@font-face {
    font-family: 'Vazirmatn';
    src: url('../font/Vazirmatn.woff2') format('woff2');
    font-weight: normal;
    font-style: normal;
    font-display: swap;
}

:root {
    --primary-color: #3b82f6;
    --secondary-color: #64748b;
    --success-color: #10b981;
    --warning-color: #f59e0b;
    --danger-color: #ef4444;
    --school-color: #8b5cf6;
    --study-color: #2563eb;
    --rest-color: #059669;
    --reward-color: #d97706;
    --transit-color: #4f46e5;
    --bg-color: #f8fafc;
    --card-bg: #ffffff;
    --text-color: #1e293b;
    --border-radius: 16px;
    --thursday-color: #10b981;
    --friday-color: #f59e0b;
    --nav-bg: rgba(255, 255, 255, 0.9);
    --nav-height: 64px;
    --safe-bottom: env(safe-area-inset-bottom, 0px);
    --border-color: rgba(15, 23, 42, 0.08);
    --shadow-sm: 0 6px 14px rgba(15, 23, 42, 0.06);
    --shadow-md: 0 14px 30px rgba(15, 23, 42, 0.10);
    --focus-ring: 0 0 0 4px rgba(59, 130, 246, 0.18);
}

html.dark,
body.dark {
    --bg-color: #1e293b;
    --card-bg: #334155;
    --text-color: #f1f5f9;
    --secondary-color: #94a3b8;
    --nav-bg: rgba(30, 41, 59, 0.9);
    --border-color: rgba(148, 163, 184, 0.18);
    --shadow-sm: 0 6px 14px rgba(0, 0, 0, 0.25);
    --shadow-md: 0 14px 30px rgba(0, 0, 0, 0.35);
    --focus-ring: 0 0 0 4px rgba(59, 130, 246, 0.22);
}

body.dark .small-card {
    background: #334155;
}

body.dark .progress-section {
    background: #334155;
}

body.dark .day-column {
    background: #334155;
}

body.dark .setting-item {
    background: #334155;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: 'Vazirmatn', 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    -webkit-tap-highlight-color: transparent;
}

html {
    -webkit-text-size-adjust: 100%;
}

body {
    background-color: var(--bg-color);
    color: var(--text-color);
    line-height: 1.6;
    padding-bottom: calc(var(--nav-height) + 26px + var(--safe-bottom));
    transition: background-color 0.3s ease, color 0.3s ease;
    user-select: none !important;
    -webkit-user-select: none !important;
    -moz-user-select: none !important;
    -ms-user-select: none !important;
}

.install-banner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    background: var(--card-bg);
    border-radius: 14px;
    padding: 12px 14px;
    margin-bottom: 14px;
    box-shadow: 0 6px 12px rgba(0, 0, 0, 0.06);
}

.install-banner__text {
    font-weight: 700;
    color: var(--text-color);
    font-size: 0.95rem;
}

.install-banner__btn {
    padding: 10px 16px;
    border-radius: 12px;
    font-size: 0.95rem;
}

.app-container {
    max-width: 500px;
    margin: 0 auto;
    padding: 20px;
}

header {
    margin-bottom: 25px;
    text-align: center;
    animation: fadeInDown 0.5s ease;
    position: relative;
}

.sync-status {
    position: absolute;
    top: 0;
    left: 0;
    font-size: 1.2rem;
    cursor: help;
    transition: all 0.3s ease;
    padding: 5px;
    border-radius: 50%;
}

.sync-status.syncing {
    animation: spin 2s linear infinite;
    opacity: 0.7;
}

.sync-status.synced {
    color: var(--success-color);
    opacity: 1;
}

.sync-status.offline {
    color: var(--danger-color);
    opacity: 1;
}

@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

header h1 {
    font-size: 2rem;
    color: var(--primary-color);
    font-weight: 800;
    letter-spacing: -0.02em;
}

