:root {
    --bg: #f5f7fb;
    --surface: #ffffff;
    --primary: #6b7dff;
    --secondary: #8bc6ff;
    --accent: #6c5ce7;
    --muted: #5f6c7b;
    --text: #262626;
    --border: #dde4ef;
    --success: #2dce89;
    --warning: #ff9f43;
    --danger: #ff6b6b;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: 'Vazirmatn', sans-serif;
    background: linear-gradient(180deg, #eff3ff 0%, #f9fbff 100%);
    color: var(--text);
    min-height: 100vh;
}

.container {
    width: min(1120px, calc(100% - 2rem));
    margin: 0 auto;
    padding: 1rem 0;
}

.site-header {
    background: #fff;
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 10;
}

.header-grid {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}

.brand {
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--accent);
    text-decoration: none;
}

.main-nav {
    display: flex;
    flex-wrap: wrap;
    gap: .8rem;
}

.main-nav a {
    color: var(--muted);
    text-decoration: none;
    padding: .6rem 1rem;
    border-radius: 999px;
    transition: background .2s, color .2s;
}

.main-nav a:hover {
    background: rgba(107, 125, 255, .12);
    color: var(--accent);
}

.hero {
    display: grid;
    grid-template-columns: 1.4fr .8fr;
    gap: 2rem;
    align-items: center;
    padding: 2.5rem 0;
}

.hero-text h1 {
    font-size: clamp(2rem, 3vw, 3.4rem);
    margin: 0 0 1rem;
    line-height: 1.05;
}

.hero-text p {
    max-width: 640px;
    color: var(--muted);
    margin-bottom: 1.4rem;
    line-height: 1.8;
}

.hero-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
}

.hero-card {
    background: linear-gradient(180deg, #edf2ff 0%, #ffffff 100%);
    border: 1px solid rgba(107, 125, 255, .15);
    border-radius: 24px;
    padding: 2rem;
    box-shadow: 0 20px 60px rgba(23, 63, 138, .08);
}

.hero-card h2 {
    margin-top: 0;
}

.features-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 1rem;
    margin: 2rem 0 4rem;
}

.feature-card {
    background: var(--surface);
    border-radius: 22px;
    padding: 1.6rem;
    border: 1px solid var(--border);
    box-shadow: 0 16px 40px rgba(0,0,0,.04);
}

.feature-card h3 {
    margin-top: 0;
}

.main-content {
    padding: 1.5rem 0 4rem;
}

.panel-card {
    background: var(--surface);
    border-radius: 24px;
    box-shadow: 0 18px 50px rgba(73, 97, 175, .08);
    padding: 2rem;
    border: 1px solid rgba(132, 154, 255, .14);
    margin-bottom: 1.5rem;
}

.auth-card,
.success-card {
    max-width: 640px;
    margin: 0 auto;
}

.auth-card h2,
.panel-card h2 {
    margin-top: 0;
    color: var(--accent);
}

.form-row {
    display: grid;
    gap: .5rem;
    margin-bottom: 1rem;
}

.form-row label {
    font-weight: 600;
}

.form-row input,
.form-row textarea,
.form-row select {
    width: 100%;
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: .9rem 1rem;
    outline: none;
    transition: border-color .2s, box-shadow .2s;
}

.form-row input:focus,
.form-row textarea:focus,
.form-row select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 4px rgba(107, 125, 255, .12);
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: .5rem;
    padding: .95rem 1.6rem;
    border: none;
    border-radius: 999px;
    cursor: pointer;
    text-decoration: none;
    font-weight: 700;
    transition: transform .15s ease, box-shadow .15s ease;
}

.btn:hover {
    transform: translateY(-1px);
}

.btn-primary {
    background: var(--accent);
    color: white;
}

.btn-secondary {
    background: #eef4ff;
    color: var(--accent);
}

.btn-small {
    padding: .6rem 1rem;
    font-size: .87rem;
}

.btn-warning {
    background: var(--warning);
    color: white;
}

.btn-danger {
    background: var(--danger);
    color: white;
}

.days-grid,
.slots-grid,
.calendar-grid,
.articles-grid,
.action-grid {
    display: grid;
    gap: 1rem;
}

.days-grid,
.slots-grid,
.articles-grid {
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
}

.day-card,
.slot-card,
.article-card,
.calendar-link {
    display: block;
    background: white;
    border-radius: 22px;
    padding: 1.4rem;
    text-decoration: none;
    color: inherit;
    border: 1px solid var(--border);
    transition: transform .15s ease, border-color .15s ease;
}

