/* =========================================
   Toftild – Frisør Planlægning
   Design: Moderne, ren, professionel
   ========================================= */

:root {
    --brand-primary:   #1a1a2e;
    --brand-accent:    #c9a96e;
    --brand-accent-lt: #e8d5b0;
    --bg-app:          #f4f5f7;
    --bg-card:         #ffffff;
    --bg-sidebar:      #1a1a2e;
    --text-primary:    #1a1a2e;
    --text-secondary:  #6b7280;
    --text-light:      #9ca3af;
    --text-on-dark:    #ffffff;
    --border:          #e5e7eb;
    --border-focus:    #c9a96e;
    --shadow-sm:       0 1px 3px rgba(0,0,0,.06), 0 1px 2px rgba(0,0,0,.04);
    --shadow-md:       0 4px 12px rgba(0,0,0,.08);
    --shadow-lg:       0 10px 30px rgba(0,0,0,.12);
    --radius:          10px;
    --radius-sm:       6px;
    --radius-lg:       16px;
    --sidebar-w:       240px;
    --topbar-h:        64px;
    --font:            'Inter', system-ui, -apple-system, sans-serif;
}

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

html { font-size: 15px; }

body {
    font-family: var(--font);
    background: var(--bg-app);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
}

a { color: inherit; text-decoration: none; }
img { display: block; max-width: 100%; }
button, input, select, textarea { font: inherit; }

/* =========================================
   LOGIN
   ========================================= */
.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 50%, #0f3460 100%);
    padding: 1rem;
}

.login-card {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    padding: 2.5rem 2rem;
    width: 100%;
    max-width: 420px;
    box-shadow: var(--shadow-lg);
}

.login-logo {
    text-align: center;
    margin-bottom: 2rem;
}

.login-logo .brand {
    font-size: 2rem;
    font-weight: 800;
    letter-spacing: -.5px;
    color: var(--brand-primary);
}

.login-logo .brand span {
    color: var(--brand-accent);
}

.login-logo .tagline {
    font-size: .85rem;
    color: var(--text-secondary);
    margin-top: .25rem;
    letter-spacing: .5px;
    text-transform: uppercase;
}

.login-card h2 {
    font-size: 1.3rem;
    font-weight: 700;
    margin-bottom: 1.5rem;
    color: var(--text-primary);
}

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

.form-group label {
    display: block;
    font-size: .85rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: .4rem;
    text-transform: uppercase;
    letter-spacing: .4px;
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: .7rem 1rem;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    background: #f9fafb;
    color: var(--text-primary);
    transition: border-color .2s, box-shadow .2s;
    font-size: .95rem;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--border-focus);
    background: #fff;
    box-shadow: 0 0 0 3px rgba(201,169,110,.15);
}

.form-group textarea {
    resize: vertical;
    min-height: 80px;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: .5rem;
    padding: .7rem 1.4rem;
    border-radius: var(--radius-sm);
    font-weight: 600;
    font-size: .95rem;
    cursor: pointer;
    border: none;
    transition: all .18s;
    white-space: nowrap;
}

