/* ============================================================
   Doctor Mobile - VIVID GRADIENT UI
   Bold gradients, vibrant colors, energetic, modern
   ============================================================ */

:root {
    /* === GRADIENTS === */
    --grad-main: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    --grad-warm: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
    --grad-ocean: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);
    --grad-sunset: linear-gradient(135deg, #fa709a 0%, #fee140 100%);
    --grad-forest: linear-gradient(135deg, #43e97b 0%, #38f9d7 100%);
    --grad-fire: linear-gradient(135deg, #f5af19 0%, #f12711 100%);

    /* === SOLID COLORS === */
    --purple: #764ba2;
    --blue: #4facfe;
    --pink: #f093fb;
    --coral: #f5576c;
    --teal: #38f9d7;
    --green: #43e97b;
    --orange: #f5af19;
    --red: #f12711;

    /* === SURFACES === */
    --bg: #F0F2F5;
    --surface: #FFFFFF;
    --surface-raised: #FFFFFF;
    --border: rgba(0,0,0,0.06);
    --border-strong: rgba(0,0,0,0.1);

    /* === TEXT === */
    --text: #1A1D21;
    --text-2: #5F6368;
    --text-3: #9AA0A6;
    --white: #FFFFFF;

    /* === SPACING === */
    --s-1: 4px;
    --s-2: 8px;
    --s-3: 12px;
    --s-4: 16px;
    --s-5: 20px;
    --s-6: 24px;
    --s-8: 32px;
    --s-10: 40px;

    /* === RADII === */
    --r-sm: 8px;
    --r-md: 12px;
    --r-lg: 16px;
    --r-xl: 20px;
    --r-full: 9999px;

    /* === SHADOWS === */
    --sh-xs: 0 1px 3px rgba(0,0,0,0.08);
    --sh-sm: 0 2px 8px rgba(0,0,0,0.08);
    --sh-md: 0 4px 16px rgba(0,0,0,0.1);
    --sh-lg: 0 8px 32px rgba(0,0,0,0.12);
    --sh-glow: 0 4px 20px rgba(102,126,234,0.25);

    /* === MOTION === */
    --ease: cubic-bezier(0.22, 1, 0.36, 1);
    --fast: 120ms;
    --normal: 200ms;

    /* === LAYOUT === */
    --sidebar: 250px;
    --max-w: 1140px;
}

/* === DARK MODE === */
[data-theme="dark"] {
    --bg: #0F0F14;
    --surface: #1A1A24;
    --surface-raised: #22222E;
    --border: rgba(255,255,255,0.06);
    --border-strong: rgba(255,255,255,0.1);
    --text: #E8E8ED;
    --text-2: #9898A8;
    --text-3: #5C5C70;
    --sh-xs: 0 1px 3px rgba(0,0,0,0.3);
    --sh-sm: 0 2px 8px rgba(0,0,0,0.4);
    --sh-md: 0 4px 16px rgba(0,0,0,0.5);
    --sh-lg: 0 8px 32px rgba(0,0,0,0.6);
    --sh-glow: 0 4px 20px rgba(102,126,234,0.35);
}

[data-theme="dark"] .sidebar {
    background: var(--surface);
    box-shadow: -2px 0 12px rgba(0,0,0,0.3);
}

[data-theme="dark"] .sidebar-link:hover {
    background: var(--surface-raised);
}

[data-theme="dark"] .sidebar-user {
    background: var(--surface-raised);
}

[data-theme="dark"] tr:hover {
    background: rgba(102,126,234,0.06);
}

[data-theme="dark"] .search-bar {
    background: var(--surface);
}

[data-theme="dark"] .login-wrapper {
    background: linear-gradient(135deg, #1a1040 0%, #0d1a2a 100%);
}

[data-theme="dark"] .login-card {
    background: var(--surface);
}

[data-theme="dark"] .login-logo {
    background: var(--grad-main);
    color: var(--white);
}

/* Theme toggle button */
.theme-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: var(--r-sm);
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text-2);
    cursor: pointer;
    transition: all var(--fast);
    flex-shrink: 0;
}

.theme-toggle:hover {
    background: var(--surface-raised);
    color: var(--text);
    border-color: var(--border-strong);
}

.theme-toggle svg {
    width: 18px;
    height: 18px;
}

.theme-toggle .icon-sun { display: none; }
[data-theme="dark"] .theme-toggle .icon-moon { display: none; }
[data-theme="dark"] .theme-toggle .icon-sun { display: block; }

*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }
html { -webkit-font-smoothing: antialiased; }

