/* ═══════════════════════════════════════════════════
   Agenda — Design System v2
   ═══════════════════════════════════════════════════ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&display=swap');

:root {
    --primary:        #6366f1;
    --primary-hover:  #4f46e5;
    --primary-light:  #eef2ff;
    --primary-glow:   rgba(99,102,241,0.25);
    --accent:         #ec4899;
    --accent-light:   #fdf2f8;
    --success:        #10b981;
    --success-light:  #d1fae5;
    --warning:        #f59e0b;
    --warning-light:  #fef3c7;
    --danger:         #ef4444;
    --danger-light:   #fee2e2;

    --bg:             #f0f2ff;
    --surface:        #ffffff;
    --surface-2:      #f8fafc;
    --border:         #e2e8f0;
    --border-light:   #f1f5f9;

    --text-1:         #0f172a;
    --text-2:         #334155;
    --text-3:         #64748b;
    --text-4:         #94a3b8;

    --shadow-sm:      0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.04);
    --shadow:         0 4px 16px rgba(0,0,0,.08), 0 1px 4px rgba(0,0,0,.04);
    --shadow-md:      0 8px 32px rgba(0,0,0,.10), 0 2px 8px rgba(0,0,0,.06);
    --shadow-lg:      0 20px 60px rgba(0,0,0,.14), 0 4px 16px rgba(0,0,0,.08);
    --shadow-primary: 0 8px 24px var(--primary-glow);

    --radius-sm:  8px;
    --radius:     14px;
    --radius-lg:  20px;
    --radius-xl:  28px;

    --transition: all .2s cubic-bezier(.4,0,.2,1);
    --transition-slow: all .4s cubic-bezier(.4,0,.2,1);
}

/* ── Reset ── */
*, *::before, *::after { margin:0; padding:0; box-sizing:border-box; }

html { scroll-behavior: smooth; }

body {
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    background: var(--bg);
    color: var(--text-1);
    line-height: 1.6;
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
}

/* ── Scrollbar ── */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 99px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-4); }

/* ══════════════════════════════════════
   LAYOUT
══════════════════════════════════════ */

.page-wrapper {
    padding: 1.5rem;
    max-width: 1440px;
    margin: 0 auto;
}

/* ══════════════════════════════════════
   HEADER / NAVBAR
══════════════════════════════════════ */

.app-header {
    position: sticky;
    top: 1rem;
    z-index: 100;
    background: rgba(255,255,255,0.8);
    -webkit-backdrop-filter: blur(20px) saturate(1.8);
    backdrop-filter: blur(20px) saturate(1.8);
    border: 1px solid rgba(255,255,255,0.9);
    border-radius: var(--radius-lg);
    padding: 0.875rem 1.25rem;
    box-shadow: var(--shadow-md), 0 0 0 1px rgba(99,102,241,0.06);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1.75rem;
}

.header-brand {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-shrink: 0;
}

.header-brand .brand-icon {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    background: linear-gradient(135deg, var(--primary), #818cf8);
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 12px var(--primary-glow);
}

.header-brand h1 {
    font-size: 1.125rem;
    font-weight: 700;
    color: var(--text-1);
    letter-spacing: -0.02em;
}

.user-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    background: var(--primary-light);
    color: var(--primary);
    padding: 0.3rem 0.75rem;
    border-radius: 99px;
    font-size: 0.8rem;
    font-weight: 600;
}

.header-controls {
    display: flex;
    align-items: center;
    gap: 0.625rem;
    flex-wrap: wrap;
}

/* ══════════════════════════════════════
   BUTTONS
══════════════════════════════════════ */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.55rem 1.1rem;
    border-radius: var(--radius-sm);
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
    border: none;
    text-decoration: none;
    transition: var(--transition);
    white-space: nowrap;
    line-height: 1.4;
    position: relative;
    overflow: hidden;
}

.btn::after {
    content: '';
    position: absolute;
    inset: 0;
    background: rgba(255,255,255,0);
    transition: background .15s;
}

