@import url('https://fonts.googleapis.com/css2?family=Cairo:wght@300;400;500;600;700;800&display=swap');

:root {
    --primary: #0d9488;
    --primary-hover: #0f766e;
    --primary-light: #ccfbf1;
    --secondary: #0284c7;
    --success: #10b981;
    --danger: #ef4444;
    --warning: #f59e0b;
    --info: #3b82f6;
    --dark: #0f172a;
    --dark-light: #1e293b;
    --light: #f8fafc;
    --white: #ffffff;
    --text-main: #1e293b;
    --text-muted: #64748b;
    --border-color: #e2e8f0;
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 18px;
    --shadow-sm: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px -1px rgba(0, 0, 0, 0.1);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -2px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -4px rgba(0, 0, 0, 0.1);
    --shadow-glass: 0 8px 32px 0 rgba(13, 148, 136, 0.08);
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

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

body {
    font-family: 'Cairo', sans-serif;
    background-color: var(--light);
    color: var(--text-main);
    min-height: 100vh;
    overflow-x: hidden;
}

a {
    text-decoration: none;
    color: inherit;
    transition: var(--transition);
}

/* Scrollbar styling */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}
::-webkit-scrollbar-track {
    background: var(--light);
}
::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}

/* App Wrapper Layout */
.app-wrapper {
    display: flex;
    min-height: 100vh;
}

/* ==================== RTL STYLING (DEFAULT) ==================== */
html[dir="rtl"] body {
    direction: rtl;
    text-align: right;
}

html[dir="rtl"] .sidebar {
    right: 0;
    left: auto;
    border-left: 1px solid var(--dark-light);
}

html[dir="rtl"] .main-content {
    margin-right: 270px;
    margin-left: 0;
}

html[dir="rtl"] .timeline::after {
    right: 20px;
    left: auto;
}

html[dir="rtl"] .timeline-item {
    padding: 10px 40px 10px 0;
}

html[dir="rtl"] .timeline-icon {
    right: 0;
    left: auto;
}

html[dir="rtl"] .analytics-card::before {
    right: 0;
    left: auto;
}

html[dir="rtl"] .custom-table th, 
html[dir="rtl"] .custom-table td {
    text-align: right;
}

/* ==================== LTR STYLING (ENGLISH) ==================== */
html[dir="ltr"] body {
    direction: ltr;
    text-align: left;
}

html[dir="ltr"] .sidebar {
    left: 0;
    right: auto;
    border-right: 1px solid var(--dark-light);
    border-left: none;
}

html[dir="ltr"] .main-content {
    margin-left: 270px;
    margin-right: 0;
}

html[dir="ltr"] .timeline::after {
    left: 20px;
    right: auto;
}

html[dir="ltr"] .timeline-item {
    padding: 10px 0 10px 40px;
}

html[dir="ltr"] .timeline-icon {
    left: 0;
    right: auto;
}

html[dir="ltr"] .analytics-card::before {
    left: 0;
    right: auto;
}

html[dir="ltr"] .custom-table th, 
html[dir="ltr"] .custom-table td {
    text-align: left;
}

/* Sidebar General Styling */
.sidebar {
    width: 270px;
    height: 100vh;
    background-color: var(--dark);
    color: var(--white);
    position: fixed;
    top: 0;
    display: flex;
    flex-direction: column;
    z-index: 1000;
    transition: var(--transition);
    box-shadow: var(--shadow-lg);
}

.sidebar-brand {
    padding: 24px 20px;
    display: flex;
    align-items: center;
    gap: 12px;
    border-bottom: 1px solid var(--dark-light);
}

.sidebar-brand i {
    font-size: 26px;
    color: var(--primary);
}

.sidebar-brand h3 {
    font-size: 18px;
    font-weight: 700;
    color: var(--white);
}

.sidebar-menu {
    flex: 1;
    padding: 20px 14px;
    list-style: none;
    overflow-y: auto;
}

.sidebar-menu-item {
    margin-bottom: 8px;
}

.sidebar-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    color: #94a3b8;
    border-radius: var(--radius-sm);
    font-weight: 500;
    font-size: 14px;
}

.sidebar-link i {
    font-size: 18px;
    width: 24px;
    text-align: center;
}

.sidebar-link:hover, 
.sidebar-menu-item.active .sidebar-link {
    color: var(--white);
    background-color: var(--primary);
}

/* Main Content Wrapper */
.main-content {
    flex: 1;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    transition: var(--transition);
}

/* Top Navbar */
.top-navbar {
    height: 70px;
    background-color: var(--white);
    border-bottom: 1px solid var(--border-color);
    padding: 0 30px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 900;
    box-shadow: var(--shadow-sm);
}

