/* === CSS Variables === */
:root {
    --primary-color: #0f766e;
    --primary-dark: #0b4f4a;
    --secondary-color: #f59e0b;
    --secondary-dark: #d97706;
    --accent-color: #14b8a6;
    --danger-color: #ef4444;
    --text-color: #111827;
    --text-light: #6b7280;
    --bg-color: #f8fafc;
    --card-bg: #ffffff;
    --border-color: #e2e8f0;
    --shadow: 0 8px 24px rgba(15, 23, 42, 0.08);
    --shadow-lg: 0 18px 40px rgba(15, 23, 42, 0.12);
    --radius: 14px;
    --radius-sm: 10px;
}

/* === Cases Page === */
.cases-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 20px;
    margin-bottom: 40px;
}

.case-card {
    background: #CDCEB4;
    border-radius: var(--radius);
    padding: 20px 24px;
    text-decoration: none;
    color: var(--text-color);
    box-shadow: var(--shadow);
    border: 1px solid rgba(0, 0, 0, 0.08);
    transition: all 0.25s ease;
    min-height: 140px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.case-card:nth-child(12n + 1) { background: #AEDADB; }
.case-card:nth-child(12n + 2) { background: #CDB4D6; }
.case-card:nth-child(12n + 3) { background: #B4C1E6; }
.case-card:nth-child(12n + 4) { background: #C6D8B6; }
.case-card:nth-child(12n + 5) { background: #D1A5CE; }
.case-card:nth-child(12n + 6) { background: #E89292; }
.case-card:nth-child(12n + 7) { background: #BEE1E6; }
.case-card:nth-child(12n + 8) { background: #A8B6D8; }
.case-card:nth-child(12n + 9) { background: #F2E6A2; }
.case-card:nth-child(12n + 10) { background: #F9C0CC; }
.case-card:nth-child(12n + 11) { background: #B0C4A4; }
.case-card:nth-child(12n + 12) { background: #E5C58F; }

.case-card-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.case-card:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-lg);
    border-color: rgba(17, 24, 39, 0.2);
}

 .case-card.active {
    border-color: rgba(17, 24, 39, 0.25);
 }

.case-number {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary-color), var(--accent-color));
    color: white;
    font-weight: 700;
    font-size: 0.95rem;
}

.case-count {
    font-size: 0.85rem;
    font-weight: 700;
    color: rgba(17, 24, 39, 0.85);
    background: rgba(255, 255, 255, 0.55);
    padding: 6px 12px;
    border-radius: 999px;
    align-self: flex-start;
}

.case-title-ar {
    font-size: 0.95rem;
    font-weight: 600;
    color: rgba(17, 24, 39, 0.8);
    margin-top: -4px;
}

.cases-toolbar {
    margin-bottom: 14px;
}

.back-button {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    border-radius: 999px;
    background: #111827;
    color: #ffffff;
    text-decoration: none;
    font-weight: 700;
    box-shadow: var(--shadow);
}

.back-button:hover {
    opacity: 0.9;
}

.page-header h1 i {
    display: none;
}

.case-header-banner {
    background: #AEDADB;
    border-radius: 14px;
    padding: 18px 22px;
    box-shadow: var(--shadow);
    align-items: flex-start;
}

.case-header-banner.color-1 { background: #AEDADB; }
.case-header-banner.color-2 { background: #CDB4D6; }
.case-header-banner.color-3 { background: #B4C1E6; }
.case-header-banner.color-4 { background: #C6D8B6; }
.case-header-banner.color-5 { background: #D1A5CE; }
.case-header-banner.color-6 { background: #E89292; }
.case-header-banner.color-7 { background: #BEE1E6; }
.case-header-banner.color-8 { background: #A8B6D8; }
.case-header-banner.color-9 { background: #F2E6A2; }
.case-header-banner.color-10 { background: #F9C0CC; }
.case-header-banner.color-11 { background: #B0C4A4; }
.case-header-banner.color-12 { background: #E5C58F; }

.case-header-banner .count-badge {
    background: #ef4444;
    color: #ffffff;
    border-radius: 999px;
    min-width: 36px;
    height: 36px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    box-shadow: 0 6px 14px rgba(239, 68, 68, 0.35);
}

.case-results {
    margin-top: 20px;
}

.case-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    flex-wrap: wrap;
    gap: 10px;
}

html[dir="ltr"] .case-header {
    flex-direction: row;
}

/* === Reset & Base === */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: Arial, sans-serif;
    background: var(--bg-color);
    color: var(--text-color);
    line-height: 1.6;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 20px;
}

.case-results-container {
    max-width: none;
    width: 100%;
    padding: 0 30px;
}

/* === Navbar === */
.navbar {
    background: linear-gradient(135deg, var(--primary-color), var(--primary-dark));
    padding: 15px 0;
    position: sticky;
    top: 0;
    z-index: 1000;
    box-shadow: var(--shadow-lg);
}

.navbar .container {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.logo {
    display: flex;
    align-items: center;
    gap: 10px;
    color: white;
    text-decoration: none;
    font-size: 1.5rem;
    font-weight: 700;
}

.logo i {
    font-size: 1.8rem;
}

.nav-links {
    display: flex;
    list-style: none;
    gap: 10px;
}

.lang-switch {
    display: flex;
    align-items: center;
    gap: 8px;
    color: white;
    font-weight: 600;
}

.lang-option {
    color: white;
    text-decoration: none;
    padding: 6px 10px;
    border-radius: 999px;
    transition: all 0.2s ease;
    background: rgba(255, 255, 255, 0.15);
}

.lang-option.active {
    background: white;
    color: var(--primary-dark);
}

.lang-divider {
    opacity: 0.6;
}

.nav-links a {
    color: white;
    text-decoration: none;
    padding: 10px 20px;
    border-radius: var(--radius-sm);
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 8px;
}

.nav-links a:hover {
    background: rgba(255, 255, 255, 0.2);
}

.admin-link {
    background: rgba(255, 255, 255, 0.1);
}

.mobile-menu-btn {
    display: none;
    background: none;
    border: none;
    color: white;
    font-size: 1.5rem;
    cursor: pointer;
}

/* === Main Content === */
.main-content {
    flex: 1;
    padding: 40px 0;
}

/* === Home Page === */
.hero {
    text-align: center;
    padding: 60px 20px;
    background: #CCAFD7;
    border-radius: var(--radius);
    margin-bottom: 40px;
    color: #111827;
}

.hero h1 {
    font-size: 2.5rem;
    margin-bottom: 15px;
}

.hero p {
    font-size: 1.2rem;
    opacity: 0.9;
}

.hero-actions {
    margin: -10px 0 10px;
    display: flex;
    justify-content: center;
    gap: 16px;
    flex-wrap: wrap;
}

.hero-btn {
    padding: 14px 36px;
    border-radius: 999px;
    font-weight: 700;
    text-decoration: none;
    border: 2px solid transparent;
    transition: all 0.25s ease;
    box-shadow: var(--shadow);
}

.hero-btn.primary {
    background: #111827;
    color: #f8fafc;
}

.hero-btn.primary:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.hero-btn.outline {
    background: transparent;
    color: #111827;
    border-color: #111827;
}

.hero-btn.outline:hover {
    background: rgba(17, 24, 39, 0.08);
}

.category-cards {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 30px;
    margin-top: 40px;
}

.category-card {
    background: #ffffff;
    border-radius: var(--radius);
    padding: 30px 28px;
    text-align: right;
    box-shadow: var(--shadow);
    transition: all 0.3s ease;
    text-decoration: none;
    color: var(--text-color);
    border: 2px solid transparent;
}

.category-card:hover {
    transform: translateY(-5px);
    box-shadow: var(--shadow-lg);
}

.category-card.color-1 {
    background: #752067;
    color: #ffffff;
}

.category-card.color-2 {
    background: #92CE56;
    color: #111827;
}

.category-card.color-3 {
    background: #6D38A5;
    color: #ffffff;
}

.category-card.color-4 {
    background: #FF01B1;
    color: #ffffff;
}

.category-card.color-5 {
    background: #FF7A1A;
    color: #111827;
}

.category-card.color-6 {
    background: #1E9BB8;
    color: #ffffff;
}

.category-card h2 {
    font-size: 1.5rem;
    margin-bottom: 10px;
}

.category-card p {
    color: var(--text-light);
}

.category-card.color-1 p,
.category-card.color-3 p,
.category-card.color-4 p,
.category-card.color-6 p {
    color: rgba(255, 255, 255, 0.85);
}

.category-card .count {
    display: inline-block;
    margin-top: 15px;
    padding: 8px 20px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 20px;
    font-weight: 600;
}

.category-card.color-2 .count,
.category-card.color-5 .count {
    background: rgba(17, 24, 39, 0.12);
}

html[dir="ltr"] .category-card {
    text-align: left;
}

@media (max-width: 1100px) {
    .category-cards {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 768px) {
    .category-cards {
        grid-template-columns: 1fr;
    }

    .hero {
        padding: 45px 20px;
    }
}

/* === Data Pages === */
.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
    flex-wrap: wrap;
    gap: 20px;
}

.page-header h1 {
    font-size: 2rem;
    display: flex;
    align-items: center;
    gap: 10px;
}

.page-header h1 i {
    color: var(--primary-color);
}

/* === Filters === */
.filters {
    background: var(--card-bg);
    padding: 25px;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    margin-bottom: 30px;
    display: flex;
    gap: 20px;
    flex-wrap: wrap;
    align-items: flex-end;
}

.filter-group {
    flex: 1;
    min-width: 200px;
}

.filter-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: var(--text-light);
}

.filter-group input,
.filter-group select {
    width: 100%;
    padding: 12px 15px;
    border: 2px solid var(--border-color);
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-size: 1rem;
    transition: all 0.3s ease;
}

.filter-group input:focus,
.filter-group select:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.btn {
    padding: 12px 25px;
    border: none;
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary-color), var(--primary-dark));
    color: white;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow);
}

.btn-secondary {
    background: var(--bg-color);
    color: var(--text-color);
}

.btn-secondary:hover {
    background: var(--border-color);
}

.btn-success {
    background: linear-gradient(135deg, var(--secondary-color), var(--secondary-dark));
    color: white;
}

.btn-success:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow);
}

/* === Data Table === */
.data-table-wrapper {
    background: var(--card-bg);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
}

.case-table-wrapper {
    overflow-x: auto;
}

.case-table-full {
    width: 100%;
    padding: 0;
}

.case-table {
    min-width: 1200px;
}

.case-results-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0 12px;
}

.case-results-table thead th {
    background: transparent;
    border-bottom: none;
    padding: 0 12px 6px;
    font-size: 0.95rem;
    color: var(--text-light);
}

.case-results-table tbody tr td {
    background: #f4f4f4;
    border: none;
    padding: 12px 16px;
    box-shadow: 0 1px 10px rgba(0, 0, 0, 0.12);
    transition: background-color 0.3s ease;
}

.case-results-table tbody tr td:first-child {
    border-radius: 12px 0 0 12px;
}

.case-results-table tbody tr td:last-child {
    border-radius: 0 12px 12px 0;
}

.case-results-table tbody tr:hover td {
    background: #eeeeee;
}

.case-results-table {
    border-collapse: separate;
    border-spacing: 0 8px;
}

.case-results-table tbody tr {
    box-shadow: 0 2px 6px rgba(15, 23, 42, 0.08);
}

.case-results-table tbody tr td {
    background: #f9fafb;
    font-family: Verdana, Arial, sans-serif;
    font-weight: 700;
}

.case-results-table tbody tr:nth-child(5n + 1) td {
    background: #fff4da;
}

.case-results-table tbody tr:nth-child(5n + 2) td {
    background: #eaf3ff;
}

.case-results-table tbody tr:nth-child(5n + 3) td {
    background: #eefbea;
}

.case-results-table tbody tr:nth-child(5n + 4) td {
    background: #f4ecff;
}

.case-results-table tbody tr:nth-child(5n + 5) td {
    background: #ffe9ef;
}

/* === PDF Modal === */
.pdf-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(15, 23, 42, 0.6);
    align-items: center;
    justify-content: center;
    z-index: 2000;
    padding: 20px;
}

.pdf-modal.active {
    display: flex;
}

.pdf-modal-content {
    background: #ffffff;
    border-radius: var(--radius);
    width: 100%;
    max-width: 1100px;
    height: 80vh;
    display: flex;
    flex-direction: column;
    box-shadow: var(--shadow-lg);
}

.pdf-modal-body {
    background: #ffffff;
}

.pdf-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-color);
    background: #ffffff;
}

.pdf-modal-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}

.pdf-modal-link {
    display: inline-flex;
    align-items: center;
    padding: 8px 16px;
    border-radius: 999px;
    background: #111827;
    color: #ffffff;
    text-decoration: none;
    font-weight: 700;
}

.close-modal {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--text-light);
}

.pdf-modal-body {
    flex: 1;
    padding: 0;
    overflow: hidden;
}

.pdf-modal-body iframe {
    width: 100%;
    height: 100%;
    background: #ffffff;
    border: none;
    outline: none;
    box-shadow: none;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
}

.data-table th,
.data-table td {
    padding: 15px;
    text-align: right;
    border-bottom: 1px solid var(--border-color);
}

.data-table th {
    background: var(--bg-color);
    font-weight: 600;
    color: var(--text-light);
    white-space: nowrap;
}

.data-table tbody tr {
    transition: background 0.2s ease;
}

.data-table tbody tr:hover {
    background: rgba(37, 99, 235, 0.05);
}

.data-table td {
    max-width: 250px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.data-table td.expandable {
    cursor: pointer;
}

.data-table td.expandable:hover {
    white-space: normal;
    word-break: break-word;
}

.pdf-link {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    color: var(--danger-color);
    text-decoration: none;
    font-weight: 500;
}

.pdf-link:hover {
    text-decoration: underline;
}

/* === Pagination === */
.pagination {
    display: flex;
    justify-content: center;
    gap: 5px;
    margin-top: 30px;
}

.pagination a,
.pagination span {
    padding: 10px 15px;
    border-radius: var(--radius-sm);
    text-decoration: none;
    color: var(--text-color);
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    transition: all 0.2s ease;
}

.pagination a:hover {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
}

.pagination .active {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
}

/* === Admin Panel === */
.admin-header {
    background: linear-gradient(135deg, #1f2937, #374151);
    color: white;
    padding: 30px;
    border-radius: var(--radius);
    margin-bottom: 30px;
}

.admin-header h1 {
    display: flex;
    align-items: center;
    gap: 15px;
}

.admin-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 30px;
}

.admin-card {
    background: var(--card-bg);
    border-radius: var(--radius);
    padding: 30px;
    box-shadow: var(--shadow);
}

.admin-card h3 {
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--text-color);
}

.admin-card h3 i {
    color: var(--primary-color);
}

.upload-form {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.file-input-wrapper {
    position: relative;
    border: 2px dashed var(--border-color);
    border-radius: var(--radius);
    padding: 40px;
    text-align: center;
    transition: all 0.3s ease;
    cursor: pointer;
}

.file-input-wrapper:hover {
    border-color: var(--primary-color);
    background: rgba(37, 99, 235, 0.05);
}

.file-input-wrapper input[type="file"] {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    cursor: pointer;
}

.file-input-wrapper i {
    font-size: 3rem;
    color: var(--text-light);
    margin-bottom: 15px;
}

.file-input-wrapper p {
    color: var(--text-light);
}

.file-input-wrapper .file-name {
    margin-top: 10px;
    font-weight: 600;
    color: var(--primary-color);
}

.category-select {
    padding: 12px 15px;
    border: 2px solid var(--border-color);
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-size: 1rem;
    width: 100%;
}

/* === Stats === */
.stats-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.stat-card {
    background: var(--card-bg);
    padding: 20px;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    text-align: center;
}

.stat-card .number {
    font-size: 2rem;
    font-weight: 700;
    color: var(--primary-color);
}

.stat-card .label {
    color: var(--text-light);
    margin-top: 5px;
}

/* === Language Switcher === */
.language-switcher {
    display: flex;
    align-items: center;
    gap: 10px;
}

.language-switcher button {
    padding: 10px 15px;
    border: none;
    border-radius: var(--radius-sm);
    background: var(--card-bg);
    color: var(--text-color);
    cursor: pointer;
}

.language-switcher button:hover {
    background: var(--primary-color);
    color: white;
}

.language-switcher button.active {
    background: var(--primary-color);
    color: white;
}

/* === LTR Overrides === */
html[dir="ltr"] body {
    direction: ltr;
}

html[dir="ltr"] .data-table th,
html[dir="ltr"] .data-table td {
    text-align: left;
}

html[dir="ltr"] .search-box .search-icon {
    margin-left: 0;
    margin-right: 15px;
}

html[dir="ltr"] .page-header {
    align-items: flex-start;
}

html[dir="ltr"] .filters {
    align-items: flex-end;
}

/* === Alerts === */
.alert {
    padding: 15px 20px;
    border-radius: var(--radius-sm);
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.alert-success {
    background: rgba(16, 185, 129, 0.1);
    color: var(--secondary-dark);
    border: 1px solid var(--secondary-color);
}

.alert-error {
    background: rgba(239, 68, 68, 0.1);
    color: var(--danger-color);
    border: 1px solid var(--danger-color);
}

/* === Loading Spinner === */
.loading {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 50px;
}

.spinner {
    width: 50px;
    height: 50px;
    border: 4px solid var(--border-color);
    border-top-color: var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* === No Data === */
.no-data {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-light);
}

.no-data i {
    font-size: 4rem;
    margin-bottom: 20px;
    opacity: 0.5;
}

/* === Footer === */
.footer {
    background: var(--text-color);
    color: white;
    padding: 20px 0;
    text-align: center;
    margin-top: auto;
}

/* === Responsive === */
@media (max-width: 768px) {
    .nav-links {
        display: none;
        position: absolute;
        top: 100%;
        left: 0;
        right: 0;
        background: var(--primary-dark);
        flex-direction: column;
        padding: 20px;
    }
    
    .nav-links.active {
        display: flex;
    }
    
    .mobile-menu-btn {
        display: block;
    }
    
    .hero h1 {
        font-size: 1.8rem;
    }
    
    .filters {
        flex-direction: column;
    }
    
    .filter-group {
        width: 100%;
    }
    
    .page-header {
        flex-direction: column;
        align-items: flex-start;
    }
    
    .data-table-wrapper {
        overflow-x: auto;
    }
    
    .data-table {
        min-width: 800px;
    }

    .case-table {
        min-width: 1200px;
    }
}
