/* CentraMEDKIT Category Management — Modern */

:root {
    --cat-ink: #0f172a;
    --cat-ink-700: #334155;
    --cat-ink-500: #64748b;
    --cat-ink-400: #94a3b8;
    --cat-line: #e2e8f0;
    --cat-brand: #7c3aed;
    --cat-brand-700: #6d28d9;
    --cat-green: #059669;
    --cat-red: #dc2626;
    --cat-amber: #b45309;
}

.cat-wrap {
    padding: 1.5rem;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

/* ---------- Header ---------- */

.cat-header {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
}

.cat-title {
    margin: 0;
    font-size: 1.6rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    color: var(--cat-ink);
}

.cat-subtitle {
    margin: 0.3rem 0 0;
    font-size: 0.88rem;
    color: var(--cat-ink-500);
}

.cat-back {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--cat-ink-500);
    text-decoration: none;
    margin-bottom: 0.6rem;
}

.cat-back:hover {
    color: var(--cat-brand);
}

.cat-back svg {
    width: 14px;
    height: 14px;
}

.cat-actions {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    flex-wrap: wrap;
}

.cat-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    padding: 0.55rem 1.1rem;
    border-radius: 10px;
    font-size: 0.85rem;
    font-weight: 600;
    text-decoration: none;
    border: 1px solid transparent;
    cursor: pointer;
    transition: all 0.2s ease;
    margin-top: 0 !important;
}

.cat-btn svg {
    width: 15px;
    height: 15px;
}

.cat-btn-primary {
    background: var(--cat-brand) !important;
    color: #ffffff !important;
    box-shadow: 0 8px 20px -8px rgba(124, 58, 237, 0.6);
}

.cat-btn-primary:hover {
    background: var(--cat-brand-700) !important;
    color: #ffffff !important;
    transform: translateY(-1px);
}

/* ---------- Stats ---------- */

.cat-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 1rem;
}

.cat-stat {
    display: flex;
    align-items: center;
    gap: 1rem;
    background: #fff;
    border: 1px solid rgba(15, 23, 42, 0.05);
    border-radius: 14px;
    box-shadow: 0 8px 24px -16px rgba(2, 24, 72, 0.25);
    padding: 1.1rem 1.25rem;
}

.cat-stat-icon {
    flex: none;
    width: 46px;
    height: 46px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.cat-stat-icon svg {
    width: 22px;
    height: 22px;
}

.cat-stat-violet .cat-stat-icon { background: rgba(124, 58, 237, 0.12); color: var(--cat-brand); }
.cat-stat-blue .cat-stat-icon { background: rgba(59, 130, 246, 0.12); color: #2563eb; }
.cat-stat-amber .cat-stat-icon { background: rgba(245, 158, 11, 0.14); color: var(--cat-amber); }

.cat-stat-number {
    display: block;
    font-size: 1.55rem;
    font-weight: 700;
    color: var(--cat-ink);
    line-height: 1.2;
}

.cat-stat-label {
    display: block;
    font-size: 0.8rem;
    color: var(--cat-ink-500);
    font-weight: 500;
    margin-top: 0.1rem;
}

/* ---------- Panel / table ---------- */

.cat-panel {
    background: #fff;
    border: 1px solid rgba(15, 23, 42, 0.05);
    border-radius: 16px;
    box-shadow: 0 8px 24px -16px rgba(2, 24, 72, 0.25);
    overflow: hidden;
}

.cat-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid #eef2f7;
}

.cat-panel-title {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    margin: 0;
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--cat-ink);
}

.cat-panel-title svg {
    width: 17px;
    height: 17px;
    color: var(--cat-brand);
}

.cat-table-wrap {
    overflow-x: auto;
}

.cat-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.88rem;
}

.cat-table thead th {
    text-align: left;
    padding: 0.75rem 1.25rem;
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--cat-ink-400);
    background: #f8fafc;
    border-bottom: 1px solid #eef2f7;
    white-space: nowrap;
}

.cat-table tbody td {
    padding: 0.9rem 1.25rem;
    border-bottom: 1px solid #f1f5f9;
    vertical-align: middle;
    color: var(--cat-ink-700);
}

.cat-table tbody tr {
    transition: background 0.15s ease;
}

.cat-table tbody tr:hover {
    background: rgba(124, 58, 237, 0.03);
}

.cat-table tbody tr:last-child td {
    border-bottom: none;
}

.cat-cell-name {
    display: flex;
    align-items: center;
    gap: 0.85rem;
    min-width: 0;
}

.cat-avatar {
    flex: none;
    width: 40px;
    height: 40px;
    border-radius: 12px;
    background: rgba(124, 58, 237, 0.12);
    color: var(--cat-brand);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    font-size: 0.95rem;
}

.cat-name {
    font-weight: 700;
    color: var(--cat-ink);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.cat-desc {
    font-size: 0.78rem;
    color: var(--cat-ink-400);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 320px;
}

.cat-count-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.28rem 0.7rem;
    border-radius: 999px;
    font-size: 0.76rem;
    font-weight: 700;
    background: rgba(124, 58, 237, 0.1);
    color: var(--cat-brand);
}

.cat-count-badge.cat-count-empty {
    background: rgba(100, 116, 139, 0.12);
    color: var(--cat-ink-500);
}

.cat-date {
    font-size: 0.8rem;
    color: var(--cat-ink-500);
    white-space: nowrap;
}

