/* Taika - Admin Panel Styles */

/* ============================================
   Light theme (default CSS, overridden by dark)
   ============================================ */
:root {
    --primary: #4f46e5;
    --primary-hover: #4338ca;
    --primary-ring: rgba(79, 70, 229, 0.12);
    --danger: #dc2626;
    --danger-hover: #b91c1c;
    --success: #16a34a;
    --success-bg: #f0fdf4;
    --success-border: #bbf7d0;
    --warning: #d97706;
    --warning-bg: #fffbeb;
    --warning-border: #fde68a;
    --bg: #f8fafc;
    --surface: #ffffff;
    --surface-raised: #ffffff;
    --border: #e2e8f0;
    --text: #1e293b;
    --text-muted: #64748b;
    --input-bg: transparent;
    --radius: 8px;
    --shadow: 0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.04);
    --shadow-md: 0 4px 6px rgba(0,0,0,0.07), 0 2px 4px rgba(0,0,0,0.05);
    --sidebar-w: 240px;
    --sidebar-w-collapsed: 64px;
}

/* ============================================
   Dark theme (default via JS)
   ============================================ */
html.dark {
    --primary: #818cf8;
    --primary-hover: #6366f1;
    --primary-ring: rgba(129, 140, 248, 0.15);
    --danger: #f87171;
    --danger-hover: #ef4444;
    --success: #4ade80;
    --success-bg: rgba(34, 197, 94, 0.1);
    --success-border: rgba(34, 197, 94, 0.2);
    --warning: #fbbf24;
    --warning-bg: rgba(251, 191, 36, 0.1);
    --warning-border: rgba(251, 191, 36, 0.2);
    --bg: #0f172a;
    --surface: #1e293b;
    --surface-raised: #334155;
    --border: #334155;
    --text: #f1f5f9;
    --text-muted: #94a3b8;
    --input-bg: #0f172a;
    --shadow: 0 1px 3px rgba(0,0,0,0.3), 0 1px 2px rgba(0,0,0,0.2);
    --shadow-md: 0 4px 6px rgba(0,0,0,0.3), 0 2px 4px rgba(0,0,0,0.2);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html {
    overflow-x: hidden;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    min-height: 100vh;
    overflow-x: hidden;
}

/* ============================================
   App Layout (sidebar + main)
   ============================================ */
.app-layout {
    min-height: 100vh;
}

/* --- Sidebar --- */
.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: var(--sidebar-w);
    background: var(--surface);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    z-index: 40;
    transition: width 0.2s ease;
    overflow: hidden;
}

.app-layout.collapsed .sidebar {
    width: var(--sidebar-w-collapsed);
}

.sidebar-header {
    display: flex;
    align-items: center;
    padding: 14px 16px;
    border-bottom: 1px solid var(--border);
    min-height: 56px;
    gap: 8px;
}

.sidebar-logo {
    display: flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
    color: var(--text);
    overflow: hidden;
    flex: 1;
    min-width: 0;
}

.sidebar-logo svg {
    width: 28px;
    height: 28px;
    flex-shrink: 0;
}

.sidebar-logo .sidebar-label {
    font-size: 1.125rem;
    font-weight: 600;
    white-space: nowrap;
}

.sidebar-toggle {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-muted);
    padding: 4px;
    display: flex;
    align-items: center;
    flex-shrink: 0;
    border-radius: 4px;
    transition: color 0.1s;
}

.sidebar-toggle:hover {
    color: var(--text);
}

.sidebar-toggle svg {
    width: 18px;
    height: 18px;
    transition: transform 0.2s;
}

.app-layout.collapsed .sidebar-toggle svg {
    transform: rotate(180deg);
}

.sidebar-nav {
    flex: 1;
    padding: 12px 8px;
    overflow-y: auto;
    overflow-x: hidden;
}

.sidebar-section {
    font-size: 0.6875rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    padding: 12px 12px 4px;
    white-space: nowrap;
    overflow: hidden;
}

.sidebar-link {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    border-radius: 6px;
    color: var(--text-muted);
    text-decoration: none;
    font-size: 0.875rem;
    font-weight: 500;
    white-space: nowrap;
    transition: background 0.1s, color 0.1s;
    border: none;
    background: none;
    cursor: pointer;
    width: 100%;
    text-align: left;
    font-family: inherit;
}

.sidebar-link:hover {
    background: var(--bg);
    color: var(--text);
}

.sidebar-link.active {
    background: var(--primary-ring);
    color: var(--primary);
}

