/* ================================================================
   Admin Panel - Custom Styles
   Works with Tailwind CDN (no @apply - all standard CSS)
   ================================================================ */

[x-cloak] { display: none !important; }

/* Custom scrollbar */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: #f1f5f9; }
::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #94a3b8; }

/* ===== LAYOUT ===== */
/* Ensure the main content stretches to fill available width */
.main-content-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
    width: 100%;
    min-height: 0;
    overflow: hidden;
}

.page-wrapper {
    width: 100%;
    max-width: 1800px;
    margin: 0 auto;
}

/* ===== DATA TABLE ===== */
.data-table {
    width: 100%;
    text-align: left;
    font-size: 0.875rem;
    border-collapse: collapse;
}
.data-table thead th {
    padding: 14px 18px;
    background: #f8fafc;
    font-weight: 600;
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: #475569;
    border-bottom: 2px solid #e2e8f0;
    white-space: nowrap;
    position: sticky;
    top: 0;
}
.data-table tbody td {
    padding: 16px 18px;
    border-bottom: 1px solid #f1f5f9;
    vertical-align: middle;
    color: #334155;
    line-height: 1.5;
}
.data-table tbody tr {
    transition: background 0.1s ease;
}
.data-table tbody tr:hover {
    background: #f0f7ff;
}
.data-table tbody tr:last-child td {
    border-bottom: none;
}

/* ===== CARD ===== */
.card {
    background: #ffffff;
    border-radius: 16px;
    border: 1px solid #e2e8f0;
    box-shadow: 0 1px 3px rgba(0,0,0,0.04), 0 2px 8px rgba(0,0,0,0.02);
    overflow: hidden;
    width: 100%;
}
.card-header {
    padding: 24px 28px;
    border-bottom: 1px solid #f1f5f9;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
}
.card-body {
    padding: 28px;
}