body {
    font-family: "Vazirmatn", system-ui, sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100dvh;
    direction: rtl;
    line-height: 1.6;
    display: flex;
    overflow-x: hidden;
}

/* Scrollbar */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #D0D0D0; border-radius: 3px; }
* { scrollbar-width: thin; scrollbar-color: #D0D0D0 transparent; }

/* ============================================================
   SIDEBAR - Gradient accent, clean white
   ============================================================ */
.sidebar {
    width: var(--sidebar);
    height: 100dvh;
    background: var(--surface);
    border-left: 1px solid var(--border);
    position: fixed;
    right: 0;
    top: 0;
    display: flex;
    flex-direction: column;
    z-index: 100;
    box-shadow: -2px 0 12px rgba(0,0,0,0.04);
}

.sidebar-top {
    padding: var(--s-5) var(--s-4);
    border-bottom: 1px solid var(--border);
}

.sidebar-logo {
    display: flex;
    align-items: center;
    gap: var(--s-3);
    text-decoration: none;
}

.logo-icon {
    width: 40px;
    height: 40px;
    background: var(--grad-main);
    border-radius: var(--r-md);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--white);
    flex-shrink: 0;
    box-shadow: var(--sh-glow);
    transition: transform var(--normal) var(--ease);
}

.sidebar-logo:hover .logo-icon { transform: scale(1.08) rotate(-3deg); }

.logo-text {
    color: var(--text);
    font-weight: 700;
    font-size: 16px;
}

.sidebar-nav {
    flex: 1;
    padding: var(--s-3);
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.sidebar-link {
    display: flex;
    align-items: center;
    gap: var(--s-3);
    padding: 10px var(--s-4);
    border-radius: var(--r-sm);
    text-decoration: none;
    color: var(--text-2);
    font-size: 14px;
    font-weight: 500;
    transition: all var(--fast);
}

.sidebar-link:hover {
    color: var(--text);
    background: var(--bg);
}

.sidebar-link.active {
    color: var(--purple);
    background: rgba(118,75,162,0.08);
    font-weight: 600;
}

.sidebar-link.active::before {
    content: "";
    position: absolute;
    right: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 3px;
    height: 20px;
    background: var(--grad-main);
    border-radius: 0 3px 3px 0;
}

.sidebar-link svg { flex-shrink: 0; opacity: 0.5; }
.sidebar-link.active svg, .sidebar-link:hover svg { opacity: 1; }

.sidebar-bottom {
    padding: var(--s-3);
    border-top: 1px solid var(--border);
}

.sidebar-user {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px;
    background: var(--bg);
    border-radius: var(--r-sm);
    margin-bottom: var(--s-2);
}

.user-avatar {
    width: 34px;
    height: 34px;
    background: var(--grad-warm);
    border-radius: var(--r-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--white);
    flex-shrink: 0;
}

.user-info { display: flex; flex-direction: column; min-width: 0; }
.user-name { font-size: 13px; font-weight: 600; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-role { font-size: 11px; color: var(--text-3); }

.sidebar-logout {
    display: flex;
    align-items: center;
    gap: var(--s-3);
    padding: 10px var(--s-4);
    border-radius: var(--r-sm);
    text-decoration: none;
    color: var(--text-3);
    font-size: 13px;
    transition: all var(--fast);
}
.sidebar-logout:hover { color: var(--coral); background: rgba(245,87,108,0.06); }

/* ============================================================
   MAIN
   ============================================================ */
.main-content {
    margin-right: var(--sidebar);
    flex: 1;
    min-height: 100dvh;
    padding: var(--s-8) 0 var(--s-10);
}

.container {
    max-width: var(--max-w);
    margin: 0 auto;
    padding: 0 var(--s-8);
}

/* ============================================================
   PAGE HEADER
   ============================================================ */
.page-header { margin-bottom: var(--s-6); }

.page-title {
    font-size: 28px;
    font-weight: 800;
    color: var(--text);
    letter-spacing: -0.3px;
}

.page-subtitle {
    color: var(--text-3);
    font-size: 14px;
    margin-top: 4px;
}

/* ============================================================
   CARD - Clean white with subtle shadow
   ============================================================ */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    overflow: hidden;
    box-shadow: var(--sh-xs);
    transition: box-shadow var(--normal), transform var(--normal);
}

.card:hover {
    box-shadow: var(--sh-sm);
}

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

.card-title {
    font-size: 15px;
    font-weight: 600;
    color: var(--text);
}

.card-body { padding: var(--s-5); }

/* ============================================================
   STAT CARDS - Gradient backgrounds!
   ============================================================ */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: var(--s-4);
    margin-bottom: var(--s-6);
}