.btn-primary {
    background: var(--brand-primary);
    color: #fff;
}
.btn-primary:hover { background: #0f0f22; box-shadow: var(--shadow-md); }

.btn-accent {
    background: var(--brand-accent);
    color: #fff;
}
.btn-accent:hover { background: #b8935a; box-shadow: var(--shadow-md); }

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

.btn-danger {
    background: #ef4444;
    color: #fff;
}
.btn-danger:hover { background: #dc2626; }

.btn-sm { padding: .45rem 1rem; font-size: .85rem; }
.btn-lg { padding: .9rem 2rem; font-size: 1rem; }
.btn-full { width: 100%; }
.btn-icon { padding: .45rem .6rem; border-radius: var(--radius-sm); }

.alert {
    padding: .8rem 1rem;
    border-radius: var(--radius-sm);
    font-size: .9rem;
    margin-bottom: 1rem;
}
.alert-error   { background: #fee2e2; color: #991b1b; border: 1px solid #fca5a5; }
.alert-success { background: #d1fae5; color: #065f46; border: 1px solid #6ee7b7; }
.alert-info    { background: #dbeafe; color: #1e40af; border: 1px solid #93c5fd; }
.alert-warning { background: #fef3c7; color: #92400e; border: 1px solid #fcd34d; }

/* =========================================
   APP LAYOUT
   ========================================= */
.app-layout {
    display: flex;
    min-height: 100vh;
}

/* Sidebar */
.sidebar {
    width: var(--sidebar-w);
    background: var(--bg-sidebar);
    color: var(--text-on-dark);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0; left: 0;
    height: 100vh;
    z-index: 100;
    transition: transform .25s;
}

.sidebar-logo {
    padding: 1.5rem 1.25rem 1rem;
    border-bottom: 1px solid rgba(255,255,255,.08);
}

.sidebar-logo .brand {
    font-size: 1.4rem;
    font-weight: 800;
    letter-spacing: -.5px;
    color: #fff;
}
.sidebar-logo .brand span { color: var(--brand-accent); }
.sidebar-logo .sub {
    font-size: .75rem;
    color: rgba(255,255,255,.4);
    margin-top: .15rem;
    text-transform: uppercase;
    letter-spacing: .6px;
}

.sidebar-nav {
    flex: 1;
    overflow-y: auto;
    padding: 1rem 0;
}

.nav-section-title {
    font-size: .7rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: rgba(255,255,255,.3);
    padding: .75rem 1.25rem .3rem;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: .75rem;
    padding: .6rem 1.25rem;
    color: rgba(255,255,255,.65);
    font-size: .9rem;
    font-weight: 500;
    border-radius: var(--radius-sm);
    margin: 0 .5rem;
    transition: all .15s;
    cursor: pointer;
}
.nav-item:hover { background: rgba(255,255,255,.07); color: #fff; }
.nav-item.active { background: rgba(201,169,110,.2); color: var(--brand-accent); }
.nav-item .icon { font-size: 1.1rem; width: 20px; text-align: center; flex-shrink: 0; }

.sidebar-footer {
    padding: 1rem 1.25rem;
    border-top: 1px solid rgba(255,255,255,.08);
}

.manual-link {
    display: flex;
    align-items: center;
    gap: .5rem;
    padding: .4rem .6rem;
    border-radius: var(--radius-sm);
    font-size: .8rem;
    font-weight: 500;
    color: rgba(255,255,255,.45);
    text-decoration: none;
    margin-bottom: .65rem;
    transition: color .13s, background .13s;
}
.manual-link:hover,
.manual-link.active {
    color: rgba(255,255,255,.85);
    background: rgba(255,255,255,.07);
}

.user-chip {
    display: flex;
    align-items: center;
    gap: .75rem;
}

.user-avatar {
    width: 36px; height: 36px;
    background: var(--brand-accent);
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-weight: 700;
    font-size: .9rem;
    color: #fff;
    flex-shrink: 0;
}

.user-info .name { font-size: .9rem; font-weight: 600; color: #fff; }
.user-info .role { font-size: .75rem; color: rgba(255,255,255,.4); }

.logout-btn {
    margin-left: auto;
    background: rgba(255,255,255,.08);
    border: none;
    color: rgba(255,255,255,.5);
    border-radius: var(--radius-sm);
    padding: .35rem .5rem;
    cursor: pointer;
    font-size: .8rem;
    transition: all .15s;
}
.logout-btn:hover { background: rgba(239,68,68,.3); color: #fff; }

/* Main area */
.main-content {
    margin-left: var(--sidebar-w);
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    transition: margin-left .25s;
}

/* Sidebar kollaps */
body.sidebar-collapsed .sidebar {
    transform: translateX(-100%);
}
body.sidebar-collapsed .main-content {
    margin-left: 0;
}

/* Kollaps-knap */
.sidebar-toggle-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border: 1.5px solid var(--border);
    border-radius: 6px;
    background: none;
    cursor: pointer;
    color: var(--text-secondary);
    flex-shrink: 0;
    transition: background .12s, color .12s;
}
.sidebar-toggle-btn:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

/* Topbar */
.topbar {
    height: var(--topbar-h);
    background: var(--bg-card);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    padding: 0 1.5rem;
    gap: 1rem;
    position: sticky;
    top: 0;
    z-index: 50;
}

.topbar-title {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--text-primary);
}

.topbar-spacer { flex: 1; }

.salon-switcher {
    display: flex;
    background: var(--bg-app);
    border: 1.5px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
}

.salon-btn {
    padding: .45rem .85rem;
    font-size: .82rem;
    font-weight: 600;
    background: transparent;
    border: none;
    cursor: pointer;
    color: var(--text-secondary);
    transition: all .15s;
    white-space: nowrap;
}
.salon-btn:hover   { background: rgba(201,169,110,.1); color: var(--brand-accent); }
.salon-btn.active  { background: var(--brand-primary); color: #fff; }

/* Page content */
.page-content {
    flex: 1;
    padding: 1.5rem;
}

.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
    gap: .75rem;
}

.page-header h1 {
    font-size: 1.4rem;
    font-weight: 800;
    color: var(--text-primary);
}

/* Cards */
.card {
    background: var(--bg-card);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border);
}

.card-header {
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: .75rem;
}

.card-body { padding: 1.25rem; }

/* =========================================
   KALENDER
   ========================================= */
.calendar-controls {
    display: flex;
    align-items: center;
    gap: .75rem;
    flex-wrap: wrap;
}

.week-nav {
    display: flex;
    align-items: center;
    gap: .5rem;
}

.week-label {
    font-size: .95rem;
    font-weight: 700;
    min-width: 200px;
    text-align: center;
    color: var(--text-primary);
}

.calendar-wrap {
    overflow-x: auto;
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    background: var(--bg-card);
    border: 1px solid var(--border);
}

.calendar-grid {
    display: grid;
    min-width: 600px;
    user-select: none;
}

/* Sticky header row */
.calendar-header {
    display: contents;
}

.cal-corner {
    background: var(--brand-primary);
    color: rgba(255,255,255,.5);
    font-size: .75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .5px;
    padding: .6rem .5rem;
    text-align: center;
    position: sticky;
    top: 0;
    z-index: 10;
    border-bottom: 1px solid rgba(255,255,255,.1);
}

.cal-day-header {
    background: var(--brand-primary);
    color: rgba(255,255,255,.9);
    font-size: .8rem;
    font-weight: 700;
    padding: .5rem .4rem;
    text-align: center;
    border-left: 1px solid rgba(255,255,255,.1);
    position: sticky;
    top: 0;
    z-index: 10;
    border-bottom: 1px solid rgba(255,255,255,.1);
}

.cal-day-header .day-name { display: block; letter-spacing: .3px; }
.cal-day-header .day-date {
    font-size: .75rem;
    opacity: .6;
    font-weight: 400;
}
.cal-day-header.today { background: #0f3460; }

/* Time label */
.cal-time {
    font-size: .72rem;
    color: var(--text-light);
    padding: 0 .5rem;
    text-align: right;
    line-height: 1;
    border-right: 1px solid var(--border);
    background: #fafafa;
    display: flex;
    align-items: flex-start;
    padding-top: 3px;
    white-space: nowrap;
}

.cal-time.hour-mark {
    font-weight: 600;
    color: var(--text-secondary);
}

/* Slots */
.cal-slot {
    border-left: 1px solid var(--border);
    border-bottom: 1px solid #f0f0f0;
    min-height: 20px;
    position: relative;
    cursor: pointer;
    transition: background .1s;
    background: #fff;
}
.cal-slot:hover { background: rgba(201,169,110,.06); }
.cal-slot.hour-mark { border-bottom-color: var(--border); }
.cal-slot.past { background: #f9fafb; }

/* Appointment blocks */
.appt-block {
    position: absolute;
    left: 2px; right: 2px;
    border-radius: 5px;
    padding: 3px 6px;
    font-size: .76rem;
    font-weight: 600;
    color: #fff;
    overflow: hidden;
    cursor: pointer;
    z-index: 5;
    box-shadow: 0 1px 4px rgba(0,0,0,.2);
    transition: opacity .15s, transform .15s;
    line-height: 1.3;
}
.appt-block:hover { opacity: .9; transform: scale(1.01); }
.appt-block .appt-name  { display: block; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.appt-block .appt-treat { display: block; font-size: .7rem; opacity: .85; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* Hairdresser sub-columns */
.cal-hdcol-header {
    background: #f8f9fa;
    border-left: 1px solid var(--border);
    border-bottom: 2px solid var(--border);
    padding: .4rem;
    text-align: center;
    position: sticky;
    top: 42px;
    z-index: 9;
}
.cal-hdcol-header .hd-name {
    font-size: .78rem;
    font-weight: 700;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* =========================================
   MODAL
   ========================================= */
.modal-overlay {
    position: fixed; inset: 0;
    background: rgba(0,0,0,.5);
    display: flex; align-items: center; justify-content: center;
    z-index: 1000;
    padding: 1rem;
    opacity: 0; pointer-events: none;
    transition: opacity .2s;
}
.modal-overlay.open { opacity: 1; pointer-events: all; }

.modal {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    width: 100%; max-width: 520px;
    box-shadow: var(--shadow-lg);
    transform: translateY(12px) scale(.98);
    transition: transform .2s;
    max-height: 90vh;
    overflow-y: auto;
}
.modal-overlay.open .modal { transform: translateY(0) scale(1); }

.modal-header {
    padding: 1.25rem 1.5rem 1rem;
    border-bottom: 1px solid var(--border);
    display: flex; align-items: center; justify-content: space-between;
}
.modal-header h3 { font-size: 1.1rem; font-weight: 700; }
.modal-close {
    background: none; border: none; cursor: pointer;
    color: var(--text-light); font-size: 1.3rem; line-height: 1;
    padding: .25rem;
    border-radius: var(--radius-sm);
    transition: color .15s;
}
.modal-close:hover { color: var(--text-primary); }

.modal-body { padding: 1.25rem 1.5rem; }

.modal-footer {
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--border);
    display: flex; align-items: center; justify-content: flex-end; gap: .75rem;
}

/* =========================================
   TABELLER
   ========================================= */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
thead th {
    background: #f8f9fa;
    font-size: .8rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .4px;
    color: var(--text-secondary);
    padding: .65rem 1rem;
    text-align: left;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}
tbody td {
    padding: .75rem 1rem;
    border-bottom: 1px solid #f0f1f3;
    font-size: .9rem;
    vertical-align: middle;
}
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover td { background: #fafbfc; }

/* Badge */
.badge {
    display: inline-block;
    padding: .2rem .65rem;
    border-radius: 50px;
    font-size: .75rem;
    font-weight: 700;
}
.badge-green  { background: #d1fae5; color: #065f46; }
.badge-yellow { background: #fef3c7; color: #92400e; }
.badge-red    { background: #fee2e2; color: #991b1b; }
.badge-blue   { background: #dbeafe; color: #1e40af; }
.badge-gray   { background: #f3f4f6; color: #374151; }

/* Status badges for appointments */
.status-booked    { background: #dbeafe; color: #1e40af; }
.status-confirmed { background: #d1fae5; color: #065f46; }
.status-done      { background: #f3f4f6; color: #374151; }
.status-cancelled { background: #fee2e2; color: #991b1b; }

/* Search / filters */
.search-bar {
    position: relative;
    max-width: 320px;
}
.search-bar input {
    width: 100%;
    padding: .6rem .9rem .6rem 2.3rem;
    border: 1.5px solid var(--border);
    border-radius: var(--radius);
    background: #f9fafb;
    font-size: .9rem;
    transition: border-color .2s;
}
.search-bar input:focus {
    outline: none;
    border-color: var(--border-focus);
    background: #fff;
    box-shadow: 0 0 0 3px rgba(201,169,110,.12);
}
.search-icon {
    position: absolute;
    left: .75rem; top: 50%;
    transform: translateY(-50%);
    color: var(--text-light);
    font-size: .9rem;
    pointer-events: none;
}

/* Stats cards */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}
.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.1rem 1.25rem;
    box-shadow: var(--shadow-sm);
}
.stat-card .stat-label { font-size: .78rem; font-weight: 600; color: var(--text-secondary); text-transform: uppercase; letter-spacing: .4px; }
.stat-card .stat-value { font-size: 1.7rem; font-weight: 800; color: var(--text-primary); margin-top: .2rem; line-height: 1; }
.stat-card .stat-sub   { font-size: .8rem; color: var(--text-light); margin-top: .25rem; }

/* Divider */
.divider { border: none; border-top: 1px solid var(--border); margin: 1rem 0; }

/* Grid utilities */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 1rem; }

/* Scrollbar styling */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #d1d5db; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #9ca3af; }

/* =========================================
   RESPONSIVE
   ========================================= */
@media (max-width: 900px) {
    .sidebar { transform: translateX(-100%); }
    .sidebar.open { transform: translateX(0); }
    .main-content { margin-left: 0; }
    .grid-2, .grid-3 { grid-template-columns: 1fr; }
}

@media (max-width: 600px) {
    .page-content { padding: 1rem; }
    .topbar { padding: 0 1rem; }
    .stats-grid { grid-template-columns: 1fr 1fr; }
}