.sidebar-link svg {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
}

.sidebar-label {
    overflow: hidden;
    white-space: nowrap;
    transition: opacity 0.15s;
}

.app-layout.collapsed .sidebar-label {
    opacity: 0;
    width: 0;
}

.app-layout.collapsed .sidebar-section {
    opacity: 0;
    height: 0;
    padding: 0;
    overflow: hidden;
}

.sidebar-footer {
    padding: 8px;
    border-top: 1px solid var(--border);
}

.sidebar-user {
    padding: 6px 12px;
    font-size: 0.75rem;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* --- Main Content --- */
.main-content {
    margin-left: var(--sidebar-w);
    min-height: 100vh;
    max-width: calc(100vw - var(--sidebar-w));
    transition: margin-left 0.2s ease, max-width 0.2s ease;
    display: flex;
    flex-direction: column;
    overflow-x: hidden;
}

.app-layout.collapsed .main-content {
    margin-left: var(--sidebar-w-collapsed);
    max-width: calc(100vw - var(--sidebar-w-collapsed));
}

.main-content > .container {
    flex: 1;
}

/* --- Mobile Header (replaces sidebar on small screens) --- */
.mobile-header {
    display: none;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    box-shadow: var(--shadow);
    margin-bottom: 24px;
    gap: 8px;
}

.mobile-header-logo {
    display: flex;
    align-items: center;
    gap: 8px;
    text-decoration: none;
    color: var(--text);
}

.mobile-header-logo svg {
    width: 24px;
    height: 24px;
}

.mobile-header-logo span {
    font-size: 1rem;
    font-weight: 600;
}

.mobile-header-actions {
    display: flex;
    gap: 8px;
    align-items: center;
}

/* --- Layout: Container --- */
.container {
    width: 100%;
    max-width: 1400px;
    margin: 0 auto;
    padding: 24px 32px;
}

/* --- Login: Split Layout --- */
.login-split {
    display: flex;
    min-height: 100vh;
}

.login-form-side {
    display: flex;
    flex-direction: column;
    justify-content: center;
    width: 100%;
    padding: 48px 24px;
}

.login-form-inner {
    width: 100%;
    max-width: 400px;
    margin: 0 auto;
}

.login-logo {
    display: block;
    margin-bottom: 32px;
}

.login-logo img,
.login-logo svg {
    display: block;
    height: 56px;
    width: auto;
}

/* Dark mode: invert the dark text in the SVG logo */
.login-logo .taika-text-main { fill: #231f20; }
.login-logo .taika-text-sub { fill: #2a00b3; }
html.dark .login-logo .taika-text-main { fill: #f1f5f9; }
html.dark .login-logo .taika-text-sub { fill: #a5b4fc; }

.login-heading {
    font-size: 1.5rem;
    font-weight: 600;
    margin-bottom: 6px;
}

.login-subtext {
    color: var(--text-muted);
    font-size: 0.875rem;
    margin-bottom: 28px;
}

.login-image-side {
    display: none;
    position: relative;
    overflow: hidden;
    background: linear-gradient(135deg, #f89747 0%, #ee2744 100%);
}

.login-image-side .login-image-overlay {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-end;
    padding: 48px 32px;
}

.login-image-side .login-image-title {
    font-size: 1.5rem;
    font-weight: 700;
    color: #fff;
    letter-spacing: -0.02em;
}

.login-image-side .login-image-sub {
    font-size: 0.875rem;
    color: rgba(255,255,255,0.7);
    margin-top: 4px;
}

/* Password field wrapper */
.password-wrapper {
    position: relative;
}

.password-wrapper input {
    padding-right: 44px;
}

.password-toggle {
    position: absolute;
    top: 50%;
    right: 12px;
    transform: translateY(-50%);
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-muted);
    padding: 2px;
    display: flex;
    align-items: center;
}

.password-toggle:hover {
    color: var(--text);
}

.password-toggle svg {
    width: 20px;
    height: 20px;
}

/* Dark mode toggle button (login page only) */
.theme-toggle {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 50;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text-muted);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: var(--shadow-md);
    transition: background 0.15s, color 0.15s;
}

.theme-toggle:hover {
    background: var(--surface-raised);
    color: var(--text);
}

.theme-toggle svg {
    width: 18px;
    height: 18px;
}

/* --- Forms --- */
.form-group {
    margin-bottom: 16px;
}

.form-group label {
    display: block;
    font-size: 0.875rem;
    font-weight: 500;
    margin-bottom: 6px;
    color: var(--text);
}

.form-group input[type="text"],
.form-group input[type="password"],
.form-group input[type="date"],
.form-group textarea,
.form-group select {
    width: 100%;
    height: 44px;
    padding: 10px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 0.9375rem;
    font-family: inherit;
    color: var(--text);
    background: var(--input-bg);
    transition: border-color 0.15s;
}

.form-group input::placeholder,
.form-group textarea::placeholder {
    color: var(--text-muted);
    opacity: 0.6;
}

.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-ring);
}

.form-group textarea {
    height: auto;
    min-height: 100px;
    resize: vertical;
}

.form-group textarea.large {
    min-height: 200px;
}

/* --- Buttons --- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 10px 20px;
    border: none;
    border-radius: var(--radius);
    font-size: 0.9375rem;
    font-weight: 500;
    cursor: pointer;
    text-decoration: none;
    transition: background-color 0.15s, transform 0.1s;
}

.btn:active { transform: scale(0.98); }

.btn-primary {
    background: var(--primary);
    color: #fff;
    box-shadow: 0 1px 2px rgba(0,0,0,0.1);
}
.btn-primary:hover { background: var(--primary-hover); }

.btn-danger {
    background: var(--danger);
    color: #fff;
}
.btn-danger:hover { background: var(--danger-hover); }

.btn-outline {
    background: transparent;
    color: var(--text);
    border: 1px solid var(--border);
}
.btn-outline:hover { background: var(--surface-raised); }

.btn-sm {
    padding: 6px 14px;
    font-size: 0.8125rem;
}

.btn-block {
    display: flex;
    justify-content: center;
    width: 100%;
    padding: 12px 20px;
}

/* --- Alerts --- */
.alert {
    padding: 12px 16px;
    border-radius: var(--radius);
    margin-bottom: 16px;
    font-size: 0.875rem;
}

.alert-error {
    background: rgba(220, 38, 38, 0.08);
    border: 1px solid rgba(220, 38, 38, 0.2);
    color: var(--danger);
}

.alert-success {
    background: var(--success-bg);
    border: 1px solid var(--success-border);
    color: var(--success);
}

.alert-warning {
    background: var(--warning-bg);
    border: 1px solid var(--warning-border);
    color: var(--warning);
}

/* --- Dashboard Cards --- */
.group-title {
    font-size: 0.8125rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    margin-bottom: 12px;
    margin-top: 24px;
}

.group-title:first-child { margin-top: 0; }

.restaurant-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 12px;
    margin-bottom: 16px;
}

.restaurant-card {
    display: block;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    text-decoration: none;
    color: var(--text);
    transition: border-color 0.15s, box-shadow 0.15s;
}

.restaurant-card:hover {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-ring);
}