header p {
    color: var(--secondary-color);
    font-size: 0.9rem;
    margin-top: 5px;
}

.card {
    background: var(--card-bg);
    border-radius: var(--border-radius);
    padding: 24px;
    margin-bottom: 20px;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-color);
    transition: transform 0.2s ease, box-shadow 0.2s ease, background 0.3s ease;
}

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

.active-block {
    border: 2px solid var(--primary-color);
    text-align: center !important;
    position: relative;
    overflow: hidden;
    background: linear-gradient(180deg, rgba(59, 130, 246, 0.06), transparent 55%);
    display: flex !important;
    flex-direction: column !important;
    align-items: center !important;
    user-select: none !important;
    -webkit-user-select: none !important;
    -moz-user-select: none !important;
    -ms-user-select: none !important;
}

body.dark .active-block {
    background: linear-gradient(180deg, rgba(59, 130, 246, 0.16), transparent 55%);
}

.active-block::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0; height: 4px;
    background: var(--primary-color);
}

#block-title {
    font-size: 1.8rem !important;
    font-weight: 900 !important;
    margin-bottom: 8px;
    text-align: center !important;
    user-select: none !important;
    -webkit-user-select: none !important;
    -moz-user-select: none !important;
    -ms-user-select: none !important;
}

.active-block .time-range {
    text-align: center !important;
    width: 100% !important;
    user-select: none !important;
    -webkit-user-select: none !important;
    -moz-user-select: none !important;
    -ms-user-select: none !important;
}

.time-range {
    font-size: 1rem;
    color: var(--secondary-color);
    margin-bottom: 15px;
    user-select: none !important;
    -webkit-user-select: none !important;
    -moz-user-select: none !important;
    -ms-user-select: none !important;
}

.timer-display {
    font-size: 3.5rem;
    font-weight: 800;
    margin: 15px 0;
    font-variant-numeric: tabular-nums;
    color: var(--text-color);
    text-shadow: 0 2px 4px rgba(0,0,0,0.05);
    user-select: none !important;
    -webkit-user-select: none !important;
    -moz-user-select: none !important;
    -ms-user-select: none !important;
}

.controls {
    display: flex;
    gap: 12px;
    justify-content: center;
    margin-top: 20px;
}

.btn {
    border: none;
    padding: 14px 28px;
    border-radius: 12px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 1rem;
    display: flex;
    align-items: center;
    gap: 8px;
    min-height: 44px;
    touch-action: manipulation;
}

.btn:focus-visible {
    outline: none;
    box-shadow: var(--focus-ring);
}

.btn:hover:not(:disabled) {
    transform: translateY(-2px);
    filter: brightness(1.1);
}