.stat-card {
    border-radius: var(--r-lg);
    padding: var(--s-5);
    position: relative;
    overflow: hidden;
    color: var(--white);
    transition: transform var(--normal) var(--ease), box-shadow var(--normal);
    box-shadow: var(--sh-sm);
}

.stat-card::before {
    content: "";
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, rgba(255,255,255,0.15) 0%, transparent 50%);
    pointer-events: none;
}

.stat-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--sh-lg);
}

.stat-card:nth-child(1) { background: var(--grad-main); }
.stat-card:nth-child(2) { background: var(--grad-sunset); }
.stat-card:nth-child(3) { background: var(--grad-ocean); }
.stat-card:nth-child(4) { background: var(--grad-forest); }

.stat-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: var(--s-4);
    position: relative;
    z-index: 1;
}

.stat-icon {
    width: 42px;
    height: 42px;
    border-radius: var(--r-md);
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255,255,255,0.2);
    backdrop-filter: blur(8px);
    transition: transform var(--normal) var(--ease);
}

.stat-card:hover .stat-icon { transform: scale(1.1); }

.stat-badge {
    font-size: 11px;
    font-weight: 700;
    padding: 4px 10px;
    border-radius: var(--r-full);
    background: rgba(255,255,255,0.2);
    backdrop-filter: blur(8px);
    position: relative;
    z-index: 1;
}

.stat-value {
    font-size: 32px;
    font-weight: 900;
    letter-spacing: -1px;
    line-height: 1;
    margin-bottom: 4px;
    position: relative;
    z-index: 1;
}

.stat-label {
    font-size: 13px;
    font-weight: 500;
    opacity: 0.85;
    position: relative;
    z-index: 1;
}

/* ============================================================
   BUTTONS
   ============================================================ */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px var(--s-5);
    border-radius: var(--r-sm);
    font-family: inherit;
    font-size: 14px;
    font-weight: 600;
    text-decoration: none;
    border: none;
    cursor: pointer;
    transition: all var(--fast);
    white-space: nowrap;
}

.btn:focus-visible { outline: 2px solid var(--purple); outline-offset: 2px; }
.btn:active { transform: scale(0.97); }

.btn-primary {
    background: var(--grad-main);
    color: var(--white);
    font-weight: 700;
    box-shadow: var(--sh-glow);
}

.btn-primary:hover {
    box-shadow: 0 6px 24px rgba(102,126,234,0.35);
    transform: translateY(-1px);
}

.btn-secondary {
    background: var(--surface);
    color: var(--text);
    border: 1px solid var(--border-strong);
}

.btn-secondary:hover {
    border-color: var(--purple);
    color: var(--purple);
}

/* ============================================================
   ACTIONS GRID
   ============================================================ */
.actions-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: var(--s-3);
    margin-bottom: var(--s-6);
}

/* ============================================================
   TABLE
   ============================================================ */
.table-wrapper { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }

th {
    text-align: right;
    padding: var(--s-3) var(--s-4);
    font-size: 12px;
    font-weight: 600;
    color: var(--text-3);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 2px solid var(--border);
    background: var(--bg);
}

td {
    padding: var(--s-4);
    font-size: 14px;
    border-bottom: 1px solid var(--border);
}

tr { cursor: pointer; transition: background var(--fast); }
tr:hover { background: rgba(102,126,234,0.03); }

