/* ============================================
   KonX — Factures Page Styles
   ============================================ */

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

/* ---- Page Header ---- */
.page-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: var(--space-6);
}

.page-header-left {
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
}

.page-title-row {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    flex-wrap: wrap;
}

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

.page-badge {
    padding: 4px 14px;
    border-radius: var(--border-radius-full);
    font-size: var(--font-xs);
    font-weight: var(--weight-semibold);
    letter-spacing: 0.01em;
}

.page-badge-red {
    background: #fee2e2;
    color: #dc2626;
}

.page-badge-gray {
    background: var(--neutral-100);
    color: var(--neutral-600);
    border: 1px solid var(--neutral-200);
}

.page-subtitle {
    font-size: var(--font-md);
    color: var(--neutral-500);
    font-weight: var(--weight-regular);
    line-height: var(--line-height-normal);
}

.page-header-right {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    flex-shrink: 0;
}

.btn-header-action {
    padding: 10px 20px;
    font-size: var(--font-md);
    border-radius: var(--border-radius-md);
}

.btn-header-action.btn-outline {
    border: 1px solid var(--neutral-300);
    background: var(--white);
    color: var(--neutral-700);
}

.btn-header-action.btn-outline:hover {
    background: var(--neutral-50);
    border-color: var(--neutral-400);
}

.btn-header-action.btn-primary {
    padding: 10px 24px;
    border-radius: var(--border-radius-md);
    box-shadow: 0 2px 8px rgba(185, 28, 28, 0.3);
}

/* ---- Toolbar ---- */
.factures-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-4);
    padding: var(--space-4) var(--space-5);
    background: var(--white);
    border-radius: 16px;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.06);
}

.toolbar-filters {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    flex-wrap: wrap;
}

.filter-btn {
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
    padding: 8px 16px;
    background: var(--white);
    border: 1px solid var(--neutral-300);
    border-radius: var(--border-radius-md);
    font-size: var(--font-sm);
    font-weight: var(--weight-medium);
    color: var(--neutral-700);
    cursor: pointer;
    transition: all var(--transition-fast);
    white-space: nowrap;
}

.filter-btn:hover {
    border-color: var(--neutral-400);
    background: var(--neutral-50);
}

.filter-btn i {
    font-size: 10px;
    color: var(--neutral-400);
}

.filter-more {
    border-style: dashed;
    color: var(--neutral-500);
}

.filter-more i {
    font-size: var(--font-sm);
    color: var(--neutral-500);
}

.toolbar-actions {
    display: flex;
    align-items: center;
    gap: var(--space-1);
    border-left: 1px solid var(--neutral-200);
    padding-left: var(--space-4);
    margin-left: var(--space-2);
}

.toolbar-action-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 8px 12px;
    border-radius: var(--border-radius-md);
    color: var(--neutral-500);
    font-size: 10px;
    font-weight: var(--weight-medium);
    cursor: pointer;
    transition: all var(--transition-fast);
    border: none;
    background: none;
    min-width: 64px;
}

.toolbar-action-btn i {
    font-size: var(--font-lg);
}

.toolbar-action-btn:hover {
    background: var(--neutral-50);
    color: var(--primary-500);
}

/* ---- Factures Table Card ---- */
.factures-list-card {
    animation: fadeInUp 0.4s ease-out 0.1s both;
}

.factures-list-card .card-body {
    padding: 0;
}

/* ---- Full Table ---- */
.factures-full-table {
    width: 100%;
}

.factures-full-table thead th {
    padding: 14px 20px;
    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-bottom: 1px solid var(--neutral-200);
    white-space: nowrap;
}

.factures-full-table tbody tr {
    border-bottom: 1px solid var(--neutral-100);
    transition: background var(--transition-fast);
}

.factures-full-table tbody tr:last-child {
    border-bottom: none;
}

.factures-full-table tbody tr:hover {
    background: #fafbfc;
}

.factures-full-table tbody td {
    padding: 16px 20px;
    font-size: var(--font-md);
    vertical-align: middle;
    color: var(--neutral-700);
}

/* Checkbox */
.th-checkbox,
.td-checkbox {
    width: 44px;
    text-align: center;
    padding-left: 16px !important;
    padding-right: 8px !important;
}

.custom-checkbox {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    position: relative;
    cursor: pointer;
    width: 18px;
    height: 18px;
}

.custom-checkbox input {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
}

.custom-checkbox .checkmark {
    width: 18px;
    height: 18px;
    border: 2px solid var(--neutral-300);
    border-radius: 4px;
    background: var(--white);
    transition: all var(--transition-fast);
    display: flex;
    align-items: center;
    justify-content: center;
}

.custom-checkbox input:checked + .checkmark {
    background: var(--primary-500);
    border-color: var(--primary-500);
}

.custom-checkbox input:checked + .checkmark::after {
    content: '';
    width: 5px;
    height: 9px;
    border: solid white;
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
    margin-top: -2px;
}

.custom-checkbox:hover .checkmark {
    border-color: var(--neutral-400);
}