.btn:active:not(:disabled) {
    transform: translateY(0);
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.primary {
    background: linear-gradient(180deg, rgba(255,255,255,0.18), rgba(255,255,255,0)) , var(--primary-color);
    color: white;
    box-shadow: 0 10px 18px rgba(59, 130, 246, 0.25);
}
.secondary { background: #f1f5f9; color: var(--secondary-color); }
body.dark .secondary { background: #475569; color: #f1f5f9; }
.danger { background: var(--danger-color); color: white; width: 100%; margin-top: 20px; box-shadow: 0 4px 6px -1px rgba(239, 68, 68, 0.3); }

.progress-section {
    margin: 25px 0;
    background: var(--card-bg);
    padding: 15px;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-color);
    transition: background 0.3s ease;
}

.progress-header {
    display: flex;
    justify-content: space-between;
    margin-bottom: 10px;
    font-weight: 600;
    font-size: 0.9rem;
}

.progress-bar {
    height: 12px;
    background: #f1f5f9;
    border-radius: 6px;
    overflow: hidden;
}

body.dark .progress-bar {
    background: #475569;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--primary-color), var(--success-color));
    transition: width 0.6s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.blocks-container {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.small-card {
    background: var(--card-bg);
    padding: 14px 16px;
    border-radius: 14px;
    display: flex !important;
    flex-direction: row !important;
    justify-content: flex-start !important;
    align-items: center !important;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-color);
    border-right: 5px solid var(--secondary-color);
    transition: all 0.2s ease, background 0.3s ease;
    gap: 12px;
    direction: rtl !important;
    user-select: none !important;
    -webkit-user-select: none !important;
    -moz-user-select: none !important;
    -ms-user-select: none !important;
}

.small-card .block-info {
    flex: 1 !important;
    display: flex !important;
    flex-direction: column !important;
    align-items: flex-start !important;
    text-align: right !important;
    user-select: none !important;
    -webkit-user-select: none !important;
    -moz-user-select: none !important;
    -ms-user-select: none !important;
}

.small-card .title {
    font-weight: 800;
    font-size: 1rem;
    color: var(--text-color);
    text-align: right !important;
    user-select: none !important;
    -webkit-user-select: none !important;
    -moz-user-select: none !important;
    -ms-user-select: none !important;
}

.small-card .time {
    font-size: 0.82rem;
    color: var(--secondary-color);
    text-align: right !important;
    user-select: none !important;
    -webkit-user-select: none !important;
    -moz-user-select: none !important;
    -ms-user-select: none !important;
}

.small-card .status {
    flex: 0 0 auto !important;
    margin-right: auto !important;
    margin-left: 0 !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    width: 42px !important;
    height: 42px !important;
    border-radius: 50% !important;
    background: rgba(100, 116, 139, 0.1) !important;
}

body.dark .small-card .status {
    background: rgba(148, 163, 184, 0.10);
}

.small-card .status span {
    font-size: 1.05rem;
    line-height: 1;
}

.small-card.study { 
    border-right-color: var(--study-color); 
    box-shadow: 0 4px 15px rgba(37, 99, 235, 0.25);
    background: linear-gradient(to left, rgba(37, 99, 235, 0.05), var(--card-bg)) !important;
}
.small-card.study:hover {
    box-shadow: 0 8px 25px rgba(37, 99, 235, 0.35);
}

.small-card.rest { 
    border-right-color: var(--rest-color); 
    box-shadow: 0 4px 15px rgba(5, 150, 105, 0.25);
    background: linear-gradient(to left, rgba(5, 150, 105, 0.05), var(--card-bg)) !important;
}
.small-card.rest:hover {
    box-shadow: 0 8px 25px rgba(5, 150, 105, 0.35);
}

.small-card.school { border-right-color: var(--school-color); box-shadow: 0 4px 12px rgba(139, 92, 246, 0.15); }
.small-card.reward { border-right-color: var(--reward-color); box-shadow: 0 4px 12px rgba(217, 119, 6, 0.15); }
.small-card.transit { border-right-color: var(--transit-color); box-shadow: 0 4px 12px rgba(79, 70, 229, 0.15); }

body.dark .small-card {
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.04), rgba(255, 255, 255, 0)) , var(--card-bg);
}

.small-card.done {
    opacity: 0.6;
    background: #f8fafc;
    border-right-color: var(--success-color);
}

body.dark .small-card.done {
    background: #1e293b;
}

.small-card.done .title {
    text-decoration: line-through;
    color: var(--secondary-color);
}

.small-card .title {
    font-weight: 700;
    font-size: 1rem;
}

.small-card .time {
    font-size: 0.85rem;
    color: var(--secondary-color);
}

.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--nav-bg);
    backdrop-filter: blur(10px);
    display: flex;
    justify-content: space-around;
    min-height: var(--nav-height);
    padding: 10px 0 calc(10px + var(--safe-bottom));
    box-shadow: 0 -5px 20px rgba(0,0,0,0.05);
    z-index: 1000;
    border-top: 1px solid var(--border-color);
    transition: background 0.3s ease;
}