.cat-row-actions {
    display: flex;
    align-items: center;
    gap: 0.45rem;
    justify-content: flex-end;
}

.cat-icon-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    border-radius: 9px;
    border: 1px solid transparent;
    cursor: pointer;
    transition: all 0.15s ease;
    background: transparent;
}

.cat-icon-btn svg {
    width: 15px;
    height: 15px;
}

.cat-icon-btn-edit {
    color: var(--cat-amber);
    background: rgba(245, 158, 11, 0.1);
}

.cat-icon-btn-edit:hover {
    background: var(--cat-amber);
    color: #fff;
}

.cat-icon-btn-del {
    color: var(--cat-red);
    background: rgba(239, 68, 68, 0.1);
}

.cat-icon-btn-del:hover {
    background: var(--cat-red);
    color: #fff;
}

.cat-empty {
    text-align: center;
    padding: 3rem 1rem;
    color: var(--cat-ink-400);
}

.cat-empty .cat-empty-icon {
    font-size: 2.6rem;
    margin-bottom: 0.75rem;
}

/* ---------- Modal ---------- */

.cat-modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.55);
    backdrop-filter: blur(4px);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    padding: 1rem;
}

.cat-modal-overlay.open {
    display: flex;
}

.cat-modal {
    background: #fff;
    border-radius: 16px;
    max-width: 520px;
    width: 100%;
    box-shadow: 0 25px 60px rgba(0, 0, 0, 0.35);
    overflow: hidden;
    animation: cat-modal-in 0.2s ease-out;
}

@keyframes cat-modal-in {
    from { opacity: 0; transform: translateY(12px) scale(0.98); }
    to { opacity: 1; transform: none; }
}

.cat-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1.1rem 1.5rem;
    background: linear-gradient(135deg, #8b5cf6, #7c3aed);
    color: #fff;
}

.cat-modal-header h3 {
    margin: 0;
    font-size: 1.05rem;
    font-weight: 700;
}

.cat-modal-close {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: #fff;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    font-size: 1rem;
    cursor: pointer;
    line-height: 1;
}

.cat-modal-close:hover {
    background: rgba(255, 255, 255, 0.35);
}

.cat-modal-body {
    padding: 1.5rem;
}

.cat-field {
    margin-bottom: 1.25rem;
}

.cat-field:last-child {
    margin-bottom: 0;
}

.cat-field label {
    display: block;
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--cat-ink-700);
    margin-bottom: 0.4rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.cat-field label .req {
    color: var(--cat-red);
}

.cat-field input,
.cat-field textarea {
    width: 100%;
    box-sizing: border-box;
    padding: 0.7rem 0.9rem;
    border: 1px solid var(--cat-line);
    border-radius: 10px;
    font-size: 0.92rem;
    font-family: inherit;
    color: var(--cat-ink);
    background: #fff;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.cat-field textarea {
    resize: vertical;
    min-height: 90px;
}

.cat-field input:focus,
.cat-field textarea:focus {
    outline: none;
    border-color: var(--cat-brand);
    box-shadow: 0 0 0 3px rgba(124, 58, 237, 0.12);
}

.cat-field-error {
    display: none;
    margin-top: 0.4rem;
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--cat-red);
}

.cat-field.invalid input,
.cat-field.invalid textarea {
    border-color: var(--cat-red);
}

.cat-field.invalid .cat-field-error {
    display: block;
}

.cat-modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 0.6rem;
    margin-top: 1.5rem;
    padding-top: 1.1rem;
    border-top: 1px solid #f1f5f9;
}

.cat-btn-ghost {
    background: #ffffff !important;
    color: #475569 !important;
    border: 1px solid #e2e8f0;
}

.cat-btn-ghost:hover {
    color: var(--cat-ink-700) !important;
    border-color: var(--cat-ink-400);
}

.cat-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

/* ---------- Toasts ---------- */

.cat-toasts {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 3000;
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
    max-width: 360px;
}

.cat-toast {
    display: flex;
    align-items: flex-start;
    gap: 0.65rem;
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 12px 32px rgba(2, 24, 72, 0.18);
    padding: 0.85rem 1rem;
    font-size: 0.87rem;
    font-weight: 600;
    color: var(--cat-ink);
    border-left: 4px solid var(--cat-green);
    animation: cat-toast-in 0.25s ease-out;
}

.cat-toast.cat-toast-error {
    border-left-color: var(--cat-red);
}

.cat-toast.cat-toast-error .cat-toast-icon {
    background: rgba(239, 68, 68, 0.12);
    color: var(--cat-red);
}

.cat-toast.cat-toast-success .cat-toast-icon {
    background: rgba(16, 185, 129, 0.12);
    color: var(--cat-green);
}

.cat-toast-icon {
    flex: none;
    width: 26px;
    height: 26px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
}

.cat-toast-msg {
    line-height: 1.4;
    padding-top: 0.15rem;
}

.cat-toast.hide {
    opacity: 0;
    transform: translateX(20px);
    transition: opacity 0.3s ease, transform 0.3s ease;
}

@keyframes cat-toast-in {
    from { opacity: 0; transform: translateX(24px); }
    to { opacity: 1; transform: none; }
}

/* ---------- Responsive ---------- */

@media (max-width: 768px) {
    .cat-wrap {
        padding: 1rem;
    }

    .cat-header {
        align-items: flex-start;
        flex-direction: column;
    }

    .cat-stats {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 480px) {
    .cat-stats {
        grid-template-columns: 1fr;
    }
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}
