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

:root {
    --primary:        #2563eb;
    --primary-dark:   #1d4ed8;
    --primary-light:  #eff6ff;
    --accent:         #0ea5e9;
    --success:        #16a34a;
    --warning:        #d97706;
    --danger:         #dc2626;
    --danger-light:   #fef2f2;
    --sidebar-bg:     #0f172a;
    --sidebar-text:   #94a3b8;
    --sidebar-active: #ffffff;
    --sidebar-hover:  #1e293b;
    --sidebar-width:  240px;
    --bg:             #f8fafc;
    --surface:        #ffffff;
    --border:         #e2e8f0;
    --border-strong:  #cbd5e1;
    --text:           #1e293b;
    --text-muted:     #64748b;
    --text-light:     #94a3b8;
    --radius:         10px;
    --radius-sm:      6px;
    --shadow:         0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.06);
    --shadow-md:      0 4px 12px rgba(0,0,0,.10);
    --font:           'Inter', system-ui, sans-serif;
}

html { font-size: 15px; }
body { font-family: var(--font); background: var(--bg); color: var(--text); line-height: 1.6; }

/* ===== Layout ===== */
.app-wrapper { display: flex; min-height: 100vh; }

/* ===== Sidebar ===== */
.sidebar {
    width: var(--sidebar-width);
    background: var(--sidebar-bg);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0; left: 0; bottom: 0;
    z-index: 100;
    overflow-y: auto;
    transition: transform .25s ease;
}

.sidebar-logo {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 20px 18px;
    color: #fff;
    font-weight: 700;
    font-size: 1rem;
    border-bottom: 1px solid rgba(255,255,255,.07);
}

.sidebar-nav { padding: 12px 8px; display: flex; flex-direction: column; gap: 2px; }

.nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 12px;
    border-radius: 8px;
    color: var(--sidebar-text);
    text-decoration: none;
    font-size: .875rem;
    font-weight: 500;
    transition: background .15s, color .15s;
}
.nav-item:hover { background: var(--sidebar-hover); color: #fff; }
.nav-item.active { background: var(--primary); color: #fff; }
.nav-item--highlight { color: #93c5fd; }
.nav-item--highlight:hover { background: rgba(37,99,235,.3); color: #fff; }
.nav-item--highlight.active { background: var(--primary); }
.nav-item--logout { margin-top: auto; color: #f87171; }
.nav-item--logout:hover { background: rgba(220,38,38,.15); color: #f87171; }
.nav-divider { height: 1px; background: rgba(255,255,255,.07); margin: 8px 4px; }

/* ===== Main Content ===== */
.main-content {
    flex: 1;
    margin-left: var(--sidebar-width);
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

.top-bar {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    padding: 14px 28px;
    display: flex;
    align-items: center;
    gap: 14px;
    position: sticky;
    top: 0;
    z-index: 50;
}
.sidebar-toggle { display: none; background: none; border: none; cursor: pointer; color: var(--text); padding: 4px; }

.page-title { font-size: 1.15rem; font-weight: 700; color: var(--text); }
.page-content { padding: 24px 28px; flex: 1; }

/* ===== Cards ===== */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 20px 24px;
    margin-bottom: 20px;
}
.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
    padding-bottom: 14px;
    border-bottom: 1px solid var(--border);
}
.card-title { font-size: 1rem; font-weight: 700; color: var(--text); }

/* ===== Buttons ===== */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 8px 16px;
    border-radius: var(--radius-sm);
    font-size: .875rem;
    font-weight: 600;
    cursor: pointer;
    border: none;
    text-decoration: none;
    transition: background .15s, box-shadow .15s, transform .1s;
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-secondary { background: var(--border); color: var(--text); }
.btn-secondary:hover { background: var(--border-strong); }
.btn-success { background: var(--success); color: #fff; }
.btn-success:hover { background: #15803d; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #b91c1c; }
.btn-outline { background: transparent; border: 1.5px solid var(--border-strong); color: var(--text); }
.btn-outline:hover { background: var(--bg); }
.btn-ghost { background: none; color: var(--primary); padding: 6px 10px; }
.btn-ghost:hover { background: var(--primary-light); }
.btn-sm { padding: 5px 11px; font-size: .8rem; }
.btn-lg { padding: 11px 24px; font-size: .95rem; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* ===== Forms ===== */
.form-group { margin-bottom: 16px; }
.form-label { display: block; font-size: .8rem; font-weight: 600; color: var(--text-muted); margin-bottom: 5px; text-transform: uppercase; letter-spacing: .04em; }
.form-control {
    width: 100%;
    padding: 9px 12px;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: .875rem;
    font-family: var(--font);
    color: var(--text);
    background: #fff;
    transition: border-color .15s, box-shadow .15s;
    outline: none;
}
.form-control:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37,99,235,.12); }
textarea.form-control { resize: vertical; min-height: 100px; }
select.form-control { cursor: pointer; }

.form-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 14px; }

/* ===== Table ===== */
.table-wrapper { overflow-x: auto; border-radius: var(--radius); border: 1px solid var(--border); }
table { width: 100%; border-collapse: collapse; font-size: .875rem; }
thead { background: var(--bg); }
th { padding: 10px 12px; text-align: left; font-size: .75rem; font-weight: 700; color: var(--text-muted); text-transform: uppercase; letter-spacing: .05em; border-bottom: 1px solid var(--border); white-space: nowrap; cursor: pointer; user-select: none; }
th:hover { color: var(--primary); }
td { padding: 10px 12px; border-bottom: 1px solid var(--border); color: var(--text); vertical-align: middle; }
tr:last-child td { border-bottom: none; }
tr:hover td { background: var(--bg); }
.table-check { width: 40px; }

/* ===== Badges ===== */
.badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 20px;
    font-size: .72rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .04em;
}
.badge-club     { background: #dbeafe; color: #1e40af; }
.badge-festival { background: #fce7f3; color: #9d174d; }
.badge-booking  { background: #d1fae5; color: #065f46; }
.badge-label    { background: #ede9fe; color: #5b21b6; }
.badge-other    { background: var(--border); color: var(--text-muted); }
.badge-yes      { background: #d1fae5; color: #065f46; }
.badge-no       { background: #fee2e2; color: #991b1b; }
.badge-success  { background: #d1fae5; color: #065f46; }
.badge-warning  { background: #fef3c7; color: #92400e; }
.badge-info     { background: #dbeafe; color: #1e40af; }

/* ===== Filters Bar ===== */
.filters-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
    margin-bottom: 16px;
    padding: 14px 16px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
}
.filters-bar input, .filters-bar select { flex: 1; min-width: 140px; max-width: 220px; }

/* ===== Stats Grid ===== */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 14px; margin-bottom: 20px; }
.stat-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 18px 20px;
    box-shadow: var(--shadow);
}
.stat-label { font-size: .75rem; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: .04em; margin-bottom: 6px; }
.stat-value { font-size: 1.9rem; font-weight: 800; color: var(--text); }
.stat-sub   { font-size: .78rem; color: var(--text-light); margin-top: 3px; }

/* ===== Calendar ===== */
.calendar-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.cal-header { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; margin-bottom: 4px; }
.cal-day-name { text-align: center; font-size: .75rem; font-weight: 700; color: var(--text-muted); padding: 4px; }
.cal-day {
    aspect-ratio: 1;
    min-height: 64px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 5px;
    font-size: .8rem;
    cursor: pointer;
    background: var(--surface);
    position: relative;
    transition: background .12s;
}
.cal-day:hover { background: var(--primary-light); border-color: var(--primary); }
.cal-day.empty { background: none; border-color: transparent; cursor: default; }
.cal-day.today { border-color: var(--primary); background: var(--primary-light); }
.cal-day.blocked { background: #fee2e2; border-color: #fca5a5; }
.cal-day.has-event { background: #f0fdf4; border-color: #86efac; }
.cal-day-num { font-weight: 700; font-size: .78rem; color: var(--text-muted); }
.cal-day .event-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--success); display: inline-block; margin: 2px 1px; }
.cal-day .block-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--danger); display: inline-block; margin: 2px 1px; }
.cal-event-label { font-size: .65rem; background: #bbf7d0; color: #15803d; padding: 1px 4px; border-radius: 3px; margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: block; }
.cal-block-label { font-size: .65rem; background: #fecaca; color: #b91c1c; padding: 1px 4px; border-radius: 3px; margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: block; }

/* ===== Modal ===== */
.modal-overlay {
    display: none;
    position: fixed; inset: 0;
    background: rgba(0,0,0,.45);
    z-index: 200;
    align-items: center;
    justify-content: center;
    padding: 20px;
}
.modal-overlay.open { display: flex; }
.modal {
    background: var(--surface);
    border-radius: var(--radius);
    box-shadow: var(--shadow-md);
    width: 100%;
    max-width: 540px;
    max-height: 90vh;
    overflow-y: auto;
    animation: modalIn .2s ease;
}
@keyframes modalIn { from { opacity: 0; transform: translateY(-16px); } to { opacity: 1; transform: none; } }
.modal-header { padding: 18px 22px 14px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; }
.modal-title { font-weight: 700; font-size: 1rem; }
.modal-close { background: none; border: none; cursor: pointer; color: var(--text-muted); font-size: 1.3rem; line-height: 1; padding: 2px 6px; border-radius: 4px; }
.modal-close:hover { background: var(--bg); }
.modal-body { padding: 18px 22px; }
.modal-footer { padding: 12px 22px 18px; display: flex; gap: 10px; justify-content: flex-end; border-top: 1px solid var(--border); }

/* ===== Booking Wizard ===== */
.wizard-steps {
    display: flex;
    gap: 0;
    margin-bottom: 28px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow);
}
.wizard-step {
    flex: 1;
    padding: 14px 10px;
    text-align: center;
    font-size: .8rem;
    font-weight: 600;
    color: var(--text-muted);
    border-right: 1px solid var(--border);
    position: relative;
}
.wizard-step:last-child { border-right: none; }
.wizard-step.active { background: var(--primary-light); color: var(--primary); }
.wizard-step.done { background: #f0fdf4; color: var(--success); }
.wizard-step-num { display: block; font-size: 1.1rem; font-weight: 800; margin-bottom: 2px; }

.wizard-nav { display: flex; justify-content: space-between; margin-top: 24px; padding-top: 18px; border-top: 1px solid var(--border); }

/* ===== AI Chat ===== */
.ai-chat { border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.ai-chat-messages { padding: 14px; min-height: 200px; max-height: 340px; overflow-y: auto; display: flex; flex-direction: column; gap: 10px; background: var(--bg); }
.ai-msg { padding: 10px 14px; border-radius: 8px; font-size: .875rem; line-height: 1.55; max-width: 88%; }
.ai-msg.assistant { background: var(--surface); border: 1px solid var(--border); align-self: flex-start; }
.ai-msg.user { background: var(--primary); color: #fff; align-self: flex-end; }
.ai-chat-input { display: flex; gap: 8px; padding: 10px; border-top: 1px solid var(--border); background: var(--surface); }
.ai-chat-input input { flex: 1; }
.ai-thinking { display: flex; gap: 5px; align-items: center; padding: 10px 14px; }
.ai-thinking span { width: 8px; height: 8px; background: var(--text-light); border-radius: 50%; animation: thinking .9s ease-in-out infinite; }
.ai-thinking span:nth-child(2) { animation-delay: .2s; }
.ai-thinking span:nth-child(3) { animation-delay: .4s; }
@keyframes thinking { 0%,60%,100% { transform: none; opacity: .4; } 30% { transform: translateY(-6px); opacity: 1; } }

/* ===== Alerts ===== */
.alert { padding: 12px 16px; border-radius: var(--radius-sm); font-size: .875rem; margin-bottom: 14px; display: flex; align-items: flex-start; gap: 10px; }
.alert-success { background: #f0fdf4; border: 1px solid #86efac; color: #15803d; }
.alert-danger  { background: #fef2f2; border: 1px solid #fca5a5; color: #991b1b; }
.alert-info    { background: #eff6ff; border: 1px solid #93c5fd; color: #1e40af; }
.alert-warning { background: #fffbeb; border: 1px solid #fcd34d; color: #92400e; }

/* ===== Template editor placeholder hints ===== */
.placeholder-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.placeholder-chip { padding: 3px 10px; background: var(--primary-light); color: var(--primary); border-radius: 20px; font-size: .75rem; font-weight: 600; cursor: pointer; border: 1px solid #bfdbfe; transition: background .12s; }
.placeholder-chip:hover { background: #bfdbfe; }

/* ===== Utilities ===== */
.flex { display: flex; }
.flex-center { display: flex; align-items: center; justify-content: center; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.mt-2 { margin-top: 8px; }
.mt-3 { margin-top: 12px; }
.mt-4 { margin-top: 16px; }
.mb-4 { margin-bottom: 16px; }
.text-muted { color: var(--text-muted); }
.text-sm { font-size: .8rem; }
.text-right { text-align: right; }
.font-bold { font-weight: 700; }
.w-full { width: 100%; }
.hidden { display: none !important; }

/* ===== Pagination ===== */
.pagination { display: flex; gap: 4px; align-items: center; justify-content: flex-end; margin-top: 14px; }
.page-btn { padding: 5px 10px; border: 1px solid var(--border); border-radius: var(--radius-sm); font-size: .8rem; cursor: pointer; background: var(--surface); color: var(--text); }
.page-btn:hover, .page-btn.active { background: var(--primary); color: #fff; border-color: var(--primary); }
.page-info { font-size: .8rem; color: var(--text-muted); }

/* ===== Login Page ===== */
.login-page { min-height: 100vh; background: var(--sidebar-bg); display: flex; align-items: center; justify-content: center; padding: 20px; }
.login-card { background: var(--surface); border-radius: 14px; padding: 40px; width: 100%; max-width: 380px; box-shadow: 0 20px 40px rgba(0,0,0,.3); }
.login-logo { text-align: center; margin-bottom: 28px; color: var(--primary); }
.login-logo h1 { font-size: 1.6rem; font-weight: 800; color: var(--text); margin-top: 10px; }
.login-logo p { color: var(--text-muted); font-size: .875rem; }

/* ===== Sidebar Collapsed Mode ===== */
.app-wrapper.sidebar-collapsed .sidebar {
    width: 56px;
}
.app-wrapper.sidebar-collapsed .sidebar-logo span,
.app-wrapper.sidebar-collapsed .nav-item span,
.app-wrapper.sidebar-collapsed .nav-divider {
    display: none;
}
.app-wrapper.sidebar-collapsed .sidebar-logo {
    justify-content: center;
    padding: 18px 0;
}
.app-wrapper.sidebar-collapsed .nav-item {
    justify-content: center;
    padding: 10px 0;
}
.app-wrapper.sidebar-collapsed .main-content {
    margin-left: 56px;
}
.sidebar-collapse-btn {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--sidebar-text);
    padding: 6px 8px;
    border-radius: 6px;
    margin-left: auto;
    transition: color .15s;
    flex-shrink: 0;
}
.sidebar-collapse-btn:hover { color: #fff; background: var(--sidebar-hover); }
.app-wrapper.sidebar-collapsed .sidebar-collapse-btn { margin: 0 auto; }

/* ===== Inactive row ===== */
tr.row-inactive td { background: #f8f8f8 !important; color: #aaa; }
tr.row-inactive td a { color: #aaa !important; }
tr.row-inactive td .badge { opacity: .55; }

/* ===== Gig date colors ===== */
.gig-past   { color: var(--text-muted); font-size:.78rem; }
.gig-future { color: var(--success); font-weight:600; font-size:.78rem; }

/* ===== Filter rows ===== */
.filters-bar { flex-wrap: wrap; }
.filters-row-2 {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
    margin-top: 8px;
}

/* ===== Row clickable ===== */
tr.clickable-row { cursor: pointer; }
tr.clickable-row:hover td { background: var(--primary-light) !important; }
    .sidebar { transform: translateX(-100%); }
    .sidebar.open { transform: translateX(0); }
    .main-content { margin-left: 0; }
    .sidebar-toggle { display: block; }
    .page-content { padding: 16px; }
    .stats-grid { grid-template-columns: repeat(2, 1fr); }
    .wizard-step { font-size: .7rem; padding: 10px 4px; }
}
/* ===== Responsive ===== */
@media (max-width: 768px) {
    .sidebar { transform: translateX(-100%); }
    .sidebar.open { transform: translateX(0); }
    .main-content { margin-left: 0; }
    .sidebar-toggle { display: block; }
    .page-content { padding: 16px; }
    .stats-grid { grid-template-columns: repeat(2, 1fr); }
    .wizard-step { font-size: .7rem; padding: 10px 4px; }
}
