:root {
    color-scheme: dark;
    --bg: #0c1110;
    --surface: #151c1a;
    --surface-alt: #1d2724;
    --ink: #edf5f2;
    --muted: #9aaca6;
    --line: #2b3935;
    --accent: #22c58b;
    --accent-dark: #18a875;
    --accent-light: #153a2e;
    --warn: #332a16;
    --warn-border: #665329;
    --warn-ink: #f7cc73;
    --danger: #e11d48;
    --danger-light: #3a1922;
    --danger-ink: #ff9bae;
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    --shadow: 0 4px 6px -1px rgba(15, 23, 42, 0.05), 0 2px 4px -2px rgba(15, 23, 42, 0.05), 0 0 0 1px rgba(15, 23, 42, 0.02);
    --shadow-hover: 0 10px 15px -3px rgba(15, 23, 42, 0.08), 0 4px 6px -4px rgba(15, 23, 42, 0.08), 0 0 0 1px rgba(15, 23, 42, 0.03);
}

:root[data-theme="light"] {
    color-scheme: light;
    --bg: #f8fafc;
    --surface: #ffffff;
    --surface-alt: #f1f5f9;
    --ink: #0f172a;
    --muted: #64748b;
    --line: #e2e8f0;
    --accent: #059669;
    --accent-dark: #047857;
    --accent-light: #ecfdf5;
    --warn: #fffbeb;
    --warn-border: #fde68a;
    --warn-ink: #b45309;
    --danger-light: #fff1f2;
    --danger-ink: #be123c;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    background: var(--bg);
    color: var(--ink);
    font-family: 'Inter', ui-sans-serif, system-ui, -apple-system, sans-serif;
    -webkit-font-smoothing: antialiased;
}

a {
    color: inherit;
    text-decoration: none;
    transition: var(--transition);
}

h1, h2, h3, h4, .brand strong {
    font-family: 'Outfit', sans-serif;
    font-weight: 700;
}

h1, h2, h3, h4 { letter-spacing: 0; }

/* App Shell Layout */
.app-shell {
    min-height: 100vh;
    display: grid;
    grid-template-columns: 280px minmax(0, 1fr);
}

/* Sidebar Styling */
.sidebar {
    background: #091e17;
    color: #f8fafc;
    padding: 28px 24px;
    display: flex;
    flex-direction: column;
    gap: 32px;
    border-right: 1px solid rgba(255, 255, 255, 0.04);
}

.brand {
    display: flex;
    align-items: center;
    gap: 14px;
}

.brand-mark {
    width: 42px;
    height: 42px;
    display: grid;
    place-items: center;
    border-radius: var(--radius-sm);
    background: linear-gradient(135deg, #10b981, #059669);
    color: #ffffff;
    font-weight: 800;
    font-size: 18px;
    box-shadow: 0 4px 10px rgba(16, 185, 129, 0.3);
}

.brand strong {
    display: block;
    font-size: 16px;
    letter-spacing: -0.02em;
}

.brand small {
    display: block;
    color: #a7f3d0;
    font-size: 12px;
    font-weight: 500;
    margin-top: 2px;
}

/* Sidebar navigation */
.sidebar nav {
    display: grid;
    gap: 6px;
}

.sidebar nav a {
    display: flex;
    align-items: center;
    gap: 12px;
    border-radius: var(--radius-sm);
    color: #94a3b8;
    padding: 12px 14px;
    font-weight: 500;
    font-size: 14px;
}

.sidebar nav a.active,
.sidebar nav a:hover {
    background: rgba(255, 255, 255, 0.06);
    color: #ffffff;
}

.sidebar nav a.active {
    background: #10b981;
    color: #ffffff;
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.2);
}

.sidebar nav a svg {
    width: 18px;
    height: 18px;
    opacity: 0.8;
}

/* Tenant switcher in sidebar */
.tenant-switcher {
    margin-top: auto;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: var(--radius-md);
    padding: 14px;
}

.sidebar-footer {
    display: grid;
    gap: 12px;
    margin-top: auto;
}

.theme-toggle,
.login-link {
    align-items: center;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: var(--radius-sm);
    color: #dbe7e2;
    cursor: pointer;
    display: flex;
    font: inherit;
    font-size: 13px;
    gap: 10px;
    padding: 10px 12px;
    width: 100%;
}