/* ============================================================
   BADGES - Gradient backgrounds
   ============================================================ */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 4px 12px;
    border-radius: var(--r-full);
    font-size: 12px;
    font-weight: 600;
    white-space: nowrap;
}

.badge-received { background: rgba(79,172,254,0.12); color: #2196F3; }
.badge-diagnosed { background: rgba(245,175,25,0.12); color: #E69500; }
.badge-in_repair { background: rgba(255,138,101,0.12); color: #E65100; }
.badge-ready { background: rgba(67,233,123,0.12); color: #16A34A; }
.badge-delivered { background: rgba(154,160,166,0.12); color: #6B7280; }
.badge-cancelled { background: rgba(245,87,108,0.12); color: #DC2626; }

/* ============================================================
   FORMS
   ============================================================ */
.form-group { margin-bottom: var(--s-4); }

.form-label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-2);
    margin-bottom: 6px;
}

.form-input {
    width: 100%;
    padding: 10px var(--s-4);
    background: var(--surface);
    border: 1px solid var(--border-strong);
    border-radius: var(--r-sm);
    color: var(--text);
    font-family: inherit;
    font-size: 14px;
    transition: all var(--fast);
    outline: none;
}

.form-input::placeholder { color: var(--text-3); }

.form-input:focus {
    border-color: var(--purple);
    box-shadow: 0 0 0 3px rgba(118,75,162,0.1);
}

select.form-input {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='10' fill='%239AA0A6' viewBox='0 0 16 16'%3E%3Cpath d='M8 11L3 6h10l-5 5z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: left 14px center;
    padding-left: 34px;
}

textarea.form-input { min-height: 80px; resize: vertical; line-height: 1.6; }
.form-row { display: grid; grid-template-columns: repeat(2, 1fr); gap: var(--s-4); }

/* ============================================================
   SEARCH BAR
   ============================================================ */
.search-bar {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    padding: var(--s-3) var(--s-4);
    margin-bottom: var(--s-5);
    display: flex;
    gap: var(--s-3);
    align-items: center;
    box-shadow: var(--sh-xs);
}

.search-bar .form-input { border: none; background: transparent; padding: 0; flex: 1; }
.search-bar .form-input:focus { box-shadow: none; }

/* ============================================================
   TABS
   ============================================================ */
.filter-tabs, .period-tabs {
    display: flex;
    gap: 6px;
    margin-bottom: var(--s-5);
    flex-wrap: wrap;
}

.filter-tab, .period-tab {
    font-size: 13px;
    padding: 8px 16px;
    border-radius: var(--r-full);
    font-weight: 600;
    text-decoration: none;
    transition: all var(--fast);
}

.filter-tab.active, .period-tab.active {
    background: var(--grad-main);
    color: var(--white);
    box-shadow: var(--sh-glow);
}

.filter-tab:not(.active), .period-tab:not(.active) {
    background: var(--surface);
    color: var(--text-2);
    border: 1px solid var(--border);
}

.filter-tab:not(.active):hover, .period-tab:not(.active):hover {
    border-color: var(--purple);
    color: var(--purple);
}

/* ============================================================
   DETAIL GRID
   ============================================================ */
.detail-grid { display: grid; grid-template-columns: 2fr 1fr; gap: var(--s-5); }
.detail-stack { display: flex; flex-direction: column; gap: var(--s-5); }

.detail-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 0;
    border-bottom: 1px solid var(--border);
    font-size: 13px;
}
.detail-row:last-child { border-bottom: none; }
.detail-label { color: var(--text-3); }

/* ============================================================
   TWO COLUMN
   ============================================================ */
.two-col-grid { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s-5); margin-bottom: var(--s-5); }

/* ============================================================
   REPORT LIST
   ============================================================ */
.report-list-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 0;
    border-bottom: 1px solid var(--border);
}
.report-list-item:last-child { border-bottom: none; }
.report-list-value { font-family: monospace; color: var(--text-2); font-size: 14px; }

/* ============================================================
   LOGIN
   ============================================================ */
.login-wrapper {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100dvh;
    padding: var(--s-6);
    width: 100%;
    background: var(--grad-main);
    position: relative;
}

.login-wrapper::before {
    content: "";
    position: absolute;
    inset: 0;
    background: url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Cg fill='%23ffffff' fill-opacity='0.05'%3E%3Cpath d='M36 34v-4h-2v4h-4v2h4v4h2v-4h4v-2h-4zm0-30V0h-2v4h-4v2h4v4h2V6h4V4h-4zM6 34v-4H4v4H0v2h4v4h2v-4h4v-2H6zM6 4V0H4v4H0v2h4v4h2V6h4V4H6z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E");
}

.login-box { width: 100%; max-width: 400px; position: relative; z-index: 1; }
.login-header { text-align: center; margin-bottom: var(--s-6); }

.login-logo {
    width: 72px;
    height: 72px;
    background: var(--white);
    border-radius: var(--r-xl);
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto var(--s-5);
    color: var(--purple);
    box-shadow: 0 8px 32px rgba(0,0,0,0.2);
    transition: transform var(--normal) var(--ease);
}

.login-logo:hover { transform: scale(1.05) rotate(-3deg); }

.login-title {
    font-size: 28px;
    font-weight: 800;
    color: var(--white);
}

.login-subtitle { color: rgba(255,255,255,0.7); font-size: 14px; margin-top: 4px; }

.login-card {
    background: var(--surface);
    border-radius: var(--r-xl);
    padding: var(--s-8);
    box-shadow: 0 16px 48px rgba(0,0,0,0.2);
}

.login-card .form-input { padding: 14px var(--s-4); font-size: 15px; }
.login-card .btn-primary { width: 100%; padding: 14px; font-size: 15px; margin-top: var(--s-2); }

.error-alert {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: var(--s-3) var(--s-4);
    background: rgba(245,87,108,0.08);
    border: 1px solid rgba(245,87,108,0.2);
    border-radius: var(--r-sm);
    color: var(--coral);
    font-size: 14px;
    margin-bottom: var(--s-5);
}

/* ============================================================
   EMPTY STATE
   ============================================================ */
.empty-state { padding: var(--s-10); text-align: center; color: var(--text-3); }
.empty-state svg { margin: 0 auto var(--s-3); opacity: 0.2; }

/* ============================================================
   MODAL
   ============================================================ */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 999;
}

