/* ============================================
   KonX — Paramètres Page Styles
   ============================================ */

/* ---- Page Content ---- */
.page-content {
    padding: var(--space-8) var(--space-8);
    display: flex;
    flex-direction: column;
    gap: var(--space-6);
}

/* ---- Page Title ---- */
.st-page-title-section {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.st-page-title {
    font-size: 1.75rem;
    font-weight: var(--weight-extrabold);
    color: var(--neutral-900);
    letter-spacing: -0.02em;
    line-height: var(--line-height-tight);
}

.st-page-subtitle {
    font-size: var(--font-md);
    color: var(--neutral-500);
    line-height: var(--line-height-relaxed);
}

/* ---- Settings Layout ---- */
.st-layout {
    display: grid;
    grid-template-columns: 220px 1fr;
    gap: var(--space-6);
    animation: stFadeInUp 0.35s ease-out both;
}

/* ---- Settings Sidebar ---- */
.st-sidebar {
    display: flex;
    flex-direction: column;
    gap: 4px;
    position: sticky;
    top: calc(var(--header-height) + var(--space-8));
    align-self: start;
}

.st-sidebar-item {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: 12px 16px;
    border-radius: var(--border-radius-lg);
    font-size: var(--font-md);
    font-weight: var(--weight-medium);
    color: var(--neutral-600);
    text-decoration: none;
    transition: all var(--transition-fast);
    cursor: pointer;
}

.st-sidebar-item:hover {
    background: var(--neutral-100);
    color: var(--neutral-800);
}

.st-sidebar-item i {
    width: 18px;
    text-align: center;
    font-size: var(--font-sm);
}

.st-sidebar-active {
    background: var(--primary-700) !important;
    color: var(--white) !important;
    font-weight: var(--weight-semibold);
    box-shadow: 0 2px 8px rgba(139, 26, 26, 0.3);
}

/* ---- Settings Content ---- */
.st-content {
    display: flex;
    flex-direction: column;
    gap: var(--space-6);
}

/* Panels */
.st-panel {
    display: none;
    flex-direction: column;
    gap: var(--space-6);
    animation: stFadeInUp 0.3s ease-out;
}

.st-panel-active {
    display: flex;
}

/* ---- Cards ---- */
.st-card {
    background: var(--white);
    border-radius: 16px;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.06);
    overflow: hidden;
}

.st-card-header {
    display: flex;
    align-items: center;
    gap: var(--space-4);
    padding: var(--space-6);
    border-bottom: 1px solid var(--neutral-100);
}

.st-card-icon {
    width: 44px;
    height: 44px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: var(--font-lg);
    flex-shrink: 0;
}