.restaurant-card h3 {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 4px;
}

.restaurant-card .card-type {
    font-size: 0.8125rem;
    color: var(--text-muted);
}

/* --- Editor Sections --- */
.section {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 24px;
    margin-bottom: 16px;
    box-shadow: var(--shadow);
    scroll-margin-top: 16px;
}

.section-title {
    font-size: 1.125rem;
    font-weight: 600;
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border);
}

/* --- Toggle / Switch --- */
.toggle-group {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 16px;
}

.toggle-label {
    font-size: 0.875rem;
    font-weight: 500;
}

.switch {
    position: relative;
    display: inline-block;
    width: 44px;
    height: 24px;
}

.switch input { opacity: 0; width: 0; height: 0; }

.switch .slider {
    position: absolute;
    inset: 0;
    background: var(--border);
    border-radius: 24px;
    cursor: pointer;
    transition: background 0.2s;
}

.switch .slider::before {
    content: '';
    position: absolute;
    width: 18px;
    height: 18px;
    left: 3px;
    bottom: 3px;
    background: #fff;
    border-radius: 50%;
    transition: transform 0.2s;
}

.switch input:checked + .slider {
    background: var(--primary);
}

.switch input:checked + .slider::before {
    transform: translateX(20px);
}

/* --- Checkbox inline --- */
.checkbox-group {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 12px;
}

.checkbox-group input[type="checkbox"] {
    width: 18px;
    height: 18px;
    accent-color: var(--primary);
}

.checkbox-group label {
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
}

/* --- Poikkeusaukioloajat (exception hours) --- */
.exception-area {
    border: 2px dotted var(--danger);
    border-radius: var(--radius);
    padding: 16px;
    background: rgba(220, 38, 38, 0.05);
    margin-top: 8px;
}