.modal-content {
    background: var(--surface);
    border-radius: var(--r-xl);
    width: 100%;
    max-width: 440px;
    box-shadow: var(--sh-lg);
}

/* ============================================================
   ANIMATIONS
   ============================================================ */
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes slideUp { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: translateY(0); } }

main > .container > * { animation: slideUp 0.3s var(--ease) both; }
.stats-grid .stat-card:nth-child(1) { animation-delay: 30ms; }
.stats-grid .stat-card:nth-child(2) { animation-delay: 60ms; }
.stats-grid .stat-card:nth-child(3) { animation-delay: 90ms; }
.stats-grid .stat-card:nth-child(4) { animation-delay: 120ms; }

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        transition-duration: 0.01ms !important;
    }
}

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 1024px) {
    .stats-grid { grid-template-columns: repeat(2, 1fr); }
    .detail-grid { grid-template-columns: 1fr; }
    .two-col-grid { grid-template-columns: 1fr; }
}

@media (max-width: 768px) {
    :root { --sidebar: 60px; }
    .sidebar-link span, .logo-text, .user-info, .sidebar-logout span { display: none; }
    .sidebar-link { justify-content: center; padding: 10px; }
    .sidebar-logo { justify-content: center; }
    .sidebar-user { justify-content: center; padding: var(--s-2); }
    .sidebar-logout { justify-content: center; }
    .main-content { margin-right: 60px; }
    .container { padding: 0 var(--s-4); }
    .stats-grid { grid-template-columns: repeat(2, 1fr); }
    .actions-grid { grid-template-columns: 1fr; }
    .form-row { grid-template-columns: 1fr; }
    .stat-value { font-size: 24px; }
    .page-title { font-size: 22px; }
}

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

/* ============================================================
   ACCESSIBILITY
   ============================================================ */
:focus-visible { outline: 2px solid var(--purple); outline-offset: 2px; }
:focus:not(:focus-visible) { outline: none; }