.navbar-right {
    display: flex;
    align-items: center;
    gap: 20px;
}

.menu-toggle {
    display: none;
    font-size: 20px;
    cursor: pointer;
    background: none;
    border: none;
    color: var(--text-main);
}

.navbar-left {
    display: flex;
    align-items: center;
    gap: 20px;
}

/* Dropdown styling */
.dropdown {
    position: relative;
    display: inline-block;
}

.dropdown-toggle {
    background: none;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px;
    border-radius: var(--radius-sm);
    font-family: inherit;
    color: var(--text-main);
}

.dropdown-toggle:hover {
    background-color: #f1f5f9;
}

.dropdown-menu {
    position: absolute;
    top: 100%;
    margin-top: 8px;
    background-color: var(--white);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-lg);
    min-width: 220px;
    display: none;
    flex-direction: column;
    z-index: 999;
}

html[dir="rtl"] .dropdown-menu {
    left: 0;
    right: auto;
}

html[dir="ltr"] .dropdown-menu {
    right: 0;
    left: auto;
}

.dropdown-menu.show {
    display: flex;
}

.dropdown-item {
    padding: 12px 16px;
    font-size: 13px;
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--text-main);
    cursor: pointer;
    border-bottom: 1px solid #f1f5f9;
}

.dropdown-item:last-child {
    border-bottom: none;
}

.dropdown-item:hover {
    background-color: #f8fafc;
    color: var(--primary);
}

/* Notifications Button & Badge */
.notification-btn {
    position: relative;
    font-size: 20px;
    color: var(--text-muted);
}

.notification-badge {
    position: absolute;
    top: -2px;
    right: -2px;
    background-color: var(--danger);
    color: var(--white);
    font-size: 9px;
    font-weight: 700;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Page Contents Container */
.page-container {
    padding: 30px;
    flex: 1;
}

.page-header {
    margin-bottom: 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 16px;
}

.page-title h1 {
    font-size: 24px;
    font-weight: 700;
    color: var(--dark);
}

.page-title p {
    font-size: 13px;
    color: var(--text-muted);
    margin-top: 4px;
}

/* Dashboard Analytics Grid */
.analytics-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.analytics-card {
    background-color: var(--white);
    border-radius: var(--radius-md);
    padding: 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-color);
    position: relative;
    overflow: hidden;
}

.analytics-card::before {
    content: '';
    position: absolute;
    width: 4px;
    height: 40px;
    background-color: var(--primary);
    border-radius: 4px 0 0 4px;
}

.analytics-card-info h4 {
    font-size: 13px;
    color: var(--text-muted);
    font-weight: 500;
}

.analytics-card-info h2 {
    font-size: 28px;
    font-weight: 700;
    color: var(--dark);
    margin-top: 4px;
}

.analytics-card-icon {
    width: 54px;
    height: 54px;
    border-radius: var(--radius-sm);
    background-color: var(--primary-light);
    color: var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
}

.analytics-card.blue::before { background-color: var(--info); }
.analytics-card.blue .analytics-card-icon { background-color: #dbeafe; color: var(--info); }

.analytics-card.green::before { background-color: var(--success); }
.analytics-card.green .analytics-card-icon { background-color: #d1fae5; color: var(--success); }

.analytics-card.orange::before { background-color: var(--warning); }
.analytics-card.orange .analytics-card-icon { background-color: #fef3c7; color: var(--warning); }

/* Dashboard Content Grid */
.dashboard-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 24px;
}

@media (max-width: 1200px) {
    .dashboard-grid {
        grid-template-columns: 1fr;
    }
}

/* Card Component */
.card {
    background-color: var(--white);
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-sm);
    margin-bottom: 24px;
    overflow: hidden;
}

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

.card-title {
    font-size: 16px;
    font-weight: 700;
    color: var(--dark);
    display: flex;
    align-items: center;
    gap: 10px;
}

.card-body {
    padding: 24px;
}

/* Tables Styling */
.table-responsive {
    width: 100%;
    overflow-x: auto;
}

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

.custom-table th {
    background-color: #f1f5f9;
    color: var(--text-muted);
    font-weight: 600;
    font-size: 13px;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-color);
}

.custom-table td {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-color);
    font-size: 14px;
    color: var(--text-main);
}

.custom-table tr:hover {
    background-color: #f8fafc;
}

/* Badge component for status */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
}