.st-icon-blue   { background: #eff6ff; color: #3b82f6; }
.st-icon-green  { background: #ecfdf5; color: #059669; }
.st-icon-purple { background: #f3e8ff; color: #7c3aed; }
.st-icon-orange { background: #fff7ed; color: #ea580c; }
.st-icon-red    { background: #fef2f2; color: #dc2626; }

.st-card-title-area {
    flex: 1;
}

.st-card-title {
    font-size: var(--font-lg);
    font-weight: var(--weight-bold);
    color: var(--neutral-900);
    margin-bottom: 2px;
}

.st-card-subtitle {
    font-size: var(--font-sm);
    color: var(--neutral-500);
}

.st-card-body {
    padding: var(--space-6);
}

.st-no-padding {
    padding: 0;
}

/* ---- Form Grid ---- */
.st-form-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: var(--space-5);
}

.st-field {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.st-field-full {
    grid-column: 1 / -1;
}

.st-label {
    font-size: var(--font-sm);
    font-weight: var(--weight-semibold);
    color: var(--neutral-700);
}

.st-input {
    padding: 10px 14px;
    border: 1px solid var(--neutral-200);
    border-radius: var(--border-radius-md);
    font-size: var(--font-md);
    font-family: var(--font-family);
    color: var(--neutral-800);
    background: var(--white);
    transition: all var(--transition-fast);
    outline: none;
}

.st-input:focus {
    border-color: var(--primary-400);
    box-shadow: 0 0 0 3px rgba(185, 28, 28, 0.1);
}

.st-input::placeholder {
    color: var(--neutral-400);
}

.st-select {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%236b7280' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 36px;
    cursor: pointer;
}

/* ---- Toggle Switch ---- */
.st-toggle-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--space-4) 0;
    border-bottom: 1px solid var(--neutral-100);
    gap: var(--space-6);
}

.st-toggle-row:last-child {
    border-bottom: none;
    padding-bottom: 0;
}

.st-toggle-row:first-child {
    padding-top: 0;
}

.st-toggle-info {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.st-toggle-info strong {
    font-size: var(--font-md);
    font-weight: var(--weight-semibold);
    color: var(--neutral-800);
}

.st-toggle-info span {
    font-size: var(--font-sm);
    color: var(--neutral-500);
}

.st-toggle {
    position: relative;
    display: inline-block;
    width: 44px;
    height: 24px;
    flex-shrink: 0;
}

.st-toggle input {
    opacity: 0;
    width: 0;
    height: 0;
}

.st-toggle-slider {
    position: absolute;
    cursor: pointer;
    inset: 0;
    background: var(--neutral-300);
    border-radius: 24px;
    transition: all var(--transition-base);
}

.st-toggle-slider::before {
    content: '';
    position: absolute;
    height: 18px;
    width: 18px;
    left: 3px;
    bottom: 3px;
    background: var(--white);
    border-radius: 50%;
    transition: all var(--transition-base);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.15);
}

.st-toggle input:checked + .st-toggle-slider {
    background: var(--primary-600);
}

.st-toggle input:checked + .st-toggle-slider::before {
    transform: translateX(20px);
}

/* ---- Upload Zones ---- */
.st-upload-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--space-6);
}

.st-upload-group {
    display: flex;
    flex-direction: column;
    gap: var(--space-3);
}

.st-upload-zone {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: var(--space-2);
    padding: var(--space-8) var(--space-6);
    border: 2px dashed var(--neutral-300);
    border-radius: var(--border-radius-lg);
    background: var(--neutral-50);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.st-upload-zone:hover {
    border-color: var(--primary-300);
    background: #fef2f2;
}

.st-upload-zone i {
    font-size: 1.75rem;
    color: var(--neutral-400);
}

.st-upload-zone:hover i {
    color: var(--primary-500);
}

.st-upload-text {
    font-size: var(--font-sm);
    font-weight: var(--weight-semibold);
    color: var(--neutral-600);
    text-align: center;
}

.st-upload-hint {
    font-size: var(--font-xs);
    color: var(--neutral-400);
}

/* ---- TVA List ---- */
.st-tva-list {
    display: flex;
    flex-direction: column;
}

.st-tva-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--space-4) 0;
    border-bottom: 1px solid var(--neutral-100);
}

.st-tva-item:last-child {
    border-bottom: none;
    padding-bottom: 0;
}

.st-tva-item:first-child {
    padding-top: 0;
}

.st-tva-left {
    display: flex;
    align-items: center;
    gap: var(--space-4);
}