.theme-toggle:hover, .login-link:hover { background: rgba(255, 255, 255, 0.1); }
.theme-toggle svg, .icon-button svg { height: 18px; width: 18px; }

.user-menu {
    align-items: center;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    display: flex;
    justify-content: space-between;
    padding-top: 14px;
}

.user-menu div { display: grid; gap: 2px; min-width: 0; }
.user-menu strong { color: #fff; font-size: 13px; }
.user-menu small { color: #8fa49c; font-size: 11px; overflow: hidden; text-overflow: ellipsis; }
.user-menu form { margin: 0; }

.icon-button {
    background: transparent;
    border: 0;
    border-radius: var(--radius-sm);
    color: #9fb1aa;
    cursor: pointer;
    display: grid;
    padding: 8px;
    place-items: center;
}

.icon-button:hover { background: rgba(255, 255, 255, 0.08); color: #fff; }

.tenant-switcher label {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #64748b;
    margin-bottom: 6px;
    display: block;
    font-weight: 600;
}

.tenant-select {
    width: 100%;
    background: #0f172a;
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: #f8fafc;
    font-size: 13px;
    border-radius: var(--radius-sm);
    padding: 8px 10px;
    cursor: pointer;
}

.tenant-select:focus {
    outline: none;
    border-color: #10b981;
}

/* Main Content Area */
.content {
    padding: 40px;
    background: var(--bg);
}

.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    margin-bottom: 32px;
}

.page-header h1 {
    font-size: 32px;
    letter-spacing: -0.03em;
    margin: 0;
}

.eyebrow {
    color: var(--accent);
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.08em;
    margin: 0 0 6px;
    text-transform: uppercase;
}

.tenant-badge {
    display: flex;
    align-items: center;
    gap: 10px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius-md);
    padding: 8px 16px;
    box-shadow: var(--shadow);
}

.tenant-badge-dot {
    width: 8px;
    height: 8px;
    background: #10b981;
    border-radius: 50%;
    box-shadow: 0 0 8px #10b981;
}

.tenant-badge span {
    font-size: 14px;
    font-weight: 600;
    color: var(--ink);
}

/* Grid Layouts */
.dashboard-grid {
    display: grid;
    grid-template-columns: 400px 1fr;
    gap: 28px;
}

.catalog-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 24px;
}

/* Panels / Cards */
.panel {
    background: var(--surface);
    border-radius: var(--radius-md);
    padding: 24px;
    box-shadow: var(--shadow);
    transition: var(--transition);
    display: flex;
    flex-direction: column;
}

.panel:hover {
    box-shadow: var(--shadow-hover);
}

.panel-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
    border-bottom: 1px solid var(--line);
    padding-bottom: 14px;
}

.panel-heading h2 {
    font-size: 18px;
    margin: 0;
    letter-spacing: -0.01em;
}

.panel-heading span {
    background: var(--surface-alt);
    color: var(--muted);
    font-size: 12px;
    font-weight: 600;
    padding: 4px 10px;
    border-radius: 20px;
}