/* Invoice Number */
.invoice-num {
    font-family: 'SF Mono', 'Fira Code', 'Consolas', monospace;
    font-size: var(--font-md);
    font-weight: var(--weight-semibold);
    color: var(--primary-500);
    cursor: pointer;
    transition: color var(--transition-fast);
}

.invoice-num:hover {
    color: var(--primary-700);
    text-decoration: underline;
}

/* Client */
.td-client {
    font-weight: var(--weight-medium);
    color: var(--neutral-800);
}

/* Date */
.td-date {
    color: var(--neutral-500);
    font-size: var(--font-sm);
    white-space: nowrap;
}

/* Amount */
.td-amount {
    font-weight: var(--weight-bold);
    color: var(--neutral-900);
    white-space: nowrap;
    text-align: right;
}

/* ---- Status Badges ---- */
.status-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 12px;
    border-radius: var(--border-radius-full);
    font-size: var(--font-xs);
    font-weight: var(--weight-medium);
    white-space: nowrap;
}

.status-indicator {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    flex-shrink: 0;
}

.status-indicator-green {
    background: #10b981;
}

.status-indicator-yellow {
    background: #f59e0b;
}

.status-indicator-red {
    background: #ef4444;
}

.status-validated {
    background: #ecfdf5;
    color: #059669;
}

.status-inprogress {
    background: #fffbeb;
    color: #b45309;
}

.status-rejected {
    background: #fef2f2;
    color: #dc2626;
}

/* ---- Payment Badges ---- */
.payment-badge {
    display: inline-flex;
    align-items: center;
    padding: 4px 14px;
    border-radius: var(--border-radius-sm);
    font-size: var(--font-xs);
    font-weight: var(--weight-semibold);
    white-space: nowrap;
    letter-spacing: 0.01em;
}

.payment-paid {
    background: #ecfdf5;
    color: #059669;
}

.payment-pending {
    background: #f3f4f6;
    color: #6b7280;
    border: 1px solid #e5e7eb;
}

.payment-unpaid {
    background: #fef2f2;
    color: #dc2626;
}

.payment-partial {
    background: #fffbeb;
    color: #d97706;
}

/* ---- Canal Badge ---- */
.canal-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: var(--font-sm);
    color: var(--neutral-600);
    font-weight: var(--weight-medium);
}

.canal-badge i {
    font-size: var(--font-sm);
    color: var(--neutral-400);
}

.canal-badge .fa-whatsapp {
    color: #25d366;
}

.canal-empty {
    color: var(--neutral-400);
}

/* ---- Action Dots & Dropdown ---- */
.td-actions {
    position: relative;
    width: 48px;
    text-align: center;
}

.btn-dots {
    width: 32px;
    height: 32px;
    border-radius: var(--border-radius-sm);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: var(--neutral-400);
    font-size: var(--font-md);
    cursor: pointer;
    transition: all var(--transition-fast);
    border: none;
    background: none;
}

.btn-dots:hover {
    background: var(--neutral-100);
    color: var(--neutral-700);
}

.action-dropdown {
    position: absolute;
    top: 100%;
    right: 16px;
    width: 220px;
    background: var(--white);
    border-radius: 12px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.12), 0 2px 8px rgba(0, 0, 0, 0.06);
    padding: 6px;
    z-index: 200;
    display: none;
    animation: dropdownFade 0.15s ease-out;
}

.action-dropdown.show {
    display: block;
}