.badge-pending { background-color: #fef3c7; color: var(--warning); }
.badge-confirmed { background-color: #dbeafe; color: var(--info); }
.badge-checked_in { background-color: #f3e8ff; color: #a855f7; }
.badge-in_consultation { background-color: var(--primary-light); color: var(--primary); }
.badge-completed { background-color: #d1fae5; color: var(--success); }
.badge-no_show { background-color: #f1f5f9; color: var(--text-muted); }
.badge-cancelled { background-color: #fee2e2; color: var(--danger); }
.badge-rescheduled { background-color: #e0e7ff; color: #4f46e5; }

/* Buttons styling */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 20px;
    border-radius: var(--radius-sm);
    font-weight: 600;
    font-size: 14px;
    cursor: pointer;
    border: none;
    transition: var(--transition);
}

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

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

.btn-secondary {
    background-color: #e2e8f0;
    color: var(--text-main);
}

.btn-secondary:hover {
    background-color: #cbd5e1;
}

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

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

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

/* Modals with scrolling visibility fix */
.modal-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background-color: rgba(15, 23, 42, 0.4);
    backdrop-filter: blur(4px);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1100;
    padding: 20px;
}

.modal-content {
    background-color: var(--white);
    border-radius: var(--radius-md);
    width: 100%;
    max-width: 600px;
    max-height: 90vh; /* Heights Scroll Fix */
    overflow-y: auto;  /* Heights Scroll Fix */
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--border-color);
    animation: modalSlide 0.3s ease-out;
}

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

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

.form-label {
    display: block;
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 8px;
    color: var(--text-main);
}

.form-control {
    width: 100%;
    padding: 10px 14px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-color);
    background-color: var(--white);
    font-family: inherit;
    font-size: 14px;
    transition: var(--transition);
}

.form-control:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(13, 148, 136, 0.15);
}

textarea.form-control {
    min-height: 100px;
    resize: vertical;
}

/* Auth Layout */
.auth-wrapper {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #ccfbf1, #e0f2fe, #f8fafc);
    padding: 20px;
}

.auth-card {
    background-color: var(--white);
    border-radius: var(--radius-lg);
    width: 100%;
    max-width: 480px;
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--border-color);
    padding: 40px;
}

.auth-header {
    text-align: center;
    margin-bottom: 30px;
}

.auth-header i {
    font-size: 48px;
    color: var(--primary);
    margin-bottom: 12px;
}

.auth-header h2 {
    font-size: 22px;
    font-weight: 700;
    color: var(--dark);
}

.auth-header p {
    font-size: 13px;
    color: var(--text-muted);
    margin-top: 6px;
}

.turnstile-container {
    display: flex;
    justify-content: center;
    margin: 20px 0;
}

/* Timeline EMR */
.timeline {
    position: relative;
    padding: 20px 0;
}

.timeline::after {
    content: '';
    position: absolute;
    width: 2px;
    background-color: var(--border-color);
    top: 0;
    bottom: 0;
    margin-left: -1px;
}

.timeline-item {
    position: relative;
    background-color: inherit;
    width: 100%;
}

.timeline-icon {
    position: absolute;
    width: 40px;
    height: 40px;
    top: 15px;
    border-radius: 50%;
    background-color: var(--primary-light);
    color: var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1;
    font-size: 16px;
    border: 3px solid var(--white);
}

.timeline-content {
    padding: 20px;
    background-color: #f8fafc;
    position: relative;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
}

.timeline-content h3 {
    font-size: 15px;
    font-weight: 700;
    margin-bottom: 6px;
}

.timeline-content .time {
    font-size: 12px;
    color: var(--text-muted);
    display: block;
    margin-bottom: 10px;
}

/* Dental Kit List items */
.dental-kit-card {
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 16px;
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.dental-kit-badge {
    padding: 4px 8px;
    font-size: 11px;
    font-weight: bold;
    border-radius: 4px;
}

.badge-unsent { background-color: #f1f5f9; color: var(--text-muted); }
.badge-sent { background-color: #e0f2fe; color: var(--secondary); }
.badge-installed { background-color: #d1fae5; color: var(--success); }
.badge-uninstalled { background-color: #fee2e2; color: var(--danger); }

/* Tab control buttons */
.active-tab-btn {
    background-color: var(--primary) !important;
    color: var(--white) !important;
}

/* Responsive Media Queries */
@media (max-width: 992px) {
    .sidebar {
        transform: translateX(100%);
    }
    
    html[dir="ltr"] .sidebar {
        transform: translateX(-100%);
    }

    .sidebar.show {
        transform: translateX(0) !important;
    }
    
    .main-content {
        margin-left: 0 !important;
        margin-right: 0 !important;
    }
    
    .menu-toggle {
        display: block;
    }
}


/* Premium field and upload controls */
.form-control,
select.form-control,
textarea.form-control {
    min-height: 46px;
    border: 1px solid #dbe3ef;
    background: linear-gradient(180deg, #ffffff 0%, #fbfdff 100%);
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
}

.form-control:hover {
    border-color: #b9c7d9;
}

.form-control::placeholder {
    color: #94a3b8;
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 18px;
}

.form-grid .full {
    grid-column: 1 / -1;
}

.upload-field {
    position: relative;
    border: 1.5px dashed #cbd5e1;
    border-radius: var(--radius-md);
    padding: 18px;
    background: #f8fafc;
    transition: var(--transition);
}

.upload-field:hover {
    border-color: var(--primary);
    background: #f0fdfa;
}

.upload-field input[type="file"] {
    position: absolute;
    inset: 0;
    opacity: 0;
    cursor: pointer;
}

.upload-preview {
    display: flex;
    align-items: center;
    gap: 14px;
    color: var(--text-muted);
    font-size: 13px;
}

.upload-preview i {
    width: 42px;
    height: 42px;
    border-radius: 12px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--white);
    color: var(--primary);
    box-shadow: var(--shadow-sm);
}

.record-thumb {
    width: 46px;
    height: 46px;
    border-radius: 12px;
    object-fit: cover;
    border: 1px solid var(--border-color);
}

.kpi-row {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.kpi-box {
    background: var(--white);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 18px;
    box-shadow: var(--shadow-sm);
}

.kpi-box span {
    color: var(--text-muted);
    font-size: 13px;
}

.kpi-box strong {
    display: block;
    margin-top: 8px;
    font-size: 24px;
    color: var(--dark);
}

@media (max-width: 768px) {
    .form-grid,
    .kpi-row {
        grid-template-columns: 1fr;
    }
}


/* Upgrade patch: clearer full-width rows and premium upload controls */
.full-width-row,
.row-12,
.form-grid.form-grid-12,
.form-grid .span-12 {
    grid-column: 1 / -1 !important;
}

.upload-field.enhanced-upload {
    min-height: 86px;
    display: flex;
    align-items: center;
    border-width: 2px;
    background: linear-gradient(180deg, #ffffff 0%, #f8fafc 100%);
}

.upload-field.enhanced-upload .upload-preview {
    width: 100%;
}

.upload-field.enhanced-upload .upload-preview small {
    display: block;
    color: var(--text-muted);
    margin-top: 4px;
}

.modal-actions {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    margin-top: 10px;
}

.table-actions {
    display: inline-flex;
    gap: 8px;
    align-items: center;
}

.patient-link {
    color: var(--primary);
    text-decoration: none;
    font-weight: 800;
}

.patient-link:hover {
    text-decoration: underline;
}

@media print {
    body * { visibility: hidden !important; }
    .print-area, .print-area * { visibility: visible !important; }
    .print-area { position: absolute; inset: 0; padding: 24px; background: #fff; }
    .no-print { display: none !important; }
}


/* Clinicore structural polish */
.filter-bar{display:flex;flex-wrap:wrap;gap:12px;align-items:end;margin-bottom:18px;padding:14px;background:#fff;border:1px solid var(--border-color);border-radius:var(--radius-md);box-shadow:var(--shadow-sm)}
.filter-bar .form-group{margin-bottom:0;min-width:180px;flex:1}.filter-bar .btn{height:42px}.two-table-grid{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:22px}.dashboard-grid{align-items:start}.row-12,.col-12{grid-column:1/-1;width:100%}.patient-link{font-weight:700;color:var(--primary);text-decoration:none}.patient-link:hover{text-decoration:underline}.password-field-wrap{position:relative}.password-toggle{position:absolute;inset-inline-end:12px;top:50%;transform:translateY(-50%);border:0;background:transparent;color:var(--text-muted);cursor:pointer;padding:4px}.upload-box{border:1.5px dashed var(--border-color);border-radius:16px;padding:18px;background:#f8fafc;display:flex;gap:14px;align-items:center}.upload-box i{font-size:26px;color:var(--primary)}.invoice-services{font-size:12px;color:var(--text-muted);line-height:1.8;margin-top:6px}.transfer-mini-form{display:flex;gap:6px;align-items:center;flex-wrap:wrap}.transfer-mini-form select{min-width:150px;height:34px;padding:4px 8px;font-size:12px}.transfer-mini-form button{height:34px;padding:4px 10px}.modal-backdrop{z-index:3000}.modal-content{z-index:3001}
@media (max-width:768px){.clinic-brand-header strong,.desktop-location-text,.text-sm-location{display:none!important}.two-table-grid,.dashboard-grid{grid-template-columns:1fr!important}.filter-bar{display:grid;grid-template-columns:1fr}.top-navbar{min-height:58px}.profile-meta,.profile-arrow{display:none!important}.custom-table th,.custom-table td{white-space:normal}.upload-box{align-items:flex-start}.upload-box .btn{width:100%}}