.nav-item {
    text-decoration: none;
    color: var(--secondary-color);
    font-weight: 700;
    font-size: 0.95rem;
    transition: all 0.2s ease;
    padding: 8px 16px;
    border-radius: 12px;
    min-height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.nav-item.active {
    color: var(--primary-color);
    background: rgba(59, 130, 246, 0.1);
}

body.dark .nav-item.active {
    background: rgba(59, 130, 246, 0.18);
}

/* Weekly Grid */
.weekly-grid {
    display: flex;
    flex-direction: column;
    gap: 16px;
    animation: fadeInUp 0.5s ease;
}

.day-column {
    background: var(--card-bg);
    padding: 18px;
    border-radius: var(--border-radius);
    border-right: 5px solid var(--primary-color);
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05);
    transition: background 0.3s ease;
}

.day-column.thursday { border-right-color: var(--thursday-color); }
.day-column.friday { border-right-color: var(--friday-color); }

.day-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
    border-bottom: 1px solid #f1f5f9;
    padding-bottom: 8px;
}

body.dark .day-header {
    border-bottom-color: #475569;
}

.day-header strong {
    font-size: 1.1rem;
}

/* Settings */
.setting-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px;
    background: var(--card-bg);
    border-radius: 12px;
    margin-bottom: 10px;
}

.switch {
    position: relative;
    display: inline-block;
    width: 50px;
    height: 24px;
}

.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #ccc;
    transition: .4s;
    border-radius: 24px;
}

.slider:before {
    position: absolute;
    content: "";
    height: 20px;
    width: 20px;
    left: 2px;
    bottom: 2px;
    background-color: white;
    transition: .4s;
    border-radius: 50%;
}

input:checked + .slider {
    background-color: var(--primary-color);
}

input:checked + .slider:before {
    transform: translateX(26px);
}

/* Install Overlay */
.install-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(5px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    padding: 20px;
    animation: fadeIn 0.3s ease;
}

.install-card {
    max-width: 350px;
    width: 100%;
    text-align: center;
    padding: 30px;
    animation: scaleUp 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.app-logo-small {
    width: 80px;
    height: 80px;
    margin-bottom: 20px;
}

.install-card h3 {
    font-size: 1.3rem;
    margin-bottom: 12px;
}

.install-card p {
    color: var(--secondary-color);
    font-size: 0.95rem;
    margin-bottom: 25px;
}

.ios-instruction-small {
    margin: 15px 0;
    padding: 12px;
    background: rgba(59, 130, 246, 0.1);
    border-radius: 10px;
    font-size: 0.85rem;
    color: var(--primary-color);
}

.install-card .btn {
    width: 100%;
    justify-content: center;
}

.btn-text {
    background: none;
    border: none;
    color: var(--secondary-color);
    font-weight: 600;
    margin-top: 15px;
    cursor: pointer;
    font-size: 0.9rem;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes scaleUp {
    from { transform: scale(0.8); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}

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

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

@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}

/* Responsive */
@media (max-width: 480px) {
    .app-container {
        padding: 14px;
    }

    header {
        margin-bottom: 18px;
    }

    header h1 {
        font-size: 1.6rem;
    }

    .card {
        padding: 18px;
        margin-bottom: 14px;
    }

    #block-title {
        font-size: 1.2rem;
    }

    .time-range {
        font-size: 0.95rem;
        margin-bottom: 10px;
    }

    .controls {
        gap: 10px;
    }

    .btn {
        padding: 12px 16px;
        border-radius: 12px;
        width: 100%;
        justify-content: center;
    }

    .controls .btn {
        width: 50%;
    }

    .small-card {
        padding: 14px;
    }

    .small-card .title {
        font-size: 0.95rem;
    }
}

@media (max-width: 400px) {
    .timer-display { font-size: 2.8rem; }
    .btn { padding: 12px 20px; }
}