/* ============================================================
   BookABoard – Application Styles
   Uses Pico.css as base (loaded from CDN in index.php)
   ============================================================ */

:root {
    --brand:        #4f46e5;
    --brand-hover:  #4338ca;
    --brand-light:  #eef2ff;
    --danger:       #ef4444;
    --danger-hover: #dc2626;
    --success:      #22c55e;
    --warning:      #f59e0b;
    --released-bg:  #fef9c3;
    --released-border: #fde047;
    --taken-bg:     #f0fdf4;
    --taken-border: #86efac;
    --radius:       0.6rem;
}

/* ── Layout ─────────────────────────────────────────────── */
body {
    min-height: 100vh;
    background: #f8fafc;
}

#app {
    max-width: 960px;
    margin: 0 auto;
    padding: 1.5rem 1rem 4rem;
}

/* ── Navbar ──────────────────────────────────────────────── */
nav.app-nav {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: var(--brand);
    color: #fff;
    padding: 0.75rem 1.5rem;
    border-radius: var(--radius);
    margin-bottom: 2rem;
    flex-wrap: wrap;
    gap: 0.5rem;
}

nav.app-nav .brand {
    font-weight: 700;
    font-size: 1.2rem;
    letter-spacing: 0.02em;
    color: #fff;
}

nav.app-nav .nav-actions {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

nav.app-nav button {
    background: rgba(255,255,255,0.15);
    border: 1px solid rgba(255,255,255,0.35);
    color: #fff;
    padding: 0.3rem 0.9rem;
    border-radius: var(--radius);
    cursor: pointer;
    font-size: 0.875rem;
    transition: background 0.15s;
}

nav.app-nav button:hover {
    background: rgba(255,255,255,0.3);
}

nav.app-nav .user-info {
    font-size: 0.875rem;
    opacity: 0.9;
}

/* ── Views ───────────────────────────────────────────────── */
.view { display: none; }
.view.active { display: block; }

/* ── Auth card ───────────────────────────────────────────── */
.auth-card {
    max-width: 420px;
    margin: 4rem auto;
    background: #fff;
    border-radius: var(--radius);
    padding: 2.5rem 2rem;
    box-shadow: 0 4px 24px rgba(0,0,0,0.08);
}

.auth-card h1 {
    text-align: center;
    margin-bottom: 0.25rem;
    font-size: 1.6rem;
    color: var(--brand);
}

.auth-card .subtitle {
    text-align: center;
    color: #64748b;
    margin-bottom: 1.75rem;
    font-size: 0.9rem;
}

.auth-card label {
    font-weight: 600;
    font-size: 0.875rem;
    display: block;
    margin-bottom: 0.3rem;
    color: #374151;
}

.auth-card input {
    width: 100%;
    padding: 0.6rem 0.85rem;
    border: 1px solid #d1d5db;
    border-radius: 0.4rem;
    font-size: 1rem;
    margin-bottom: 1rem;
    box-sizing: border-box;
    transition: border-color 0.15s;
}

.auth-card input:focus {
    outline: none;
    border-color: var(--brand);
    box-shadow: 0 0 0 3px rgba(79,70,229,0.12);
}

.btn {
    display: inline-block;
    padding: 0.55rem 1.1rem;
    border-radius: 0.4rem;
    border: none;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 600;
    transition: background 0.15s, opacity 0.15s;
}

.btn-primary {
    background: var(--brand);
    color: #fff;
    width: 100%;
    padding: 0.65rem;
}
.btn-primary:hover { background: var(--brand-hover); }

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

.btn-danger {
    background: var(--danger);
    color: #fff;
}
.btn-danger:hover { background: var(--danger-hover); }

.btn-success {
    background: var(--success);
    color: #fff;
}

.btn-warning {
    background: var(--warning);
    color: #fff;
}

.btn-outline {
    background: transparent;
    border: 1.5px solid var(--brand);
    color: var(--brand);
}
.btn-outline:hover { background: var(--brand-light); }

.btn-sm {
    padding: 0.3rem 0.7rem;
    font-size: 0.8rem;
}

.auth-divider {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin: 1rem 0;
    color: #94a3b8;
    font-size: 0.8rem;
}
.auth-divider::before,
.auth-divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: #e2e8f0;
}

/* ── Page header ─────────────────────────────────────────── */
.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
    gap: 0.5rem;
}
.page-header h2 {
    margin: 0;
    font-size: 1.4rem;
    color: #1e293b;
}

/* ── Appointment cards ───────────────────────────────────── */
.appointment-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1.25rem;
}

.appt-card {
    background: #fff;
    border-radius: var(--radius);
    border: 1.5px solid #e2e8f0;
    padding: 1.25rem 1.25rem 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    transition: box-shadow 0.15s, border-color 0.15s;
}
.appt-card:hover {
    box-shadow: 0 4px 16px rgba(0,0,0,0.08);
    border-color: #c7d2fe;
}

.appt-card.has-booking {
    border-color: var(--brand);
    background: var(--brand-light);
}

.appt-card .appt-title {
    font-weight: 700;
    font-size: 1.05rem;
    color: #1e293b;
    margin: 0;
}

.appt-card .appt-meta {
    font-size: 0.82rem;
    color: #64748b;
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
}

.appt-card .appt-desc {
    font-size: 0.875rem;
    color: #475569;
    flex: 1;
}