.day-card:hover,
.slot-card:hover,
.article-card:hover,
.calendar-link:hover {
    transform: translateY(-3px);
    border-color: rgba(107, 125, 255, .35);
}

.day-card.disabled {
    opacity: .6;
    pointer-events: none;
}

.calendar-link.selected {
    border-color: var(--accent);
    background: #f4f6ff;
}

.table-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

table {
    width: 100%;
    border-collapse: collapse;
}

table th,
table td {
    text-align: center;
    border-bottom: 1px solid var(--border);
}

table th {
    background: #f8faff;
}

.actions-cell form {
    display: flex;
    gap: .5rem;
    justify-content: center;
    flex-wrap: wrap;
}

.booking-info,
.schedule-summary {
    background: #f7f9ff;
    border: 1px solid rgba(107, 125, 255, .18);
    border-radius: 20px;
    padding: 1.4rem;
    margin-bottom: 1.5rem;
}

.alert {
    padding: 1rem 1.2rem;
    border-radius: 16px;
    margin-bottom: 1rem;
    color: #1a202c;
}

.alert-success { background: #d8f5e8; }
.alert-warning { background: #fff4d6; }
.alert-error,
.alert-danger { background: #ffe2e2; }

.success-card {
    text-align: center;
}

.payment-info {
    font-size: 1.05rem;
    color: var(--accent);
    margin: 1rem 0;
}

.article-detail .article-summary {
    font-weight: 600;
    color: var(--muted);
}

.article-content {
    line-height: 2;
    color: #4b5563;
    margin: 1.5rem 0;
}

/* ===== Calendar table styles ===== */
.calendar-table {
    width: 100%;
    border-collapse: collapse;
    table-layout: fixed;
}

/* تمام سلول‌های جدول (اعم از عنوان و تاریخ) مربع می‌شوند */
.calendar-table th,
.calendar-table td {
    width: calc(100% / 7);
    aspect-ratio: 1 / 1;
    padding: 0.2rem;
    vertical-align: middle;
    border: 1px solid var(--border);
    text-align: center;
    overflow: hidden;
}

.calendar-table th {
    background: #f8faff;
    font-weight: 700;
}

/* استایل سلول‌های تاریخ */
.calendar-cell {
    padding: 0;
}
.calendar-cell .cell-date {
    font-weight: 700;
    font-size: 1.1rem;
    line-height: 1.2;
}
.calendar-cell a.calendar-cell-link {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    width: 100%;
    height: 100%;
    text-decoration: none;
    color: inherit;
    border-radius: 12px;
    padding: 0.2rem;
}
.calendar-cell.available {
    background: #e6f9ec;
    border-color: #65c36b;
    color: #186030;
}
.calendar-cell.available:hover {
    background: #d2f0d8;
}
.calendar-cell.full {
    background: #ffecec;
    border-color: #ff6b6b;
    color: #8b1b1b;
}
.calendar-cell.disabled {
    opacity: .55;
}

/* ===== Slot styles ===== */
.slot-card {
    display: inline-block;
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: .6rem .9rem;
    text-decoration: none;
    color: var(--text);
    transition: transform .12s ease, box-shadow .12s ease;
}
.slot-card:hover { transform: translateY(-3px); border-color: rgba(107,125,255,.35); }
.slot-card.booked {
    background: #ffecec;
    border-color: #ff6b6b;
    color: #8b1b1b;
    cursor: default;
}
.slot-card.disabled {
    opacity: .6;
    pointer-events: none;
}
.slot-card .slot-note { font-size: .8rem; margin-top: .3rem; color: #8b1b1b; }
.slot-card.available {
    background: #e6f9ec;
    border-color: #65c36b;
    color: #1a5f26;
}
.slot-card.available .slot-note { color: #1a5f26; }

/* ===== Month navigation ===== */
.month-nav {
    display: flex;
    align-items: center;
    gap: .5rem;
    width: 320px;
}
.month-nav .month-label {
    flex: 1;
    text-align: center;
    font-weight: 700;
}
.btn-small {
    padding: .35rem .55rem;
    font-size: .9rem;
    white-space: nowrap;
}

/* ============================================================
   RESPONSIVE – بدون تغییر در محتوا یا عملکرد
   ============================================================ */

/* تبلت‌های بزرگ و صفحه‌های با عرض کمتر از 1024px */
@media (max-width: 1024px) {
    .hero {
        grid-template-columns: 1fr;
        gap: 1.5rem;
        padding: 1.5rem 0;
    }
    .hero-text h1 {
        font-size: clamp(1.8rem, 4vw, 2.8rem);
    }
    .panel-card {
        padding: 1.75rem;
    }
    .month-nav {
        width: 260px;
    }
    .calendar-table th,
    .calendar-table td {
        padding: 0.15rem;
    }
    .calendar-cell .cell-date {
        font-size: 1rem;
    }
}

/* تبلت‌های کوچک و موبایل‌های بزرگ (حالت افقی) */
@media (max-width: 860px) {
    .header-grid {
        flex-direction: column;
        align-items: flex-start;
    }
    .main-nav {
        width: 100%;
        justify-content: flex-start;
    }
    .panel-card {
        padding: 1.5rem;
    }
    .month-nav {
        width: 220px;
        gap: .4rem;
    }
    .month-nav .month-label {
        font-size: .95rem;
    }
    .calendar-table th,
    .calendar-table td {
        padding: 0.1rem;
    }
    .calendar-cell .cell-date {
        font-size: .95rem;
    }
    .btn-small {
        padding: .3rem .5rem;
        font-size: .85rem;
    }
}

/* موبایل و تبلت عمودی — چرخش عنوان روزهای هفته ۹۰ درجه به چپ */
@media (max-width: 860px) and (orientation: portrait),
       (max-width: 640px) {
    .calendar-table th {
        writing-mode: vertical-rl;
        text-orientation: mixed;
        font-size: 0.85rem;
        padding: 0.1rem 0.2rem;
        letter-spacing: 0.05rem;
        background: #f8faff;
        word-break: keep-all;
    }
    /* برای اطمینان از اینکه متن در وسط قرار گیرد */
    .calendar-table th {
        vertical-align: middle;
        text-align: center;
    }
    /* تنظیم اندازه فونت برای نمایش بهتر */
    .calendar-table th {
        font-size: 0.75rem;
    }
}

/* موبایل (بیشتر دستگاه‌ها) */
@media (max-width: 640px) {
    .container {
        padding: 0.5rem 0;
        width: calc(100% - 1rem);
    }
    .panel-card {
        padding: 1rem;
        border-radius: 18px;
    }
    .panel-card h2 {
        font-size: 1.2rem;
    }
    .month-nav {
        width: 100%;
        justify-content: center;
        gap: .5rem;
        flex-wrap: nowrap;
    }
    .month-nav .month-label {
        font-size: .9rem;
        white-space: nowrap;
    }
    .month-nav .btn {
        padding: .5rem .8rem;
        font-size: 1rem;
        min-width: 44px;
        min-height: 44px;
    }
    .calendar-table th,
    .calendar-table td {
        padding: 0.1rem;
    }
    .calendar-cell .cell-date {
        font-size: .85rem;
    }
    .btn-small {
        padding: .25rem .4rem;
        font-size: .82rem;
        min-height: 36px;
        min-width: 36px;
    }
    .table-wrap {
        margin: 0 -0.5rem;
        padding: 0 0.5rem;
    }
}

/* موبایل‌های بسیار کوچک (عرض کمتر از 480px) */
@media (max-width: 480px) {
    .panel-card {
        padding: 0.75rem;
        border-radius: 16px;
    }
    .panel-card h2 {
        font-size: 1rem;
    }
    .month-nav {
        gap: .3rem;
    }
    .month-nav .month-label {
        font-size: .8rem;
    }
    .month-nav .btn {
        padding: .4rem .6rem;
        font-size: .9rem;
        min-width: 40px;
        min-height: 40px;
    }
    .calendar-table th,
    .calendar-table td {
        padding: 0.05rem;
    }
    .calendar-cell .cell-date {
        font-size: .75rem;
    }
    .btn-small {
        padding: .2rem .3rem;
        font-size: .75rem;
        min-height: 32px;
        min-width: 32px;
    }
    .table-wrap {
        margin: 0 -0.25rem;
        padding: 0 0.25rem;
    }
    /* چرخش عنوان برای موبایل‌های کوچک با فونت کوچک‌تر */
    .calendar-table th {
        font-size: 0.65rem;
        padding: 0.05rem 0.1rem;
    }
}

/* بهبود نمایش در حالت portrait برای تبلت */
@media (min-width: 641px) and (max-width: 860px) and (orientation: portrait) {
    .month-nav {
        width: 200px;
    }
    .calendar-table th {
        font-size: 0.8rem;
    }
}

/* بهبود نمایش در حالت landscape برای موبایل */
@media (max-width: 860px) and (orientation: landscape) {
    .calendar-table th,
    .calendar-table td {
        padding: 0.1rem;
    }
    .calendar-cell .cell-date {
        font-size: .9rem;
    }
}