/* Forms */
.booking-form {
    gap: 16px;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.form-group label {
    color: var(--ink);
    font-size: 13px;
    font-weight: 600;
}

.form-group label span {
    color: var(--danger);
}

input,
select,
textarea {
    width: 100%;
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    color: var(--ink);
    font-family: inherit;
    font-size: 14px;
    padding: 10px 12px;
    background: var(--surface);
    transition: var(--transition);
}

select option {
    background: var(--surface);
    color: var(--ink);
}

input::placeholder,
textarea::placeholder {
    color: var(--muted);
    opacity: 1;
}

:root[data-theme="dark"] input,
:root[data-theme="dark"] select,
:root[data-theme="dark"] textarea {
    background-color: #151c1a;
    border-color: #354640;
    color: #edf5f2;
}

:root[data-theme="dark"] input:-webkit-autofill,
:root[data-theme="dark"] input:-webkit-autofill:hover,
:root[data-theme="dark"] input:-webkit-autofill:focus,
:root[data-theme="dark"] textarea:-webkit-autofill,
:root[data-theme="dark"] select:-webkit-autofill {
    -webkit-box-shadow: 0 0 0 1000px #151c1a inset;
    -webkit-text-fill-color: #edf5f2;
    caret-color: #edf5f2;
}

:root[data-theme="dark"] input[type="datetime-local"]::-webkit-calendar-picker-indicator {
    filter: invert(1);
}

input:focus,
select:focus,
textarea:focus {
    border-color: var(--accent);
    outline: none;
    box-shadow: 0 0 0 3px rgba(5, 150, 105, 0.15);
}

textarea {
    resize: vertical;
}

/* Buttons */
.primary-button,
.secondary-button,
.danger-button {
    border: 0;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-family: inherit;
    font-size: 14px;
    font-weight: 600;
    padding: 10px 16px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: var(--transition);
}

.primary-button {
    background: var(--accent);
    color: #ffffff;
    box-shadow: 0 4px 6px -1px rgba(5, 150, 105, 0.2);
}

.primary-button:hover {
    background: var(--accent-dark);
    transform: translateY(-1px);
}

.primary-button:disabled {
    cursor: not-allowed;
    opacity: 0.6;
    transform: none;
}

.secondary-button {
    background: var(--surface-alt);
    color: var(--ink);
    border: 1px solid var(--line);
}

.secondary-button:hover {
    background: var(--line);
}

.danger-button {
    background: var(--danger-light);
    color: var(--danger-ink);
}

.danger-button:hover {
    background: var(--danger);
    color: #ffffff;
}

/* Notices and Messages */
.notice {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    background: var(--warn);
    border: 1px solid var(--warn-border);
    border-radius: var(--radius-md);
    padding: 14px 18px;
    margin-bottom: 24px;
    color: var(--warn-ink);
}

.notice-icon {
    font-weight: bold;
    font-size: 16px;
}

.notice-content {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.notice-content strong {
    font-weight: 600;
}

.notice-content span {
    font-size: 13px;
}

.form-message {
    font-size: 13px;
    padding: 8px 12px;
    border-radius: var(--radius-sm);
    background: var(--accent-light);
    color: var(--accent-dark);
    margin: 0;
    font-weight: 500;
}

.form-message.error {
    background: var(--danger-light);
    color: var(--danger-ink);
}

.empty-state {
    text-align: center;
    color: var(--muted);
    padding: 40px 20px;
    font-size: 14px;
}

/* Agenda / Appointment list */
.appointment-list {
    display: grid;
    gap: 14px;
}

.appointment-item {
    align-items: center;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius-md);
    display: grid;
    grid-template-columns: 140px minmax(0, 1fr) auto;
    gap: 20px;
    padding: 16px;
    transition: var(--transition);
}

.appointment-item:hover {
    transform: translateX(4px);
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.02);
}

.appointment-time-badge {
    background: var(--accent-light);
    border-radius: var(--radius-sm);
    padding: 8px 12px;
    text-align: center;
    color: var(--accent-dark);
    font-weight: 700;
    font-size: 13px;
    line-height: 1.3;
}

.appointment-details {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.appointment-details strong {
    font-size: 15px;
    color: var(--ink);
}

.appointment-details .service-line {
    font-size: 13px;
    color: var(--muted);
    font-weight: 500;
}

.appointment-details .notes-line {
    font-size: 12px;
    color: var(--muted);
    font-style: italic;
    background: var(--surface-alt);
    padding: 4px 8px;
    border-radius: var(--radius-sm);
    display: inline-block;
    width: fit-content;
    margin-top: 4px;
}

.appointment-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}

/* Badges */
.badge {
    border-radius: 30px;
    font-size: 12px;
    font-weight: 600;
    padding: 4px 12px;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.badge-pending {
    background: var(--warn);
    color: var(--warn-ink);
}

.badge-confirmed {
    background: var(--accent-light);
    color: var(--accent-dark);
}

.badge-cancelled {
    background: var(--danger-light);
    color: var(--danger-ink);
}

/* Filters bar on top of the agenda */
.filters-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius-md);
    padding: 14px 20px;
    margin-bottom: 20px;
    box-shadow: var(--shadow);
}

.filters-left {
    display: flex;
    align-items: center;
    gap: 10px;
}

.filter-tab {
    background: transparent;
    border: 0;
    color: var(--muted);
    font-weight: 600;
    font-size: 13px;
    padding: 6px 14px;
    border-radius: 20px;
    cursor: pointer;
    transition: var(--transition);
}

.filter-tab:hover {
    background: var(--surface-alt);
    color: var(--ink);
}