.slot-bar {
    background: #e2e8f0;
    border-radius: 99px;
    height: 6px;
    overflow: hidden;
}
.slot-bar-fill {
    height: 100%;
    background: var(--brand);
    border-radius: 99px;
    transition: width 0.3s;
}

.slot-label {
    font-size: 0.78rem;
    color: #64748b;
}

.appt-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    margin-top: 0.5rem;
}

/* ── Released slot list ──────────────────────────────────── */
.released-list {
    margin-top: 0.5rem;
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.released-item {
    background: var(--released-bg);
    border: 1px solid var(--released-border);
    border-radius: 0.35rem;
    padding: 0.4rem 0.6rem;
    font-size: 0.8rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
}

.badge {
    display: inline-block;
    padding: 0.15rem 0.55rem;
    border-radius: 99px;
    font-size: 0.72rem;
    font-weight: 600;
}
.badge-booked   { background: #dbeafe; color: #1d4ed8; }
.badge-released { background: #fef9c3; color: #854d0e; }
.badge-taken    { background: #dcfce7; color: #15803d; }
.badge-admin    { background: #f3e8ff; color: #7e22ce; }

/* ── Admin panel ─────────────────────────────────────────── */
.admin-tabs {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
    border-bottom: 2px solid #e2e8f0;
    padding-bottom: 0;
}

.admin-tab {
    padding: 0.5rem 1.1rem;
    border-radius: 0.4rem 0.4rem 0 0;
    border: none;
    background: transparent;
    cursor: pointer;
    font-weight: 600;
    color: #64748b;
    font-size: 0.9rem;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    transition: color 0.15s;
}
.admin-tab.active {
    color: var(--brand);
    border-bottom-color: var(--brand);
}
.admin-tab:hover { color: var(--brand); }

.admin-section { display: none; }
.admin-section.active { display: block; }

/* ── Tables ──────────────────────────────────────────────── */
.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.875rem;
    background: #fff;
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: 0 1px 8px rgba(0,0,0,0.06);
}
.data-table th {
    background: #f1f5f9;
    color: #475569;
    font-weight: 700;
    text-align: left;
    padding: 0.65rem 0.9rem;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}
.data-table td {
    padding: 0.65rem 0.9rem;
    border-top: 1px solid #f1f5f9;
    color: #1e293b;
    vertical-align: middle;
}
.data-table tr:hover td { background: #f8fafc; }

.data-table .actions { display: flex; gap: 0.4rem; flex-wrap: wrap; }

/* ── Modal ───────────────────────────────────────────────── */
.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.45);
    z-index: 100;
    align-items: center;
    justify-content: center;
}
.modal-overlay.open { display: flex; }

.modal {
    background: #fff;
    border-radius: var(--radius);
    padding: 2rem;
    width: 100%;
    max-width: 480px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 20px 60px rgba(0,0,0,0.2);
    position: relative;
}

.modal h3 {
    margin: 0 0 1.25rem;
    font-size: 1.2rem;
    color: #1e293b;
}

.modal label {
    display: block;
    font-weight: 600;
    font-size: 0.85rem;
    margin-bottom: 0.3rem;
    color: #374151;
}

.modal input,
.modal textarea,
.modal select {
    width: 100%;
    padding: 0.55rem 0.8rem;
    border: 1px solid #d1d5db;
    border-radius: 0.4rem;
    font-size: 0.95rem;
    margin-bottom: 0.9rem;
    box-sizing: border-box;
    font-family: inherit;
}
.modal input:focus,
.modal textarea:focus,
.modal select:focus {
    outline: none;
    border-color: var(--brand);
    box-shadow: 0 0 0 3px rgba(79,70,229,0.12);
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 0.5rem;
    margin-top: 1rem;
}

.modal-close {
    position: absolute;
    top: 1rem;
    right: 1rem;
    background: none;
    border: none;
    font-size: 1.3rem;
    cursor: pointer;
    color: #94a3b8;
    line-height: 1;
}
.modal-close:hover { color: #1e293b; }

/* ── Alerts ──────────────────────────────────────────────── */
.alert {
    padding: 0.75rem 1rem;
    border-radius: 0.4rem;
    font-size: 0.875rem;
    margin-bottom: 1rem;
}
.alert-error   { background: #fee2e2; color: #991b1b; border: 1px solid #fca5a5; }
.alert-success { background: #dcfce7; color: #14532d; border: 1px solid #86efac; }
.alert-info    { background: #dbeafe; color: #1e3a8a; border: 1px solid #93c5fd; }

/* ── Spinner ─────────────────────────────────────────────── */
.spinner {
    border: 3px solid #e2e8f0;
    border-top-color: var(--brand);
    border-radius: 50%;
    width: 28px;
    height: 28px;
    animation: spin 0.7s linear infinite;
    margin: 2rem auto;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Empty state ─────────────────────────────────────────── */
.empty-state {
    text-align: center;
    padding: 3rem 1rem;
    color: #94a3b8;
}
.empty-state .empty-icon {
    font-size: 3rem;
    margin-bottom: 0.75rem;
}

/* ── Responsive ──────────────────────────────────────────── */
@media (max-width: 600px) {
    .auth-card { padding: 1.75rem 1.25rem; margin-top: 2rem; }
    .data-table { font-size: 0.78rem; }
    .data-table th, .data-table td { padding: 0.5rem 0.6rem; }
}