.btn:hover::after { background: rgba(255,255,255,0.12); }
.btn:active { transform: scale(0.97); }

.btn-primary {
    background: linear-gradient(135deg, var(--primary), #818cf8);
    color: white;
    box-shadow: var(--shadow-primary);
}

.btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 12px 28px var(--primary-glow);
}

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

.btn-ghost:hover {
    background: var(--surface);
    border-color: var(--primary);
    color: var(--primary);
    transform: translateY(-1px);
}

.btn-danger {
    background: var(--danger-light);
    color: var(--danger);
    border: 1px solid #fca5a5;
}

.btn-danger:hover {
    background: var(--danger);
    color: white;
    transform: translateY(-1px);
}

.btn-admin {
    background: var(--warning-light);
    color: #92400e;
    border: 1px solid #fcd34d;
}

.btn-admin:hover {
    background: var(--warning);
    color: white;
    transform: translateY(-1px);
}

.btn-icon {
    width: 36px;
    height: 36px;
    padding: 0;
    border-radius: var(--radius-sm);
}

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

/* ══════════════════════════════════════
   FILTER BAR
══════════════════════════════════════ */

.filter-bar {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
}

.filter-pill-group {
    display: flex;
    gap: 0.375rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 4px;
}

.status-btn {
    padding: 0.45rem 1rem;
    border-radius: 10px;
    border: none;
    background: transparent;
    color: var(--text-3);
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    white-space: nowrap;
}

.status-btn:hover {
    color: var(--primary);
    background: var(--primary-light);
}

.status-btn.active {
    background: linear-gradient(135deg, var(--primary), #818cf8);
    color: white;
    box-shadow: 0 2px 8px var(--primary-glow);
}

/* ══════════════════════════════════════
   FORM CONTROLS
══════════════════════════════════════ */

.form-control {
    width: 100%;
    padding: 0.65rem 0.875rem;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface);
    color: var(--text-1);
    font-size: 0.9rem;
    font-family: inherit;
    outline: none;
    transition: var(--transition);
    appearance: none;
}

.form-control:hover { border-color: var(--text-4); }

.form-control:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 4px var(--primary-glow);
}

.form-control::placeholder { color: var(--text-4); }

select.form-control {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.75rem center;
    padding-right: 2.5rem;
    cursor: pointer;
}

.form-group {
    margin-bottom: 1.25rem;
}

.form-group label {
    display: block;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-2);
    margin-bottom: 0.4rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

/* ══════════════════════════════════════
   APPOINTMENT GRID
══════════════════════════════════════ */