.filter-tab.active {
    background: var(--accent);
    color: #06150f;
}

:root[data-theme="light"] .filter-tab.active {
    color: #ffffff;
}

.filters-right {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-grow: 1;
    max-width: 600px;
    justify-content: flex-end;
}

.filter-input-wrapper {
    position: relative;
    max-width: 220px;
    width: 100%;
}

.filter-input {
    padding-left: 32px;
    font-size: 13px;
}

.filter-search-icon {
    position: absolute;
    left: 10px;
    top: 50%;
    transform: translateY(-50%);
    width: 14px;
    height: 14px;
    color: var(--muted);
    pointer-events: none;
}

.filter-select {
    max-width: 200px;
    font-size: 13px;
}

/* Compact list in Catalogo */
.compact-list {
    display: grid;
    gap: 16px;
}

.compact-item {
    border-bottom: 1px solid var(--line);
    padding-bottom: 14px;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
}

.compact-item:last-child {
    border-bottom: 0;
    padding-bottom: 0;
}

.compact-item-details {
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.compact-item-details strong {
    font-size: 15px;
    color: var(--ink);
}

.compact-item-details span {
    font-size: 13px;
    color: var(--muted);
}

.compact-item-details small {
    font-size: 12px;
    color: var(--muted);
    background: var(--surface-alt);
    padding: 2px 6px;
    border-radius: 4px;
    display: inline-block;
    width: fit-content;
}

/* Catalog Management Form */
.catalog-form {
    border: 1px solid var(--line);
    border-radius: var(--radius-md);
    background: var(--surface-alt);
    padding: 16px;
    margin-top: 16px;
    display: grid;
    gap: 12px;
}

.catalog-form-title {
    font-weight: 700;
    font-size: 14px;
    margin: 0 0 4px 0;
    color: var(--ink);
}

.catalog-actions-row {
    display: flex;
    gap: 10px;
    margin-top: 6px;
}

.btn-icon {
    border: none;
    background: transparent;
    padding: 6px;
    cursor: pointer;
    border-radius: 50%;
    color: var(--muted);
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn-icon:hover {
    background: var(--danger-light);
    color: var(--danger);
}

/* Settings View details */
.settings-panel {
    max-width: 800px;
}

.settings-form { display: grid; gap: 18px; max-width: 560px; }
.settings-form small { color: var(--muted); font-size: 12px; line-height: 1.5; }
.contact-inbox { margin-top: 24px; }
.message-list { display: grid; gap: 12px; }
.message-item { border: 1px solid var(--line); border-radius: var(--radius-sm); display: grid; gap: 10px; padding: 16px; }
.message-heading { align-items: flex-start; display: flex; justify-content: space-between; }
.message-heading > div { display: grid; gap: 3px; }
.message-heading span, .message-item time { color: var(--muted); font-size: 12px; }
.message-item p { color: var(--ink); font-size: 14px; line-height: 1.6; margin: 0; }
.message-item .icon-button { color: var(--muted); }

.settings-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 32px;
}

.settings-info dl {
    display: grid;
    gap: 16px;
    margin: 0;
}

.settings-info dl div {
    display: grid;
    grid-template-columns: 140px minmax(0, 1fr);
    gap: 16px;
    border-bottom: 1px solid var(--line);
    padding-bottom: 12px;
}

.settings-info dl div:last-child {
    border-bottom: 0;
}

.settings-info dt {
    color: var(--muted);
    font-weight: 600;
    font-size: 14px;
}

.settings-info dd {
    margin: 0;
    font-size: 14px;
    font-weight: 500;
}

code {
    background: var(--surface-alt);
    border-radius: 4px;
    padding: 2px 6px;
    font-size: 12px;
    color: var(--ink);
    border: 1px solid var(--line);
}

.auth-shell {
    align-items: center;
    background: var(--bg);
    display: grid;
    min-height: 100vh;
    padding: 32px 20px;
    place-items: center;
}

.auth-panel {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow);
    display: grid;
    gap: 28px;
    max-width: 440px;
    padding: 32px;
    width: 100%;
}