@keyframes dropdownFade {
    from {
        opacity: 0;
        transform: translateY(-4px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.dropdown-item {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 10px 14px;
    border: none;
    background: none;
    font-size: var(--font-sm);
    font-weight: var(--weight-medium);
    color: var(--neutral-700);
    cursor: pointer;
    border-radius: 8px;
    transition: all var(--transition-fast);
    text-align: left;
}

.dropdown-item:hover {
    background: var(--neutral-50);
    color: var(--neutral-900);
}

.dropdown-item i {
    width: 16px;
    text-align: center;
    font-size: var(--font-sm);
    color: var(--neutral-400);
}

.dropdown-item:hover i {
    color: var(--neutral-600);
}

/* ---- Table Footer / Pagination ---- */
.table-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 24px;
    border-top: 1px solid var(--neutral-100);
}

.table-info {
    font-size: var(--font-sm);
    color: var(--neutral-500);
    font-weight: var(--weight-regular);
}

.pagination {
    display: flex;
    align-items: center;
    gap: 4px;
}

.page-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 36px;
    height: 36px;
    padding: 0 4px;
    border: 1px solid var(--neutral-200);
    border-radius: var(--border-radius-md);
    background: var(--white);
    color: var(--neutral-700);
    font-size: var(--font-sm);
    font-weight: var(--weight-medium);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.page-btn:hover:not(:disabled):not(.active) {
    background: var(--neutral-50);
    border-color: var(--neutral-300);
}

.page-btn.active {
    background: var(--primary-500);
    color: var(--white);
    border-color: var(--primary-500);
    box-shadow: 0 1px 4px rgba(185, 28, 28, 0.25);
}

.page-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.page-btn i {
    font-size: 11px;
}

.page-ellipsis {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 36px;
    height: 36px;
    color: var(--neutral-400);
    font-size: var(--font-sm);
}

/* ============================================
   RESPONSIVE — Factures
   ============================================ */
@media (max-width: 1200px) {
    .toolbar-actions {
        display: none;
    }
}

@media (max-width: 1024px) {
    .page-content {
        padding: var(--space-5) var(--space-5);
    }

    .factures-toolbar {
        flex-direction: column;
        align-items: flex-start;
    }

    .toolbar-actions {
        border-left: none;
        padding-left: 0;
        margin-left: 0;
        border-top: 1px solid var(--neutral-200);
        padding-top: var(--space-3);
        width: 100%;
        justify-content: flex-start;
    }
}

@media (max-width: 768px) {
    .page-header {
        flex-direction: column;
        gap: var(--space-4);
    }

    .page-header-right {
        width: 100%;
    }

    .page-header-right .btn {
        flex: 1;
    }

    .page-content {
        padding: var(--space-4);
    }

    .factures-full-table {
        display: block;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .table-footer {
        flex-direction: column;
        gap: var(--space-3);
        text-align: center;
    }

    .toolbar-filters {
        width: 100%;
    }

    .filter-btn {
        flex: 1;
        justify-content: center;
    }
}

@media (max-width: 480px) {
    .page-title {
        font-size: 1.375rem;
    }

    .page-badge {
        font-size: 10px;
    }

    .btn-header-action span {
        display: none;
    }

    .pagination {
        gap: 2px;
    }

    .page-btn {
        min-width: 32px;
        height: 32px;
    }
}

/* ============================================
   Filter Dropdown Menus
   ============================================ */
.filter-dropdown {
    position: relative;
}

.filter-menu {
    position: absolute;
    top: calc(100% + 6px);
    left: 0;
    min-width: 220px;
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.12);
    z-index: 1000;
    padding: 6px;
    animation: filterSlideIn 0.2s ease;
}

@keyframes filterSlideIn {
    from {
        opacity: 0;
        transform: translateY(-8px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.filter-menu-item {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 10px 12px;
    border: none;
    background: none;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 500;
    color: #374151;
    cursor: pointer;
    font-family: 'Inter', sans-serif;
    transition: background 0.15s;
    text-align: left;
}

.filter-menu-item:hover {
    background: #f3f4f6;
}

.filter-menu-item.active {
    background: #fef2f2;
    color: #dc2626;
    font-weight: 600;
}

.filter-menu-item i {
    width: 16px;
    text-align: center;
    font-size: 13px;
}

.filter-check {
    margin-left: auto;
    font-size: 12px;
    color: #dc2626;
}

.filter-btn.filter-active {
    border-color: #dc2626;
    color: #dc2626;
    background: #fef2f2;
}

/* Invoice number hover */
.invoice-num {
    cursor: pointer;
    transition: color 0.2s;
}

.invoice-num:hover {
    color: #dc2626;
    text-decoration: underline;
}

/* RTL support for filter menus */
html[dir="rtl"] .filter-menu {
    left: auto;
    right: 0;
}

html[dir="rtl"] .filter-menu-item {
    text-align: right;
}

html[dir="rtl"] .filter-check {
    margin-left: 0;
    margin-right: auto;
}

html[dir="rtl"] .factures-full-table thead th,
html[dir="rtl"] .factures-full-table tbody td {
    text-align: right !important;
}

html[dir="rtl"] .th-checkbox,
html[dir="rtl"] .td-checkbox,
html[dir="rtl"] .td-actions {
    text-align: center !important;
}

html[dir="rtl"] .toolbar-actions {
    border-left: none;
    border-right: 1px solid var(--neutral-200);
    padding-left: 0;
    padding-right: var(--space-4);
    margin-left: 0;
    margin-right: var(--space-2);
}

html[dir="rtl"] .filter-menu-item {
    flex-direction: row-reverse;
    justify-content: flex-start;
}

html[dir="rtl"] .pagination {
    flex-direction: row-reverse;
}

html[dir="rtl"] .page-prev i,
html[dir="rtl"] .page-next i {
    transform: rotate(180deg);
}

/* RTL dropdown position */
html[dir="rtl"] .action-dropdown {
    right: auto;
    left: 16px;
}

html[dir="rtl"] .dropdown-item {
    text-align: right;
    flex-direction: row;
    justify-content: flex-start;
    direction: rtl;
}

/* RTL amount cell - keep numbers LTR */
html[dir="rtl"] .td-amount {
    direction: ltr !important;
    unicode-bidi: isolate !important;
    text-align: left !important;
}

/* RTL filter buttons */
html[dir="rtl"] .filter-btn {
    flex-direction: row-reverse;
}

html[dir="rtl"] .toolbar-filters {
    flex-direction: row-reverse;
}
