:root {
    --bg: #f3f4f6;
    --bg-alt: #e5e7eb;
    --accent: #2563eb;
    --accent-soft: rgba(37, 99, 235, 0.08);
    --card-bg: rgba(255, 255, 255, 0.9);
    --card-border: rgba(148, 163, 184, 0.7);
    --text-main: #111827;
    --text-muted: #6b7280;
    --danger: #b91c1c;
    --success: #15803d;
    --radius-lg: 12px;
    --shadow-soft: 0 6px 18px rgba(15, 23, 42, 0.12);
}

/* Basic reset */
*,
*::before,
*::after {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    background: radial-gradient(circle at top, #ffffff 0, #e5e7eb 60%, #d1d5db 100%);
    color: var(--text-main);
    font-size: 13px;
}

/* Top bar */
.top-bar {
    position: sticky;
    top: 0;
    z-index: 10;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 4px 14px;
    backdrop-filter: blur(12px);
    background: rgba(249, 250, 251, 0.9);
    border-bottom: 1px solid rgba(209, 213, 219, 0.9);
}

.brand {
    font-weight: 600;
    letter-spacing: 0.04em;
    font-size: 11px;
    text-transform: uppercase;
    color: #111827;
}

.top-nav a {
    color: var(--text-muted);
    text-decoration: none;
    font-size: 11px;
    padding: 2px 10px;
    border-radius: 999px;
    border: 1px solid transparent;
}

.top-nav a:hover {
    border-color: rgba(156, 163, 175, 0.8);
    color: #111827;
}

.user-label {
    font-size: 11px;
    color: var(--text-muted);
    margin: 0 6px;
}

/* Layout */
.page-container {
    padding: 8px 10px;
    max-width: 1300px;
    margin: 0 auto;
}

.layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 8px;
}

/* Cards */
.card {
    border-radius: var(--radius-lg);
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    box-shadow: var(--shadow-soft);
    padding: 6px 8px;
    backdrop-filter: blur(16px);
}

.card-title {
    font-size: 12px;
    font-weight: 600;
    margin-bottom: 4px;
    color: #111827;
}

/* Flash messages */
.flash-container {
    position: fixed;
    right: 16px;
    bottom: 16px;
    max-width: 260px;
    z-index: 50;
}

.flash {
    padding: 8px 10px;
    border-radius: 10px;
    font-size: 12px;
    border: 1px solid transparent;
    margin-top: 6px;
    box-shadow: var(--shadow-soft);
    background: #ffffff;
}

.flash-error {
    border-color: rgba(220, 38, 38, 0.7);
    background: #fef2f2;
    color: var(--danger);
}

.flash-success {
    border-color: rgba(22, 163, 74, 0.7);
    background: #ecfdf3;
    color: var(--success);
}

/* Inputs, buttons */
input[type="text"],
input[type="date"],
input[type="password"],
select,
textarea {
    margin-top: 2px;
    padding: 3px 6px;
    border-radius: 999px;
    border: 1px solid rgba(156, 163, 175, 0.9);
    background: #f9fafb;
    color: var(--text-main);
    font-size: 12px;
    outline: none;
}

textarea {
    border-radius: 8px;
    resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 1px rgba(37, 99, 235, 0.6);
    background: #ffffff;
}

button {
    padding: 4px 12px;
    border-radius: 999px;
    border: none;
    font-size: 12px;
    font-weight: 500;
    background: linear-gradient(to right, #2563eb, #1d4ed8);
    color: white;
    cursor: pointer;
}

button:hover {
    filter: brightness(1.04);
}

/* Week navigation + day tabs */
.week-day-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 2px;
    gap: 8px;
    flex-wrap: wrap;
}

.week-nav {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 11px;
    color: var(--text-muted);
}

.week-nav a {
    color: var(--accent);
    text-decoration: none;
    font-size: 11px;
}

.week-nav a:hover {
    text-decoration: underline;
}

.day-tabs {
    display: flex;
    gap: 4px;
    flex-wrap: wrap;
}

.day-tab {
    padding: 2px 8px;
    border-radius: 999px;
    border: 1px solid transparent;
    font-size: 11px;
    color: var(--text-muted);
    text-decoration: none;
    background: rgba(243, 244, 246, 0.8);
}

.day-tab-date {
    margin-left: 4px;
    font-size: 10px;
    color: var(--text-muted);
}

.day-tab.active {
    border-color: var(--accent);
    color: #111827;
    background: rgba(219, 234, 254, 0.9);
}

/* Add-form rows (schedule, bills) */
.add-form-row,
.bills-form-row,
.user-add-form {
    display: flex;
    align-items: flex-end;
    gap: 6px;
    margin-top: 6px;
    flex-wrap: wrap;
}

.add-form-row label,
.bills-form-row label,
.user-add-form label {
    display: flex;
    flex-direction: column;
    font-size: 11px;
    color: var(--text-muted);
    min-width: 150px;
}

.notes-inline {
    min-width: 180px;
}

.form-actions-inline {
    margin-left: auto;
}

/* Schedule table */
.schedule-wrapper {
    margin-top: 4px;
    overflow: hidden;
}

.schedule-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 11px;
    table-layout: fixed;
}

/* vertical "boards" between doctor columns */
.schedule-table thead th:nth-child(n+3),
.schedule-table tbody td:nth-child(n+3) {
    border-left: 1px solid rgba(209, 213, 219, 1);
}