.appointments-grid {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

.date-row {
    display: flex;
    gap: 1.5rem;
    background: var(--surface);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    box-shadow: var(--shadow);
    border: 1px solid var(--border-light);
    align-items: flex-start;
    animation: fadeInUp .4s cubic-bezier(.4,0,.2,1) both;
    transition: box-shadow .2s;
}

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

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

.date-sidebar {
    min-width: 90px;
    flex-shrink: 0;
    text-align: center;
    padding-right: 1.5rem;
    border-right: 1.5px solid var(--border-light);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.125rem;
}

.date-day-num {
    font-size: 2.25rem;
    font-weight: 800;
    background: linear-gradient(135deg, var(--primary), #818cf8);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    line-height: 1;
    letter-spacing: -0.03em;
}

.date-day-name {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    font-weight: 700;
    color: var(--text-4);
    margin-top: 0.125rem;
}

.date-month {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-3);
}

.day-content {
    flex: 1;
    display: flex;
    flex-wrap: wrap;
    gap: 0.875rem;
}

/* ══════════════════════════════════════
   APPOINTMENT CARD
══════════════════════════════════════ */

.appointment-card {
    background: var(--surface-2);
    border-radius: var(--radius);
    padding: 1.125rem 1.25rem;
    border: 1.5px solid var(--border-light);
    position: relative;
    overflow: hidden;
    min-width: 260px;
    max-width: 340px;
    flex: 1 1 260px;
    cursor: default;
    transition: var(--transition);
}

.appointment-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 4px;
    height: 100%;
    background: linear-gradient(180deg, var(--primary), #818cf8);
    border-radius: 4px 0 0 4px;
}

.appointment-card.status-completed::before {
    background: linear-gradient(180deg, var(--success), #34d399);
}

.appointment-card.status-cancelled::before {
    background: linear-gradient(180deg, var(--danger), #f87171);
}

.appointment-card:hover {
    background: var(--surface);
    border-color: var(--primary);
    box-shadow: 0 8px 24px rgba(99,102,241,0.12);
    transform: translateY(-2px);
}

.card-header-row {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
}

.card-title {
    font-size: 0.975rem;
    font-weight: 700;
    color: var(--text-1);
    line-height: 1.3;
    flex: 1;
}

.card-time {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    color: var(--primary);
    font-size: 0.8rem;
    font-weight: 600;
    background: var(--primary-light);
    padding: 0.2rem 0.6rem;
    border-radius: 99px;
    margin-bottom: 0.625rem;
}

.card-desc {
    font-size: 0.8rem;
    color: var(--text-3);
    margin-bottom: 0.875rem;
    line-height: 1.5;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.card-actions {
    display: flex;
    justify-content: flex-end;
    gap: 0.5rem;
    padding-top: 0.625rem;
    border-top: 1px solid var(--border-light);
}

/* ══════════════════════════════════════
   BADGES
══════════════════════════════════════ */

.badge {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    padding: 0.2rem 0.6rem;
    border-radius: 99px;
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    flex-shrink: 0;
}

.badge::before {
    content: '';
    width: 5px;
    height: 5px;
    border-radius: 50%;
    background: currentColor;
    flex-shrink: 0;
}

.badge-pending   { background: var(--warning-light); color: #b45309; }
.badge-completed { background: var(--success-light);  color: #065f46; }
.badge-cancelled { background: var(--danger-light);   color: #991b1b; }

/* ══════════════════════════════════════
   EMPTY STATE
══════════════════════════════════════ */

.empty-state {
    text-align: center;
    padding: 5rem 2rem;
    color: var(--text-3);
    background: var(--surface);
    border-radius: var(--radius-lg);
    border: 2px dashed var(--border);
    animation: fadeInUp .4s ease both;
}

.empty-icon {
    font-size: 3.5rem;
    margin-bottom: 1rem;
    opacity: 0.5;
}

.empty-state h3 {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--text-2);
    margin-bottom: 0.5rem;
}

.empty-state p {
    font-size: 0.875rem;
    margin-bottom: 1.5rem;
}

/* ══════════════════════════════════════
   LOADING SKELETON
══════════════════════════════════════ */

.skeleton {
    background: linear-gradient(90deg, var(--surface-2) 25%, var(--border-light) 50%, var(--surface-2) 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
    border-radius: var(--radius-sm);
}

@keyframes shimmer {
    0%   { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* ══════════════════════════════════════
   MODAL
══════════════════════════════════════ */

.modal {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(15,23,42,0.55);
    -webkit-backdrop-filter: blur(6px);
    backdrop-filter: blur(6px);
    z-index: 1000;
    justify-content: center;
    align-items: center;
    padding: 1rem;
}

.modal-content {
    background: var(--surface);
    padding: 2rem;
    border-radius: var(--radius-xl);
    width: 100%;
    max-width: 520px;
    box-shadow: var(--shadow-lg), 0 0 0 1px rgba(0,0,0,0.05);
    animation: modalIn .28s cubic-bezier(.34,1.56,.64,1) both;
    position: relative;
}

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

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.5rem;
    padding-bottom: 1rem;
    border-bottom: 1.5px solid var(--border-light);
}

.modal-title {
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--text-1);
}

.modal-close {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    border: none;
    background: var(--surface-2);
    color: var(--text-3);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    transition: var(--transition);
}

.modal-close:hover { background: var(--danger-light); color: var(--danger); }

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 0.75rem;
    margin-top: 1.75rem;
    padding-top: 1.25rem;
    border-top: 1.5px solid var(--border-light);
}

/* ══════════════════════════════════════
   LOGIN PAGE
══════════════════════════════════════ */

.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
    background:
        radial-gradient(ellipse 80% 80% at 20% 20%, rgba(99,102,241,0.15) 0%, transparent 60%),
        radial-gradient(ellipse 60% 60% at 80% 80%, rgba(236,72,153,0.1) 0%, transparent 60%),
        linear-gradient(160deg, #f0f2ff 0%, #fdf4ff 50%, #fff0f9 100%);
    position: relative;
    overflow: hidden;
}

.login-page::before,
.login-page::after {
    content: '';
    position: absolute;
    border-radius: 50%;
    filter: blur(60px);
    opacity: 0.4;
    pointer-events: none;
}

.login-page::before {
    width: 400px; height: 400px;
    background: radial-gradient(circle, #6366f1, transparent);
    top: -100px; left: -100px;
    animation: float 8s ease-in-out infinite;
}

.login-page::after {
    width: 300px; height: 300px;
    background: radial-gradient(circle, #ec4899, transparent);
    bottom: -80px; right: -80px;
    animation: float 10s ease-in-out infinite reverse;
}

@keyframes float {
    0%, 100% { transform: translate(0,0); }
    50%       { transform: translate(20px, -20px); }
}

.login-card {
    background: rgba(255,255,255,0.85);
    -webkit-backdrop-filter: blur(24px) saturate(1.8);
    backdrop-filter: blur(24px) saturate(1.8);
    border: 1.5px solid rgba(255,255,255,0.9);
    border-radius: var(--radius-xl);
    padding: 3rem 2.5rem;
    width: 100%;
    max-width: 420px;
    box-shadow: var(--shadow-lg), 0 0 80px rgba(99,102,241,0.1);
    position: relative;
    z-index: 1;
    animation: modalIn .5s cubic-bezier(.34,1.2,.64,1) both;
}

.login-logo {
    width: 56px; height: 56px;
    margin: 0 auto 1.5rem;
    border-radius: 16px;
    background: linear-gradient(135deg, var(--primary), #818cf8);
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 8px 24px var(--primary-glow);
}

.login-logo svg { color: white; }

.login-title {
    font-size: 1.625rem;
    font-weight: 800;
    text-align: center;
    color: var(--text-1);
    letter-spacing: -0.03em;
    margin-bottom: 0.375rem;
}

.login-subtitle {
    font-size: 0.875rem;
    color: var(--text-3);
    text-align: center;
    margin-bottom: 2rem;
}

.error-msg {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background: var(--danger-light);
    color: #991b1b;
    border: 1px solid #fca5a5;
    padding: 0.75rem 1rem;
    border-radius: var(--radius-sm);
    font-size: 0.875rem;
    font-weight: 500;
    margin-bottom: 1.25rem;
    animation: shake .3s ease both;
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25%       { transform: translateX(-5px); }
    75%       { transform: translateX(5px); }
}

.login-btn {
    width: 100%;
    padding: 0.9rem;
    font-size: 0.975rem;
    margin-top: 0.5rem;
    border-radius: var(--radius-sm);
    letter-spacing: 0.01em;
}

/* ══════════════════════════════════════
   SETTINGS PAGE
══════════════════════════════════════ */

.settings-card {
    background: var(--surface);
    border-radius: var(--radius-lg);
    padding: 2.5rem;
    box-shadow: var(--shadow);
    border: 1px solid var(--border-light);
    max-width: 720px;
    margin: 0 auto;
    animation: fadeInUp .35s ease both;
}

.form-section {
    margin-bottom: 2rem;
    padding-bottom: 2rem;
    border-bottom: 1.5px solid var(--border-light);
}

.form-section:last-of-type { border-bottom: none; margin-bottom: 0; }

.section-title {
    font-size: 0.7rem;
    font-weight: 800;
    color: var(--primary);
    text-transform: uppercase;
    letter-spacing: 0.1em;
    margin-bottom: 1.25rem;
    display: flex;
    align-items: center;
    gap: 0.625rem;
}

.section-title::after {
    content: '';
    flex: 1;
    height: 1.5px;
    background: var(--primary-light);
}

.help-text {
    font-size: 0.8rem;
    color: var(--text-4);
    margin-top: 0.375rem;
    line-height: 1.5;
}

/* ══════════════════════════════════════
   ADMIN TABLE
══════════════════════════════════════ */

.admin-card {
    background: var(--surface);
    border-radius: var(--radius-lg);
    padding: 2rem;
    box-shadow: var(--shadow);
    border: 1px solid var(--border-light);
    max-width: 1000px;
    margin: 0 auto;
    animation: fadeInUp .35s ease both;
}

.users-table {
    width: 100%;
    border-collapse: collapse;
}

.users-table th {
    padding: 0.75rem 1rem;
    text-align: left;
    background: var(--surface-2);
    font-size: 0.7rem;
    font-weight: 800;
    color: var(--text-4);
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.users-table th:first-child { border-radius: var(--radius-sm) 0 0 var(--radius-sm); }
.users-table th:last-child  { border-radius: 0 var(--radius-sm) var(--radius-sm) 0; }

.users-table td {
    padding: 0.875rem 1rem;
    border-bottom: 1px solid var(--border-light);
    font-size: 0.9rem;
    color: var(--text-2);
    vertical-align: middle;
}

.users-table tr:last-child td { border-bottom: none; }

.users-table tr:hover td { background: #fafbff; }

.role-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.2rem 0.6rem;
    border-radius: 99px;
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

/* ══════════════════════════════════════
   NOTIFICATION TOAST
══════════════════════════════════════ */

#toast {
    position: fixed;
    bottom: 1.5rem;
    right: 1.5rem;
    background: var(--text-1);
    color: white;
    padding: 0.875rem 1.25rem;
    border-radius: var(--radius);
    font-size: 0.875rem;
    font-weight: 500;
    box-shadow: var(--shadow-lg);
    z-index: 9999;
    transform: translateY(120%);
    opacity: 0;
    transition: var(--transition-slow);
    display: flex;
    align-items: center;
    gap: 0.625rem;
    max-width: 340px;
}

#toast.show {
    transform: translateY(0);
    opacity: 1;
}

#toast.toast-success { background: #064e3b; }
#toast.toast-error   { background: #7f1d1d; }

/* ══════════════════════════════════════
   RESPONSIVE
══════════════════════════════════════ */

@media (max-width: 768px) {
    .page-wrapper { padding: 1rem; }

    .app-header {
        top: 0.5rem;
        flex-wrap: wrap;
        padding: 0.75rem 1rem;
        gap: 0.75rem;
    }

    .header-controls {
        width: 100%;
        justify-content: flex-end;
    }

    .date-row {
        flex-direction: column;
        gap: 1rem;
        padding: 1.25rem;
    }

    .date-sidebar {
        flex-direction: row;
        align-items: center;
        gap: 0.75rem;
        padding-right: 0;
        padding-bottom: 0.75rem;
        border-right: none;
        border-bottom: 1.5px solid var(--border-light);
        min-width: auto;
        width: 100%;
    }

    .day-content {
        flex-direction: column;
    }

    .appointment-card {
        min-width: unset;
        max-width: 100%;
    }

    .modal-content {
        padding: 1.5rem;
        border-radius: var(--radius-lg);
    }

    .login-card {
        padding: 2rem 1.5rem;
    }
}

@media (max-width: 480px) {
    .btn-text-hide { display: none; }
    .filter-pill-group { flex-wrap: wrap; }
}