.auth-brand { align-items: center; display: flex; gap: 12px; }
.auth-brand strong, .auth-brand small { display: block; }
.auth-brand small { color: var(--muted); font-size: 12px; margin-top: 2px; }
.auth-heading h1 { font-size: 28px; margin: 0 0 8px; }
.auth-heading p:last-child { color: var(--muted); font-size: 14px; margin: 0; }
.auth-form { display: grid; gap: 16px; }
.check-row { align-items: center; color: var(--muted); display: flex; font-size: 13px; gap: 8px; }
.check-row input { height: 16px; margin: 0; width: 16px; }
.demo-access { background: var(--surface-alt); border: 1px solid var(--line); border-radius: var(--radius-sm); display: grid; font-size: 13px; gap: 4px; padding: 12px; }
.demo-access span { color: var(--muted); }
.auth-contact { color: var(--accent); font-size: 13px; text-align: center; }
.auth-options { display: flex; flex-wrap: wrap; gap: 10px 18px; justify-content: center; }
.auth-options a { color: var(--accent); font-size: 13px; }
.auth-form small { color: var(--muted); font-size: 12px; }
.auth-actions { display: grid; gap: 8px; }
.register-link { border: 1px solid rgba(255,255,255,.12); border-radius: var(--radius-sm); color: #dbe7e2; font-size: 13px; padding: 10px 12px; text-align: center; }
.register-link:hover { background: rgba(255,255,255,.08); }

.contact-layout { align-items: start; display: grid; gap: 48px; grid-template-columns: minmax(240px, 0.7fr) minmax(400px, 1fr); }
.contact-intro { padding: 24px 0; }
.contact-intro h2 { font-size: 26px; margin: 0 0 12px; }
.contact-intro > p { color: var(--muted); line-height: 1.7; margin: 0; }
.contact-points { display: grid; gap: 22px; margin-top: 36px; }
.contact-points div { display: grid; gap: 4px; }
.contact-points span { color: var(--muted); font-size: 13px; line-height: 1.5; }
.contact-form { gap: 16px; }

/* Blazor interactive error ui */
#blazor-error-ui {
    background: #fef2f2;
    color: #991b1b;
    border-top: 2px solid #ef4444;
    bottom: 0;
    box-shadow: 0 -4px 10px rgba(0, 0, 0, 0.05);
    display: none;
    left: 0;
    padding: 12px 24px;
    position: fixed;
    width: 100%;
    z-index: 1000;
    font-size: 14px;
    font-weight: 500;
    align-items: center;
    justify-content: space-between;
}

#blazor-error-ui a {
    color: #b91c1c;
    text-decoration: underline;
    font-weight: 600;
    margin: 0 10px;
}

#blazor-error-ui .dismiss {
    cursor: pointer;
    font-size: 18px;
    font-weight: 700;
}

/* Responsive queries */
@media (max-width: 1200px) {
    .dashboard-grid {
        grid-template-columns: 1fr;
    }
    
    .catalog-grid {
        grid-template-columns: 1fr 1fr;
    }
}

@media (max-width: 980px) {
    .app-shell {
        grid-template-columns: 1fr;
    }

    .sidebar {
        border-right: 0;
        border-bottom: 1px solid rgba(255, 255, 255, 0.04);
        padding: 20px;
        flex-direction: row;
        align-items: center;
        justify-content: space-between;
    }

    .sidebar nav {
        display: flex;
        flex-direction: row;
        gap: 4px;
    }

    .sidebar-footer { margin-left: auto; margin-top: 0; }
    .user-menu { display: none; }
    .theme-toggle span { display: none; }
    .theme-toggle { padding: 10px; width: auto; }
    
    .tenant-switcher {
        display: none; /* Hide in header for mobile to simplify */
    }

    .content {
        padding: 24px;
    }
}

@media (max-width: 768px) {
    .catalog-grid,
    .settings-grid,
    .contact-layout {
        grid-template-columns: 1fr;
    }

    .contact-layout { gap: 20px; }
    .auth-panel { padding: 24px; }
    
    .filters-bar {
        flex-direction: column;
        align-items: stretch;
    }
    
    .filters-right {
        flex-direction: column;
        align-items: stretch;
        max-width: none;
    }
    
    .filter-input-wrapper,
    .filter-select {
        max-width: none;
    }
    
    .appointment-item {
        grid-template-columns: 1fr;
        text-align: center;
        gap: 12px;
    }
    
    .appointment-time-badge {
        width: fit-content;
        margin: 0 auto;
    }
    
    .appointment-actions {
        justify-content: center;
    }
}