.st-tva-badge {
    width: 52px;
    height: 36px;
    border-radius: var(--border-radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: var(--font-sm);
    font-weight: var(--weight-bold);
}

.st-tva-standard  { background: #ecfdf5; color: #059669; }
.st-tva-transport  { background: #fff7ed; color: #ea580c; }
.st-tva-services   { background: #eff6ff; color: #3b82f6; }
.st-tva-reduit     { background: #fef3c7; color: #d97706; }
.st-tva-exonere    { background: var(--neutral-100); color: var(--neutral-500); }

.st-tva-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.st-tva-info strong {
    font-size: var(--font-md);
    font-weight: var(--weight-semibold);
    color: var(--neutral-800);
}

.st-tva-info span {
    font-size: var(--font-xs);
    color: var(--neutral-500);
}

/* ---- Users Table ---- */
.st-users-table {
    width: 100%;
    border-collapse: collapse;
}

.st-users-table thead th {
    padding: 14px 24px;
    text-align: left;
    font-size: var(--font-xs);
    font-weight: var(--weight-semibold);
    color: var(--neutral-500);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    background: var(--neutral-50);
    border-top: 1px solid var(--neutral-200);
    border-bottom: 1px solid var(--neutral-200);
    white-space: nowrap;
}

.st-users-table tbody tr {
    transition: background var(--transition-fast);
}

.st-users-table tbody tr:hover {
    background: var(--neutral-50);
}

.st-users-table tbody td {
    padding: 16px 24px;
    vertical-align: middle;
    border-bottom: 1px solid var(--neutral-100);
    font-size: var(--font-sm);
    color: var(--neutral-700);
}

.st-user-cell {
    display: flex;
    align-items: center;
    gap: var(--space-3);
}

.st-user-cell img {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    flex-shrink: 0;
}

.st-user-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.st-user-info strong {
    font-size: var(--font-md);
    font-weight: var(--weight-semibold);
    color: var(--neutral-900);
}

.st-user-info span {
    font-size: var(--font-xs);
    color: var(--neutral-500);
}

/* Role Badges */
.st-role-badge {
    display: inline-flex;
    align-items: center;
    padding: 4px 12px;
    border-radius: var(--border-radius-full);
    font-size: var(--font-xs);
    font-weight: var(--weight-semibold);
}

.st-role-admin     { background: #fef2f2; color: var(--primary-700); }
.st-role-comptable { background: #eff6ff; color: #3b82f6; }
.st-role-editeur   { background: #fef3c7; color: #d97706; }
.st-role-lecture    { background: var(--neutral-100); color: var(--neutral-500); }

/* Status Dot */
.st-status-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    margin-right: 6px;
}

.st-status-online  { background: #10b981; }
.st-status-offline { background: var(--neutral-300); }

.st-date-cell {
    font-size: var(--font-sm);
    color: var(--neutral-500);
    white-space: nowrap;
}

/* Actions Cell */
.st-actions-cell {
    display: flex;
    align-items: center;
    gap: var(--space-2);
}

.st-btn-icon {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--neutral-100);
    border: none;
    color: var(--neutral-500);
    font-size: var(--font-sm);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.st-btn-icon:hover {
    background: var(--neutral-200);
    color: var(--neutral-800);
}

.st-btn-view:hover  { background: #dbeafe; color: #2563eb; }
.st-btn-edit:hover   { background: #fef3c7; color: #d97706; }
.st-btn-delete:hover { background: #fee2e2; color: #dc2626; }

.st-btn-add-user {
    margin-left: auto;
    gap: 6px;
    font-size: var(--font-sm) !important;
    white-space: nowrap;
}

/* ---- Sessions ---- */
.st-session-list {
    display: flex;
    flex-direction: column;
    gap: var(--space-3);
}

.st-session-item {
    display: flex;
    align-items: center;
    gap: var(--space-4);
    padding: var(--space-4);
    border-radius: var(--border-radius-lg);
    background: var(--neutral-50);
    border: 1px solid var(--neutral-100);
    transition: all var(--transition-fast);
}

.st-session-current {
    background: #ecfdf5;
    border-color: #a7f3d0;
}

.st-session-icon {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    background: var(--white);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: var(--font-lg);
    color: var(--neutral-500);
    flex-shrink: 0;
    border: 1px solid var(--neutral-200);
}

.st-session-current .st-session-icon {
    color: #059669;
    border-color: #a7f3d0;
}

.st-session-info {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.st-session-info strong {
    font-size: var(--font-md);
    font-weight: var(--weight-semibold);
    color: var(--neutral-800);
}

.st-session-info span {
    font-size: var(--font-xs);
    color: var(--neutral-500);
}

.st-session-badge {
    padding: 4px 12px;
    background: #059669;
    color: var(--white);
    border-radius: var(--border-radius-full);
    font-size: var(--font-xs);
    font-weight: var(--weight-bold);
    white-space: nowrap;
}

.st-session-revoke {
    padding: 6px 14px;
    background: none;
    border: 1px solid var(--neutral-300);
    border-radius: var(--border-radius-md);
    font-size: var(--font-xs);
    font-weight: var(--weight-semibold);
    font-family: var(--font-family);
    color: var(--neutral-600);
    cursor: pointer;
    transition: all var(--transition-fast);
    white-space: nowrap;
}

.st-session-revoke:hover {
    border-color: #dc2626;
    color: #dc2626;
    background: #fef2f2;
}

/* ---- Danger Zone ---- */
.st-danger-zone {
    display: flex;
    flex-direction: column;
}

.st-danger-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--space-4) 0;
    border-bottom: 1px solid var(--neutral-100);
    gap: var(--space-6);
}

.st-danger-item:last-child {
    border-bottom: none;
    padding-bottom: 0;
}

.st-danger-item:first-child {
    padding-top: 0;
}

.st-danger-info {
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.st-danger-info strong {
    font-size: var(--font-md);
    font-weight: var(--weight-semibold);
    color: var(--neutral-800);
}

.st-danger-info span {
    font-size: var(--font-sm);
    color: var(--neutral-500);
}

.st-btn-danger {
    background: #dc2626 !important;
    color: var(--white) !important;
    border: none !important;
    font-weight: var(--weight-semibold);
}

.st-btn-danger:hover {
    background: #b91c1c !important;
    box-shadow: 0 2px 8px rgba(220, 38, 38, 0.3);
}

/* ---- Footer Actions ---- */
.st-footer-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: var(--space-3);
    padding: var(--space-5) 0;
    border-top: 1px solid var(--neutral-200);
    margin-top: var(--space-2);
}

.st-btn-cancel {
    padding: 10px 24px !important;
    font-size: var(--font-md) !important;
}

.st-btn-save {
    padding: 10px 24px !important;
    font-size: var(--font-md) !important;
    gap: var(--space-2);
}

/* ============================================
   ANIMATIONS
   ============================================ */
@keyframes stFadeInUp {
    from {
        opacity: 0;
        transform: translateY(12px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ============================================
   RESPONSIVE
   ============================================ */
@media (max-width: 1024px) {
    .st-layout {
        grid-template-columns: 1fr;
    }

    .st-sidebar {
        flex-direction: row;
        overflow-x: auto;
        gap: var(--space-2);
        position: static;
        padding-bottom: var(--space-3);
    }

    .st-sidebar-item {
        white-space: nowrap;
        padding: 10px 16px;
    }
}

@media (max-width: 768px) {
    .page-content {
        padding: var(--space-6) var(--space-4);
    }

    .st-page-title {
        font-size: var(--font-2xl);
    }

    .st-form-grid {
        grid-template-columns: 1fr;
    }

    .st-upload-row {
        grid-template-columns: 1fr;
    }

    .st-users-table {
        display: block;
    }

    .st-footer-actions {
        flex-direction: column;
    }

    .st-btn-cancel,
    .st-btn-save {
        width: 100%;
        justify-content: center;
    }
}

/* ── Sidebar Backdrop ── */
.sidebar-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.35);
    backdrop-filter: blur(2px);
    z-index: 998;
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none;
}
.sidebar-backdrop.visible {
    opacity: 1;
    pointer-events: auto;
}

/* ── Search Focus ── */
.search-focused {
    border-color: #b91c1c !important;
    box-shadow: 0 0 0 3px rgba(185, 28, 28, 0.12) !important;
}

/* ── Settings Card Hover ── */
.st-card {
    transition: box-shadow 0.2s ease, transform 0.2s ease;
}
.st-card:hover {
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.06);
}

/* ── User Row Hover ── */
.st-users-table tbody tr {
    transition: background 0.15s ease;
}
.st-users-table tbody tr:hover {
    background: #fef2f2 !important;
}

/* ── Session Item Hover ── */
.st-session-item {
    transition: background 0.15s ease;
}
.st-session-item:hover {
    background: #f9fafb;
}

/* ── TVA Item Hover ── */
.st-tva-item {
    transition: background 0.15s ease;
}
.st-tva-item:hover {
    background: #f9fafb;
}

/* ── Settings Sidebar Active Enhancement ── */
.st-sidebar-item {
    transition: all 0.2s ease;
}
.st-sidebar-item:hover:not(.st-sidebar-active) {
    background: #f3f4f6;
    transform: translateX(2px);
}

/* ---- RTL ---- */
html[dir="rtl"] .st-users-table thead th,
html[dir="rtl"] .st-users-table tbody td {
    text-align: right !important;
}

html[dir="rtl"] .st-sidebar-item,
html[dir="rtl"] .st-card-header,
html[dir="rtl"] .st-actions-cell,
html[dir="rtl"] .st-session-item,
html[dir="rtl"] .st-session-revoke,
html[dir="rtl"] .st-tva-left,
html[dir="rtl"] .st-btn-add-user,
html[dir="rtl"] .st-btn-save {
    flex-direction: row-reverse;
}

/* RTL table icon + text order: avatar/icon on right, label on left */
html[dir="rtl"] .st-user-cell,
html[dir="rtl"] .st-actions-cell {
    flex-direction: row;
    direction: rtl;
    justify-content: flex-start;
}

/* Keep Latin user names/emails readable in RTL without punctuation drift */
html[dir="rtl"] .st-user-info strong,
html[dir="rtl"] .st-user-info span {
    direction: ltr;
    unicode-bidi: isolate;
    display: inline-block;
}

html[dir="rtl"] .st-status-dot {
    margin-right: 0;
    margin-left: 6px;
}

html[dir="rtl"] .st-select {
    background-position: left 12px center;
    padding-right: 14px;
    padding-left: 36px;
}

/* RTL sidebar position */
html[dir="rtl"] .st-sidebar {
    border-right: none;
    border-left: 1px solid var(--neutral-200);
}

/* RTL form field layout */
html[dir="rtl"] .st-form-row {
    flex-direction: row-reverse;
}

html[dir="rtl"] .st-input-suffix {
    right: auto;
    left: 14px;
}

html[dir="rtl"] .st-input-with-suffix .st-input {
    padding-right: 14px;
    padding-left: 50px;
}
