/* -*- coding: utf-8 -*- */
/**
 * Main Stylesheet
 * نظام إدارة المركز الصحي
 */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary-color: #003040;
    --primary-hover: #007090;
    --secondary-color: #2080a0;
    --secondary-hover: #007090;
    --success-color: #4CAF50;
    --danger-color: #f44336;
    --warning-color: #FF9800;
    --bg-color: #f3f8fb;
    --card-bg: #ffffff;
    --text-primary: #003040;
    --text-secondary: #666;
    --border-color: #e0e0e0;
    --sidebar-width: 250px;
    --header-height: 70px;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-primary);
    direction: rtl;
    overflow: hidden;
}

/* Login Container */
.login-container {
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100vh;
    width: 100vw;
    background: linear-gradient(135deg, #003040 0%, #007090 55%, #80c0e0 100%);
    position: relative;
    overflow: hidden;
}

.login-container::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle, rgba(255,255,255,0.1) 0%, transparent 60%);
    animation: pulse 15s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% { transform: scale(1); opacity: 0.5; }
    50% { transform: scale(1.1); opacity: 0.3; }
}

.login-card {
    background: rgba(255, 255, 255, 0.95);
    border-radius: 20px;
    padding: 50px 40px;
    width: 100%;
    max-width: 420px;
    box-shadow: 0 25px 60px rgba(0, 0, 0, 0.3);
    backdrop-filter: blur(10px);
    position: relative;
    z-index: 1;
    animation: slideUp 0.5s ease-out;
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.login-header {
    text-align: center;
    margin-bottom: 35px;
}

.login-header .logo-icon {
    font-size: 60px;
    margin-bottom: 15px;
    display: block;
}

.login-logo {
    width: 168px;
    height: 168px;
    border-radius: 50%;
    object-fit: cover;
    background: #fff;
    border: 4px solid rgba(0, 112, 144, 0.25);
    box-shadow: 0 8px 24px rgba(0, 48, 64, 0.16);
    margin-bottom: 15px;
}

.login-title {
    font-size: 26px;
    color: #003040;
    margin-bottom: 8px;
    font-weight: 700;
}

.login-subtitle {
    font-size: 16px;
    color: #6c757d;
    margin-bottom: 0;
    font-weight: 500;
}

.login-form {
    margin-top: 30px;
}

.login-guide {
    display: block;
    margin-top: 16px;
    text-align: center;
    color: #007090;
    font-weight: 700;
    text-decoration: none;
}

.login-guide:hover {
    color: #003040;
}

.login-form .form-group {
    margin-bottom: 20px;
}

.login-form .form-label {
    font-weight: 600;
    color: #495057;
    margin-bottom: 8px;
    display: block;
}

.login-form .form-control {
    padding: 14px 16px;
    border: 2px solid #e9ecef;
    border-radius: 10px;
    font-size: 15px;
    transition: all 0.3s ease;
}

.login-form .form-control:focus {
    border-color: #007090;
    box-shadow: 0 0 0 4px rgba(0, 112, 144, 0.15);
    outline: none;
}

.btn-block {
    width: 100%;
    margin-top: 25px;
    padding: 14px 20px;
    font-size: 16px;
    font-weight: 600;
    border-radius: 10px;
    background: linear-gradient(135deg, #003040 0%, #007090 100%);
    border: none;
    color: white;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(0, 48, 64, 0.28);
}

.btn-block:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0, 112, 144, 0.35);
}

.btn-block:disabled {
    opacity: 0.7;
    cursor: not-allowed;
    transform: none;
}

.login-footer {
    margin-top: 25px;
    text-align: center;
    padding-top: 20px;
    border-top: 1px solid #e9ecef;
}

.login-hint {
    font-size: 13px;
    color: #6c757d;
    margin: 0;
    background: #f8f9fa;
    padding: 10px 15px;
    border-radius: 8px;
}

.error-message {
    background-color: #fee;
    color: var(--danger-color);
    padding: 10px;
    border-radius: 5px;
    margin-bottom: 15px;
    border: 1px solid var(--danger-color);
}

.app-container {
    display: flex;
    height: 100vh;
    width: 100vw;
}