.schedule-table thead th {
    position: sticky;
    top: 0;
    background: #f3f4f6;
    padding: 3px 2px;
    font-weight: 500;
    color: var(--text-muted);
    border-bottom: 1px solid rgba(209, 213, 219, 0.9);
    text-align: center;
}

.time-header {
    width: 60px;
}

.schedule-table tbody td {
    border-bottom: 1px solid rgba(229, 231, 235, 0.9);
}

.time-col {
    width: 60px;
    text-align: right;
    padding-right: 6px;
    color: var(--text-muted);
    white-space: nowrap;
    font-size: 10px;
}

.slot {
    height: 18px;
    padding: 1px 2px;
    vertical-align: top;
}

.slot.free {
    background: transparent;
}

.slot.busy {
    background: transparent; /* color handled by doctor- classes */
}

/* Appointment badges */
.appt-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    margin-bottom: 1px;
    padding: 1px 6px;
    border-radius: 999px;
    border: 1px solid transparent;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-size: 10px;
    background: rgba(255, 255, 255, 0.6);
}

.appt-type {
    font-weight: 600;
}

.appt-patient {
    color: var(--text-muted);
}

/* Delete button inside schedule badge */
.inline-delete-form {
    display: inline-block;
}

.delete-btn {
    border: none;
    background: transparent;
    color: #4b5563;
    font-size: 12px;
    padding: 0 2px;
    cursor: pointer;
    line-height: 1;
}

.delete-btn:hover {
    color: #b91c1c;
}

/* Doctor-specific colors: columns & headers */
/* 1 Farshid, 2 Suada, 3 Ibrahim, 4 Lala */
.doctor-cell.doctor-1,
.doctor-header.doctor-1 {
    background: rgba(59, 130, 246, 0.06);
}

.doctor-cell.doctor-2,
.doctor-header.doctor-2 {
    background: rgba(16, 185, 129, 0.06);
}

.doctor-cell.doctor-3,
.doctor-header.doctor-3 {
    background: rgba(245, 158, 11, 0.06);
}

.doctor-cell.doctor-4,
.doctor-header.doctor-4 {
    background: rgba(244, 114, 182, 0.06);
}

/* Module tabs (Schedule / Bills) */
.module-tabs {
    display: inline-flex;
    gap: 4px;
    margin-bottom: 6px;
}

.module-tab {
    padding: 3px 10px;
    border-radius: 999px;
    border: 1px solid rgba(209, 213, 219, 1);
    font-size: 11px;
    color: var(--text-muted);
    text-decoration: none;
    background: rgba(243, 244, 246, 0.9);
}

.module-tab.active {
    border-color: var(--accent);
    background: rgba(219, 234, 254, 1);
    color: #111827;
}

/* Bills page */
.bills-summary {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 6px;
    font-size: 11px;
    color: var(--text-muted);
}

.bills-amounts {
    display: flex;
    gap: 10px;
}

.bills-amounts .paid {
    color: var(--success);
    font-weight: 600;
}

.bills-amounts .unpaid {
    color: var(--danger);
    font-weight: 600;
}

.paid-inline {
    flex-direction: row;
    align-items: center;
    gap: 4px;
    min-width: auto;
}

.bills-table-wrapper {
    margin-top: 6px;
    overflow-x: auto;
}

.bills-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 11px;
}

.bills-table thead th {
    padding: 4px 6px;
    border-bottom: 1px solid rgba(209, 213, 219, 1);
    text-align: left;
    color: var(--text-muted);
}

.bills-table tbody td {
    padding: 3px 6px;
    border-bottom: 1px solid rgba(229, 231, 235, 1);
}

.bills-table tr.bill-paid {
    background: rgba(209, 250, 229, 0.5);
}

.bills-table tr.bill-unpaid {
    background: rgba(254, 242, 242, 0.5);
}

.no-bills {
    text-align: center;
    color: var(--text-muted);
}

.toggle-paid-btn {
    padding: 2px 8px;
    border-radius: 999px;
    border: none;
    font-size: 10px;
    background: rgba(55, 65, 81, 0.9);
    color: #f9fafb;
    cursor: pointer;
}

.toggle-paid-btn:hover {
    background: rgba(31, 41, 55, 0.95);
}

/* Auth layout (login) */
.auth-wrapper {
    min-height: calc(100vh - 60px);
    display: flex;
    align-items: center;
    justify-content: center;
}

.auth-card {
    max-width: 320px;
    width: 100%;
}

.auth-form {
    display: grid;
    gap: 8px;
}

.auth-form label {
    display: flex;
    flex-direction: column;
    font-size: 11px;
    color: var(--text-muted);
}

.auth-actions {
    display: flex;
    justify-content: flex-end;
    margin-top: 4px;
}

.auth-hint {
    margin-top: 6px;
    font-size: 11px;
    color: var(--text-muted);
}

/* Users admin table */
.users-table-wrapper {
    margin-top: 6px;
    overflow-x: auto;
}

.users-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 11px;
}

.users-table thead th {
    padding: 4px 6px;
    border-bottom: 1px solid rgba(209, 213, 219, 1);
    text-align: left;
    color: var(--text-muted);
}

.users-table tbody td {
    padding: 3px 6px;
    border-bottom: 1px solid rgba(229, 231, 235, 1);
}

.inline-password-form,
.inline-delete-user-form {
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.small-btn {
    padding: 2px 8px;
    font-size: 10px;
}

.danger-btn {
    background: linear-gradient(to right, #dc2626, #b91c1c);
}

.danger-btn:hover {
    filter: brightness(1.05);
}

.self-note {
    font-size: 10px;
    color: var(--text-muted);
}