/* ===== BUTTONS ===== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 20px;
    font-size: 0.875rem;
    font-weight: 500;
    border-radius: 10px;
    transition: all 0.2s ease;
    cursor: pointer;
    border: none;
    outline: none;
    white-space: nowrap;
    text-decoration: none;
}
.btn:focus-visible { box-shadow: 0 0 0 3px rgba(59,130,246,0.3); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-primary { background: #2563eb; color: white; }
.btn-primary:hover { background: #1d4ed8; transform: translateY(-1px); box-shadow: 0 4px 12px rgba(37,99,235,0.3); }
.btn-secondary { background: #f1f5f9; color: #374151; border: 1px solid #e2e8f0; }
.btn-secondary:hover { background: #e2e8f0; }
.btn-success { background: #16a34a; color: white; }
.btn-success:hover { background: #15803d; transform: translateY(-1px); box-shadow: 0 4px 12px rgba(22,163,74,0.3); }
.btn-danger { background: #dc2626; color: white; }
.btn-danger:hover { background: #b91c1c; }
.btn-sm { padding: 8px 14px; font-size: 0.8rem; border-radius: 8px; }

/* ===== FORM INPUTS ===== */
.form-input {
    width: 100%;
    padding: 11px 16px;
    border: 1.5px solid #d1d5db;
    border-radius: 10px;
    font-size: 0.875rem;
    transition: all 0.2s ease;
    background: #ffffff;
    color: #1f2937;
    line-height: 1.5;
}
.form-input:focus {
    outline: none;
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59,130,246,0.12);
}
.form-input::placeholder { color: #9ca3af; }
textarea.form-input { resize: vertical; min-height: 120px; }

.form-select {
    width: 100%;
    padding: 11px 16px;
    border: 1.5px solid #d1d5db;
    border-radius: 10px;
    font-size: 0.875rem;
    background: white;
    color: #1f2937;
    transition: all 0.2s ease;
    appearance: auto;
}
.form-select:focus { outline: none; border-color: #3b82f6; box-shadow: 0 0 0 3px rgba(59,130,246,0.12); }

.table-inline-input {
    padding: 4px 8px;
    font-size: 0.75rem;
    border-radius: 6px;
    min-width: 80px;
}
.data-table td .table-inline-input { width: 100%; }

.form-label {
    display: block;
    font-size: 0.875rem;
    font-weight: 600;
    color: #374151;
    margin-bottom: 8px;
}

/* ===== BADGE ===== */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 5px 12px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
    white-space: nowrap;
    letter-spacing: 0.01em;
}
.badge-success { background: #dcfce7; color: #166534; }
.badge-warning { background: #fef9c3; color: #854d0e; }
.badge-danger { background: #fee2e2; color: #991b1b; }
.badge-info { background: #dbeafe; color: #1e40af; }

/* ===== PAGINATION ===== */
.pagination {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
}
.page-btn {
    padding: 8px 14px;
    font-size: 0.8rem;
    border-radius: 8px;
    border: 1px solid #e2e8f0;
    color: #475569;
    background: white;
    cursor: pointer;
    transition: all 0.15s ease;
    font-weight: 500;
    min-width: 38px;
    text-align: center;
}
.page-btn:hover { background: #f1f5f9; border-color: #cbd5e1; }
.page-btn.active { background: #2563eb; color: white; border-color: #2563eb; }
.page-btn:disabled { opacity: 0.4; cursor: not-allowed; }

/* ===== SPINNER ===== */
.spinner {
    width: 36px;
    height: 36px;
    border: 3px solid #dbeafe;
    border-top-color: #2563eb;
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ===== STAT CARD ===== */
.stat-card {
    background: white;
    border-radius: 16px;
    border: 1px solid #e2e8f0;
    padding: 24px 28px;
    transition: box-shadow 0.2s ease, transform 0.2s ease;
}
.stat-card:hover {
    box-shadow: 0 8px 24px rgba(0,0,0,0.06);
    transform: translateY(-2px);
}

/* ===== TABLE CONTAINER ===== */
.table-container {
    overflow-x: auto;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    margin: 20px 24px 24px 24px;
    background: white;
}

/* ===== EMPTY STATE ===== */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 72px 24px;
    text-align: center;
}
.empty-state-icon {
    width: 72px;
    height: 72px;
    color: #cbd5e1;
    margin-bottom: 20px;
}

/* ===== MODAL ===== */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 50;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    backdrop-filter: blur(3px);
}
.modal-content {
    background: white;
    border-radius: 20px;
    box-shadow: 0 25px 60px rgba(0,0,0,0.25);
    width: 100%;
    max-width: 580px;
    max-height: 90vh;
    overflow-y: auto;
}
.modal-header {
    padding: 24px 28px 18px;
    border-bottom: 1px solid #f1f5f9;
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.modal-body { padding: 24px 28px; }
.modal-footer {
    padding: 18px 28px 24px;
    border-top: 1px solid #f1f5f9;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 12px;
}

/* ===== SKELETON ===== */
.skeleton {
    background: linear-gradient(90deg, #f1f5f9 25%, #e2e8f0 50%, #f1f5f9 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
    border-radius: 8px;
}
@keyframes shimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }

/* ===== NEWS / UPLOADS LIST ITEMS ===== */
.list-item {
    padding: 20px 28px;
    transition: background 0.15s ease;
}
.list-item:hover {
    background: #f8fafc;
}

/* ===== RESPONSIVE ===== */
@media (max-width: 1024px) {
    .card-header { padding: 20px 20px; }
    .card-body { padding: 20px; }
    .table-container { margin: 16px; }
    .data-table thead th { padding: 12px 14px; }
    .data-table tbody td { padding: 14px 14px; }
}

@media (max-width: 768px) {
    .card-header {
        flex-direction: column;
        align-items: stretch;
        gap: 12px;
    }
    .card-body { padding: 16px; }
    .table-container { margin: 12px; border-radius: 10px; overflow-x: visible; }
    .stat-card { padding: 18px; }
    .btn { padding: 9px 14px; font-size: 0.8rem; }
    .modal-content { border-radius: 16px; max-width: 100%; margin: 8px; }
    .modal-body { padding: 20px; }
    .list-item { padding: 16px 20px; }
    .empty-state { padding: 48px 16px; }

    /* --- Mobile card layout for tables --- */
    .data-table thead {
        display: none;
    }
    .data-table,
    .data-table tbody {
        display: block;
        width: 100%;
    }
    .data-table tbody tr {
        display: block;
        background: #ffffff;
        border: 1px solid #e2e8f0;
        border-radius: 12px;
        margin-bottom: 12px;
        padding: 14px 16px;
        box-shadow: 0 1px 3px rgba(0,0,0,0.04);
    }
    .data-table tbody tr:hover {
        background: #f8fafc;
    }
    .data-table tbody td {
        display: flex;
        align-items: center;
        justify-content: space-between;
        padding: 6px 0;
        border-bottom: 1px solid #f1f5f9;
        font-size: 0.82rem;
        text-align: right;
    }
    .data-table tbody td:last-child {
        border-bottom: none;
        padding-top: 10px;
        justify-content: flex-end;
    }
    .data-table tbody td::before {
        content: attr(data-label);
        font-weight: 600;
        font-size: 0.72rem;
        color: #64748b;
        text-transform: uppercase;
        letter-spacing: 0.03em;
        text-align: left;
        flex-shrink: 0;
        margin-right: 12px;
    }
    /* Hide the row number column on mobile */
    .data-table tbody td.mobile-hide {
        display: none;
    }
    /* Checkbox cells - no label needed */
    .data-table tbody td.mobile-checkbox {
        justify-content: flex-start;
        border-bottom: none;
        padding-bottom: 2px;
    }
    .data-table tbody td.mobile-checkbox::before {
        content: none;
    }
    /* Action buttons row */
    .data-table tbody td.mobile-actions {
        justify-content: flex-start;
        gap: 8px;
        padding-top: 10px;
    }
    .data-table tbody td.mobile-actions::before {
        content: none;
    }
}

@media (max-width: 480px) {
    .table-container { margin: 8px; border-radius: 8px; }
    .card-header { padding: 16px; }
    .card-body { padding: 14px; }
    .data-table tbody tr {
        padding: 12px 14px;
    }
    .data-table tbody td {
        font-size: 0.78rem;
    }
}

/* ===== HEATMAP GRID ===== */
.heatmap-cell {
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.heatmap-cell:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}


/* ===== SORTABLE HEADERS ===== */
.sortable-th {
    cursor: pointer;
    user-select: none;
    transition: background 0.15s ease;
}
.sortable-th:hover {
    background: #eef2ff !important;
}
.sort-header {
    display: inline-flex;
    align-items: center;
    gap: 4px;
}
.sort-icon {
    font-size: 0.7rem;
    opacity: 0.6;
    color: #6366f1;
}
.sortable-th:hover .sort-icon {
    opacity: 1;
}

/* ===== FILTER BAR ===== */
.filter-bar {
    border-bottom: 1px solid #e5e7eb;
}
.filter-row {
    margin-bottom: 4px;
}
.filter-row:last-child {
    margin-bottom: 0;
}
.filter-bar .form-select,
.filter-bar .form-input {
    padding: 6px 10px;
    font-size: 0.75rem;
    border-radius: 6px;
    min-width: auto;
}

/* ===== ID CARD TYPE COLUMN FIX ===== */
.data-table td .form-select.id-card-type-select {
    min-width: 130px;
    width: 130px;
}
.data-table td .form-select.id-card-lang-select {
    min-width: 110px;
    width: 110px;
}

/* ===== EXPORT BUTTON GROUP ===== */
.export-dropdown {
    position: relative;
    display: inline-block;
}
.export-dropdown-menu {
    position: absolute;
    top: 100%;
    right: 0;
    margin-top: 4px;
    background: white;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
    z-index: 50;
    min-width: 130px;
    display: none;
}
.export-dropdown-menu.show {
    display: block;
}
.export-dropdown-menu button {
    display: block;
    width: 100%;
    text-align: left;
    padding: 10px 16px;
    font-size: 0.82rem;
    color: #374151;
    border: none;
    background: none;
    cursor: pointer;
    transition: background 0.1s;
}
.export-dropdown-menu button:hover {
    background: #f1f5f9;
}
.export-dropdown-menu button:first-child {
    border-radius: 8px 8px 0 0;
}
.export-dropdown-menu button:last-child {
    border-radius: 0 0 8px 8px;
}

/* ===== ROW EDIT MODE ===== */

/* Read-mode display value */
.row-display-value {
    display: inline-block;
    font-size: 0.875rem;
    color: #334155;
    line-height: 1.5;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 180px;
}

/* Editing row — subtle highlight */
tr.row-editing {
    background: #fffbeb !important;
    box-shadow: inset 3px 0 0 #f59e0b;
}
tr.row-editing td {
    border-bottom-color: #fde68a;
}

/* Inputs inside an editing row */
tr.row-editing .table-inline-input {
    background: #ffffff;
    border-color: #3b82f6;
}

/* Mobile: editing row display */
@media (max-width: 768px) {
    tr.row-editing {
        border-color: #f59e0b !important;
        box-shadow: 0 0 0 2px #fde68a;
    }
    .row-display-value {
        max-width: 100%;
        white-space: normal;
    }
    .data-table tbody td .row-edit-input {
        width: 100%;
        margin-top: 4px;
    }
}

/* ===== TRUNCATE CELL WITH HOVER TOOLTIP ===== */
.truncate-cell {
    cursor: help;
    border-bottom: 1px dashed #94a3b8;
    position: relative;
    white-space: nowrap;
}

/* Native title tooltip is enough on desktop, but we enhance it visually */
.truncate-cell:hover {
    color: #2563eb;
    border-bottom-color: #2563eb;
}