/* Sidebar */
.sidebar {
    width: var(--sidebar-width);
    background-color: var(--primary-color);
    color: white;
    display: flex;
    flex-direction: column;
    box-shadow: 2px 0 10px rgba(0, 0, 0, 0.1);
}

.sidebar-header {
    padding: 30px 20px;
    text-align: center;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.logo-container {
    display: flex;
    justify-content: center;
    align-items: center;
    margin-bottom: 10px;
}

.clinic-logo {
    width: 118px;
    height: 118px;
    background: #fff;
    border-radius: 50%;
    object-fit: cover;
    border: 3px solid rgba(255, 255, 255, 0.3);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
    transition: transform 0.3s ease;
}

.clinic-logo:hover {
    transform: scale(1.05);
}

.logo-icon {
    font-size: 50px;
    display: block;
}

.logo {
    font-size: 18px;
    font-weight: bold;
    color: white;
    margin: 0;
    line-height: 1.4;
    max-width: 200px;
    word-wrap: break-word;
}

.sidebar-nav {
    flex: 1;
    padding: 20px 0;
    overflow-y: auto;
}

.nav-btn {
    width: 100%;
    padding: 15px 20px;
    background: transparent;
    border: none;
    color: white;
    text-align: right;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 14px;
    transition: all 0.3s;
    border-right: 3px solid transparent;
}

.nav-btn:hover {
    background-color: rgba(255, 255, 255, 0.1);
    border-right-color: var(--primary-hover);
}

.nav-btn.active {
    background-color: rgba(255, 255, 255, 0.15);
    border-right-color: var(--primary-hover);
    font-weight: bold;
}

.nav-btn .icon {
    font-size: 18px;
}

.sidebar-footer {
    padding: 20px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.settings-btn {
    background-color: rgba(0, 0, 0, 0.22);
}

.settings-btn:hover {
    background-color: #4b5563;
}

/* Main Content */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.main-header {
    height: var(--header-height);
    background-color: var(--card-bg);
    padding: 0 30px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.05);
}

.user-info {
    display: flex;
    align-items: center;
    gap: 10px;
}

.btn-sm {
    padding: 6px 12px;
    font-size: 12px;
}

.page-title {
    font-size: 28px;
    font-weight: bold;
    color: var(--text-primary);
}

.content-area {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
}

/* Cards */
.card {
    background-color: var(--card-bg);
    border-radius: 15px;
    padding: 20px;
    margin-bottom: 20px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
}

.card-title {
    font-size: 20px;
    font-weight: bold;
    margin-bottom: 15px;
    color: var(--text-primary);
}

/* Buttons */
.btn {
    padding: 12px 24px;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s;
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.btn-primary {
    background-color: var(--secondary-color);
    color: white;
}

.btn-primary:hover {
    background-color: var(--secondary-hover);
}

.btn-success {
    background-color: var(--success-color);
    color: white;
}

.btn-success:hover {
    background-color: #45a049;
}

.btn-danger {
    background-color: var(--danger-color);
    color: white;
}

.btn-danger:hover {
    background-color: #da190b;
}

.btn-warning {
    background-color: var(--warning-color);
    color: white;
}

.btn-warning:hover {
    background-color: #F57C00;
}

/* Forms */
.form-group {
    margin-bottom: 20px;
}

.form-label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
    color: var(--text-primary);
}

.form-control {
    width: 100%;
    padding: 12px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    font-size: 14px;
    transition: border-color 0.3s;
}

.form-control:focus {
    outline: none;
    border-color: var(--secondary-color);
    box-shadow: 0 0 0 3px rgba(33, 150, 243, 0.1);
}

select.form-control {
    cursor: pointer;
}

/* Tables */
.table-container {
    overflow-x: auto;
    margin-top: 20px;
}

table {
    width: 100%;
    border-collapse: collapse;
    background-color: var(--card-bg);
    border-radius: 8px;
    overflow: hidden;
}

thead {
    background-color: var(--primary-color);
    color: white;
}

th, td {
    padding: 12px;
    text-align: right;
    border-bottom: 1px solid var(--border-color);
}

th {
    font-weight: 600;
}

tbody tr:hover {
    background-color: #f5f5f5;
}

/* Stats Cards */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.stat-card {
    background: linear-gradient(135deg, var(--card-bg) 0%, #f8f9fa 100%);
    border-radius: 15px;
    padding: 25px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
    border-right: 4px solid;
}

.stat-card.primary {
    border-right-color: var(--secondary-color);
}

.stat-card.success {
    border-right-color: var(--success-color);
}

.stat-card.danger {
    border-right-color: var(--danger-color);
}

.stat-card.warning {
    border-right-color: var(--warning-color);
}

.stat-label {
    font-size: 14px;
    color: var(--text-secondary);
    margin-bottom: 10px;
}

.stat-value {
    font-size: 28px;
    font-weight: bold;
    color: var(--text-primary);
}

/* Tabs */
.tabs {
    display: flex;
    gap: 8px;
    margin-bottom: 20px;
    flex-wrap: wrap;
    background: #fff;
    padding: 8px;
    border-radius: 12px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.04);
}

.tab-btn {
    padding: 10px 16px;
    background-color: transparent;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 14px;
    color: var(--text-secondary);
    font-weight: 600;
}

.tab-btn:hover {
    background-color: #f1f5f9;
    color: var(--text-primary);
}

.tab-btn.active {
    background-color: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
}

/* Reports page */
.rpt-page {
    display: flex;
    flex-direction: column;
    gap: 18px;
}

.rpt-toolbar {
    background: #fff;
    border-radius: 16px;
    padding: 18px 20px;
    box-shadow: 0 2px 12px rgba(15, 39, 68, 0.06);
    border: 1px solid #e8eef6;
}

.rpt-toolbar h3 {
    margin: 0;
    color: var(--primary-color);
    font-size: 20px;
}

.rpt-toolbar-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
    margin-bottom: 14px;
}