.exception-area textarea {
    border-color: var(--danger);
}

/* --- Day Cards --- */
.day-card {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px;
    margin-bottom: 12px;
}

.day-card .day-header {
    font-weight: 600;
    font-size: 0.9375rem;
    margin-bottom: 8px;
    color: var(--primary);
}

.day-card .form-group {
    margin-bottom: 8px;
}

.day-card .form-group:last-child {
    margin-bottom: 0;
}

/* --- Mode Tabs --- */
.mode-tabs {
    display: flex;
    gap: 4px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 4px;
    margin-bottom: 16px;
    width: fit-content;
}

.mode-tab {
    padding: 8px 16px;
    border: none;
    border-radius: 6px;
    background: transparent;
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    color: var(--text-muted);
    transition: all 0.15s;
}

.mode-tab.active {
    background: var(--surface);
    color: var(--text);
    box-shadow: var(--shadow);
}

/* --- Save Bar --- */
.save-bar {
    position: sticky;
    bottom: 0;
    background: var(--surface);
    border-top: 1px solid var(--border);
    padding: 16px 24px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 -2px 8px rgba(0,0,0,0.06);
    margin-top: 24px;
    border-radius: var(--radius) var(--radius) 0 0;
}

/* --- Rich Text Editor (contenteditable) --- */
.rte-toolbar {
    display: flex;
    align-items: center;
    gap: 2px;
    padding: 4px 6px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-bottom: none;
    border-radius: var(--radius) var(--radius) 0 0;
}

.rte-toolbar button {
    padding: 4px 10px;
    border: none;
    border-radius: 4px;
    background: transparent;
    font-size: 0.8125rem;
    font-weight: 600;
    cursor: pointer;
    color: var(--text-muted);
    font-family: inherit;
    line-height: 1.4;
    transition: background 0.1s, color 0.1s;
}

.rte-toolbar button:hover {
    background: var(--border);
    color: var(--text);
}

.rte-toolbar button:active {
    background: var(--primary);
    color: #fff;
}

.rte-sep {
    width: 1px;
    height: 20px;
    background: var(--border);
    margin: 0 4px;
}

.rte-editor {
    width: 100%;
    min-height: 100px;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 0 0 var(--radius) var(--radius);
    font-size: 0.9375rem;
    font-family: inherit;
    color: var(--text);
    background: var(--input-bg);
    line-height: 1.6;
    outline: none;
    transition: border-color 0.15s;
    overflow-y: auto;
}

.rte-editor:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-ring);
}

.rte-editor.rte-large {
    min-height: 200px;
}

.rte-editor:empty::before {
    content: attr(data-placeholder);
    color: var(--text-muted);
    pointer-events: none;
}

.rte-editor h2 { font-size: 1.25rem; font-weight: 600; margin: 8px 0 4px; }
.rte-editor h3 { font-size: 1.0625rem; font-weight: 600; margin: 6px 0 4px; }
.rte-editor p { margin: 4px 0; }
.rte-editor ul { margin: 4px 0; padding-left: 20px; }
.rte-editor li { margin: 2px 0; }

.rte-hidden {
    position: absolute;
    width: 0;
    height: 0;
    overflow: hidden;
    opacity: 0;
    pointer-events: none;
}

/* --- Site Footer --- */
.site-footer {
    text-align: center;
    padding: 24px 16px;
    color: var(--text-muted);
    font-size: 0.75rem;
}

/* ============================================
   Responsive
   ============================================ */
@media (min-width: 1024px) {
    .login-form-side {
        width: 50%;
        padding: 48px 80px;
    }
    .login-image-side {
        display: block;
        width: 50%;
    }
}

/* Desktop: sidebar visible, mobile header hidden */
@media (min-width: 1024px) {
    .mobile-header { display: none !important; }
}

/* Mobile: sidebar hidden, mobile header shown */
@media (max-width: 1023px) {
    .sidebar { display: none; }
    .main-content { margin-left: 0 !important; max-width: 100vw !important; }
    .mobile-header { display: flex; }
}

@media (max-width: 640px) {
    .container { padding: 16px 12px; }
    .mobile-header { padding: 10px 12px; flex-wrap: wrap; }
    .section { padding: 16px; }
    .restaurant-grid { grid-template-columns: 1fr; }
    .save-bar { padding: 12px 16px; }
    .login-form-side { padding: 32px 20px; }
}