.rpt-quick {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.rpt-chip {
    border: none;
    border-radius: 999px;
    padding: 7px 14px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    background: #eef2ff;
    color: var(--primary-color);
}

.rpt-chip:hover {
    background: #dbe4ff;
}

.rpt-toolbar-body {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    align-items: flex-end;
}

.rpt-field {
    flex: 1;
    min-width: 180px;
}

.rpt-field label {
    display: block;
    margin-bottom: 6px;
    font-size: 13px;
    font-weight: 600;
    color: #475569;
}

.rpt-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.rpt-kpis {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 12px;
}

.rpt-kpi {
    background: #fff;
    border: 1px solid #e8eef6;
    border-radius: 14px;
    padding: 16px 18px;
    box-shadow: 0 2px 10px rgba(15, 39, 68, 0.05);
    border-right: 5px solid var(--primary-color);
}

.rpt-kpi.income { border-right-color: #0f766e; }
.rpt-kpi.expense { border-right-color: #b91c1c; }
.rpt-kpi.collect { border-right-color: #b45309; }
.rpt-kpi.exchange { border-right-color: #0e7490; }
.rpt-kpi.net,
.rpt-kpi.cash { border-right-color: #003040; }
.rpt-kpi.count { border-right-color: #64748b; }

.rpt-kpi-label {
    font-size: 12px;
    color: #64748b;
    font-weight: 700;
    margin-bottom: 8px;
}

.rpt-kpi-lbp {
    font-size: 22px;
    font-weight: 800;
    color: #0f172a;
    line-height: 1.2;
}

.rpt-kpi-lbp span {
    font-size: 13px;
    color: #64748b;
    font-weight: 600;
}

.rpt-kpi-usd {
    margin-top: 4px;
    color: #64748b;
    font-size: 13px;
    font-weight: 600;
}

.rpt-kpi.income .rpt-kpi-lbp { color: #0f766e; }
.rpt-kpi.expense .rpt-kpi-lbp { color: #b91c1c; }
.rpt-kpi.collect .rpt-kpi-lbp { color: #b45309; }
.rpt-kpi.exchange .rpt-kpi-lbp { color: #0e7490; }
.rpt-kpi.net .rpt-kpi-lbp,
.rpt-kpi.cash .rpt-kpi-lbp { color: #003040; }

.rpt-banner {
    background: linear-gradient(135deg, #003040 0%, #007090 62%, #80c0e0 100%);
    color: #fff;
    border-radius: 16px;
    padding: 20px 24px;
}

.rpt-banner .kicker {
    opacity: 0.8;
    font-size: 12px;
    font-weight: 700;
    margin-bottom: 4px;
}

.rpt-banner h4 {
    margin: 0;
    font-size: 22px;
}

#reportContent,
#statisticsContent {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.rpt-table-card {
    background: #fff;
    border: 1px solid #e8eef6;
    border-radius: 16px;
    overflow: hidden;
    box-shadow: 0 2px 10px rgba(15, 39, 68, 0.05);
}

.rpt-table-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 14px 18px;
    background: #003040;
    color: #fff;
}

.rpt-table-head.income { background: #0f766e; }
.rpt-table-head.expense { background: #b91c1c; }
.rpt-table-head.collect { background: #b45309; }
.rpt-table-head.exchange { background: #0e7490; }

.rpt-table-head h4 {
    margin: 0;
    font-size: 16px;
}

.rpt-badge {
    background: rgba(255, 255, 255, 0.18);
    border-radius: 999px;
    padding: 3px 10px;
    font-size: 12px;
    font-weight: 700;
}

.rpt-table-wrap {
    overflow-x: auto;
}

.rpt-table {
    width: 100%;
    border-collapse: collapse;
}

.rpt-table th,
.rpt-table td {
    padding: 12px 14px;
    text-align: right;
    border-bottom: 1px solid #eef2f7;
    font-size: 13px;
}

.rpt-table thead th {
    background: #f8fafc;
    color: #475569;
    font-size: 12px;
    font-weight: 700;
    white-space: nowrap;
}

.rpt-table tbody tr:nth-child(even) {
    background: #fbfdff;
}

.rpt-table tbody tr:hover {
    background: #f1f5f9;
}

.rpt-table .amt {
    text-align: left;
    font-variant-numeric: tabular-nums;
    font-weight: 700;
    white-space: nowrap;
}

.rpt-table .amt.income { color: #0f766e; }
.rpt-table .amt.expense { color: #b91c1c; }
.rpt-table .amt.collect { color: #b45309; }
.rpt-table .amt.exchange { color: #0e7490; }

.rpt-table tfoot td {
    background: #f1f5f9;
    font-weight: 800;
    border-top: 2px solid #dbe3ef;
}

.rpt-pill {
    display: inline-block;
    padding: 3px 8px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 700;
    background: #e7f4f8;
    color: #003040;
}

.rpt-muted {
    color: #64748b;
    font-size: 12px;
}

.rpt-empty {
    text-align: center;
    padding: 28px;
    color: #64748b;
}

.rpt-alert {
    background: #fffbeb;
    border: 1px solid #fde68a;
    color: #92400e;
    border-radius: 12px;
    padding: 16px 18px;
}

.rpt-alert h4 {
    margin: 0 0 8px;
}

.rpt-alert ul {
    margin: 8px 18px 0;
}

.rpt-split {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

@media (max-width: 900px) {
    .rpt-split {
        grid-template-columns: 1fr;
    }
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 1000;
    align-items: center;
    justify-content: center;
}

.modal.active {
    display: flex;
}

.modal-content {
    background-color: var(--card-bg);
    border-radius: 15px;
    padding: 30px;
    max-width: 600px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.modal-title {
    font-size: 24px;
    font-weight: bold;
    color: var(--text-primary);
}

.modal-close {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: var(--text-secondary);
}

.modal-close:hover {
    color: var(--text-primary);
}

/* Invoice Card */
.invoice-card {
    background-color: var(--card-bg);
    border-radius: 12px;
    padding: 20px;
    margin-bottom: 15px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    border-right: 4px solid var(--secondary-color);
}

.invoice-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    padding-bottom: 15px;
    border-bottom: 1px solid var(--border-color);
}

.invoice-number {
    font-size: 18px;
    font-weight: bold;
    color: var(--text-primary);
}

.invoice-status {
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
}

.invoice-status.pending {
    background-color: #fff3cd;
    color: #856404;
}

.invoice-status.paid {
    background-color: #d4edda;
    color: #155724;
}

.invoice-details {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 15px;
    margin-bottom: 15px;
}

.invoice-detail-item {
    display: flex;
    flex-direction: column;
}

.invoice-detail-label {
    font-size: 12px;
    color: var(--text-secondary);
    margin-bottom: 5px;
}

.invoice-detail-value {
    font-size: 14px;
    font-weight: 500;
    color: var(--text-primary);
}

.invoice-actions {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
}

/* Loading */
.loading {
    text-align: center;
    padding: 40px;
    color: var(--text-secondary);
}

/* Empty State */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-secondary);
}

.empty-state-icon {
    font-size: 64px;
    margin-bottom: 20px;
    opacity: 0.5;
}

.empty-state-text {
    font-size: 18px;
}

/* Responsive */
@media (max-width: 768px) {
    .sidebar {
        width: 200px;
    }
    
    .stats-grid {
        grid-template-columns: 1fr;
    }
    
    .tabs {
        flex-direction: column;
    }
    
    .tab-btn {
        width: 100%;
    }
}

/* RTL Support */
[dir="rtl"] {
    direction: rtl;
}

[dir="ltr"] {
    direction: ltr;
}

/* Scrollbar */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: #f1f1f1;
}

::-webkit-scrollbar-thumb {
    background: #888;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: #555;
}

.lab-file-tools {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    align-items: center;
    margin-top: 16px;
}

.lab-file-tools input[type="search"] {
    flex: 1;
    min-width: 220px;
}

.lab-file-pending-only {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: #fff;
    border: 1px solid #d7e6ee;
    border-radius: 10px;
    padding: 8px 12px;
    font-size: 13px;
    font-weight: 600;
    color: var(--primary-color);
    cursor: pointer;
}

.lab-file-browser {
    display: grid;
    grid-template-columns: minmax(250px, 320px) minmax(0, 1fr);
    gap: 16px;
    margin-top: 12px;
    align-items: start;
}

.lab-file-visits {
    background: #fff;
    border: 1px solid #d7e6ee;
    border-radius: 12px;
    max-height: calc(100vh - 250px);
    overflow: auto;
    position: sticky;
    top: 8px;
}

.lab-file-visits-head {
    position: sticky;
    top: 0;
    z-index: 1;
    background: #e7f4f8;
    color: var(--primary-color);
    font-weight: 700;
    padding: 10px 14px;
    border-bottom: 1px solid #d7e6ee;
}

.lab-file-visit {
    display: block;
    width: 100%;
    text-align: right;
    background: #fff;
    border: 0;
    border-bottom: 1px solid #e7f2f6;
    padding: 12px 14px;
    cursor: pointer;
    font-family: inherit;
    color: var(--primary-color);
}

.lab-file-visit:hover {
    background: #f3fafc;
}

.lab-file-visit.active {
    background: var(--primary-color);
    color: #fff;
}

.lab-file-visit .sub {
    display: block;
    margin-top: 4px;
    font-size: 12px;
    opacity: 0.85;
}

.lab-file-visit .pending-pill {
    display: inline-block;
    margin-top: 6px;
    background: #fff4e5;
    color: #8a5a00;
    border-radius: 999px;
    padding: 2px 8px;
    font-size: 12px;
    font-weight: 700;
}

.lab-file-visit.active .pending-pill {
    background: rgba(255, 255, 255, 0.18);
    color: #fff;
}

.lab-file-empty {
    padding: 16px 14px;
    color: #5d7084;
    font-size: 13px;
}

@media (max-width: 800px) {
    .lab-file-browser {
        grid-template-columns: 1fr;
    }

    .lab-file-visits {
        position: static;
        max-height: 240px;
    }
}

/* Force 24-hour format for time inputs - hide AM/PM */
input[type="time"] {
    font-variant-numeric: tabular-nums;
}

input[type="time"]::-webkit-calendar-picker-indicator {
    filter: invert(0);
}

/* Hide AM/PM if browser shows it */
input[type="time"]::-webkit-datetime-edit-ampm-field {
    display: none;
}

