/* SunBed - Beach Management System */

:root {
    --color-primary: #0ea5e9;
    --color-primary-dark: #0284c7;
    --color-secondary: #06b6d4;
    --color-success: #22c55e;
    --color-warning: #f59e0b;
    --color-danger: #ef4444;
    --color-reserved: #a855f7;
    --color-bg: #f0f9ff;
    --color-surface: #ffffff;
    --color-text: #0f172a;
    --color-text-muted: #64748b;
    --color-border: #e2e8f0;
    --radius: 12px;
    --radius-sm: 8px;
    --shadow: 0 1px 3px rgba(0,0,0,.08), 0 4px 12px rgba(0,0,0,.04);
    --shadow-lg: 0 4px 24px rgba(0,0,0,.12);
    --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    --safe-bottom: env(safe-area-inset-bottom, 0px);
}

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

html { font-size: 16px; -webkit-text-size-adjust: 100%; }

body {
    font-family: var(--font);
    background: var(--color-bg);
    color: var(--color-text);
    line-height: 1.5;
    min-height: 100dvh;
}

a { color: var(--color-primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* Typography */
h1 { font-size: 1.75rem; font-weight: 700; letter-spacing: -0.02em; }
h2 { font-size: 1.25rem; font-weight: 600; }
h3 { font-size: 1rem; font-weight: 600; }

.text-muted { color: var(--color-text-muted); }
.text-sm { font-size: 0.875rem; }
.text-xs { font-size: 0.75rem; }

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.75rem 1.25rem;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 0.9375rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s ease;
    min-height: 44px;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}

.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-primary { background: var(--color-primary); color: #fff; }
.btn-primary:hover { background: var(--color-primary-dark); }

.btn-success { background: var(--color-success); color: #fff; }
.btn-warning { background: var(--color-warning); color: #fff; }
.btn-danger { background: var(--color-danger); color: #fff; }
.btn-outline {
    background: transparent;
    border: 2px solid var(--color-border);
    color: var(--color-text);
}
.btn-block { width: 100%; }
.alert-success.icon-row { display: flex; align-items: center; gap: 0.5rem; }
.btn-lg { padding: 1rem 1.5rem; font-size: 1.0625rem; min-height: 52px; }
.btn-sm { padding: 0.5rem 0.875rem; font-size: 0.8125rem; min-height: 36px; }

/* Forms */
.form-group { margin-bottom: 1rem; }
.form-label {
    display: block;
    font-size: 0.875rem;
    font-weight: 500;
    margin-bottom: 0.375rem;
    color: var(--color-text-muted);
}
.form-input, .form-select {
    width: 100%;
    padding: 0.75rem 1rem;
    border: 2px solid var(--color-border);
    border-radius: var(--radius-sm);
    font-size: 1rem;
    background: var(--color-surface);
    transition: border-color 0.15s;
    min-height: 44px;
}
.form-input:focus, .form-select:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(14,165,233,.15);
}

/* Cards */
.card {
    background: var(--color-surface);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 1.25rem;
}
.card + .card { margin-top: 1rem; }

/* Alerts */
.alert {
    padding: 0.875rem 1rem;
    border-radius: var(--radius-sm);
    margin-bottom: 1rem;
    font-size: 0.875rem;
}
.alert-error { background: #fef2f2; color: #b91c1c; border: 1px solid #fecaca; }
.alert-success { background: #f0fdf4; color: #15803d; border: 1px solid #bbf7d0; }

/* Stats */
.stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 1rem;
}
.stat-card {
    background: var(--color-surface);
    border-radius: var(--radius);
    padding: 1.25rem;
    box-shadow: var(--shadow);
}
.stat-value {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 2rem;
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--color-primary);
}
.stat-value .icon { color: var(--color-primary); }
.stat-label { font-size: 0.8125rem; color: var(--color-text-muted); margin-top: 0.25rem; }

/* Tables */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 0.875rem; }
th, td { padding: 0.75rem 1rem; text-align: left; border-bottom: 1px solid var(--color-border); }
th { font-weight: 600; color: var(--color-text-muted); font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.05em; }

/* Badge */
.badge {
    display: inline-block;
    padding: 0.25rem 0.625rem;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 600;
}
.badge-free { background: #dcfce7; color: #166534; }
.badge-reserved { background: #f3e8ff; color: #7e22ce; }
.badge-paid { background: #dbeafe; color: #1d4ed8; }
.badge-inactive { background: #f1f5f9; color: #64748b; }

/* Grid utilities */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0.75rem; }
.flex { display: flex; }
.flex-between { display: flex; justify-content: space-between; align-items: center; }
.gap-1 { gap: 0.5rem; }
.gap-2 { gap: 1rem; }
.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mb-2 { margin-bottom: 1rem; }
.p-2 { padding: 1rem; }

/* Owner layout */
.layout-owner { display: flex; min-height: 100dvh; }
.sidebar {
    width: 260px;
    background: #0f172a;
    color: #e2e8f0;
    padding: 1.5rem 0;
    flex-shrink: 0;
    position: fixed;
    top: 0; left: 0; bottom: 0;
    overflow-y: auto;
    z-index: 100;
}
.sidebar-brand {
    padding: 0 1.5rem 1.5rem;
    font-size: 1.375rem;
    font-weight: 800;
    color: #fff;
    letter-spacing: -0.03em;
}
.sidebar-brand span { color: var(--color-primary); }
.sidebar-nav a {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1.5rem;
    color: #94a3b8;
    font-size: 0.9375rem;
    font-weight: 500;
    transition: all 0.15s;
    text-decoration: none;
}
.sidebar-nav a:hover, .sidebar-nav a.active {
    background: rgba(255,255,255,.08);
    color: #fff;
    text-decoration: none;
}
.main-content {
    flex: 1;
    margin-left: 260px;
    padding: 2rem;
    max-width: 1200px;
}
.page-header {
    margin-bottom: 2rem;
}
.page-header h1 { margin-bottom: 0.25rem; }

@media (max-width: 768px) {
    .sidebar { display: none; }
    .main-content { margin-left: 0; padding: 1rem; }
}

/* Auth layout */
.auth-page {
    min-height: 100dvh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
    background: linear-gradient(135deg, #0ea5e9 0%, #06b6d4 50%, #22d3ee 100%);
}
.auth-card {
    width: 100%;
    max-width: 420px;
    background: var(--color-surface);
    border-radius: 16px;
    padding: 2rem;
    box-shadow: var(--shadow-lg);
}
.auth-logo {
    text-align: center;
    margin-bottom: 1.5rem;
}
.auth-logo h1 { font-size: 2rem; }
.auth-logo span { color: var(--color-primary); }
.auth-links { text-align: center; margin-top: 1.5rem; font-size: 0.875rem; }

/* Staff mobile layout */
.staff-app {
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
    padding-bottom: calc(64px + var(--safe-bottom));
}
.staff-header {
    position: sticky;
    top: 0;
    z-index: 50;
    background: var(--color-surface);
    border-bottom: 1px solid var(--color-border);
    padding: 0.75rem 1rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    box-shadow: var(--shadow);
}
.staff-header h1 { font-size: 1.125rem; flex: 1; }
.staff-back {
    width: 40px; height: 40px;
    display: flex; align-items: center; justify-content: center;
    border-radius: 50%;
    background: var(--color-bg);
    color: var(--color-text);
    text-decoration: none;
    flex-shrink: 0;
}
.staff-content { flex: 1; padding: 1rem; }

.staff-nav {
    position: fixed;
    bottom: 0; left: 0; right: 0;
    background: var(--color-surface);
    border-top: 1px solid var(--color-border);
    display: flex;
    padding-bottom: var(--safe-bottom);
    z-index: 100;
    box-shadow: 0 -2px 12px rgba(0,0,0,.06);
}
.staff-nav a {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 0.625rem 0.5rem;
    color: var(--color-text-muted);
    font-size: 0.6875rem;
    font-weight: 500;
    text-decoration: none;
    min-height: 56px;
}
.staff-nav a.active { color: var(--color-primary); }
.staff-nav-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 0.125rem;
    color: inherit;
}

/* SVG icons */
.icon {
    display: inline-block;
    vertical-align: middle;
    flex-shrink: 0;
}
.icon-inline { vertical-align: -0.125em; }
.icon-row { display: inline-flex; align-items: center; gap: 0.375rem; }
.sea-indicator { display: inline-flex; align-items: center; gap: 0.375rem; }
.history-item-icon { display: inline-flex; vertical-align: middle; margin-right: 0.25rem; }

/* PIN pad */
.pin-display {
    display: flex;
    justify-content: center;
    gap: 0.75rem;
    margin: 1.5rem 0;
}
.pin-dot {
    width: 16px; height: 16px;
    border-radius: 50%;
    border: 2px solid var(--color-border);
    transition: all 0.15s;
}
.pin-dot.filled { background: var(--color-primary); border-color: var(--color-primary); }
.pin-pad {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.75rem;
    max-width: 280px;
    margin: 0 auto;
}
.pin-key {
    aspect-ratio: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    font-weight: 600;
    background: var(--color-surface);
    border: 2px solid var(--color-border);
    border-radius: var(--radius);
    cursor: pointer;
    min-height: 64px;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
    user-select: none;
}
.pin-key:active { background: var(--color-bg); transform: scale(0.95); }

/* Sector map */
.sea-indicator {
    text-align: center;
    padding: 0.5rem;
    background: linear-gradient(to bottom, #38bdf8, #0ea5e9);
    color: #fff;
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.1em;
    text-transform: uppercase;
}
.sea-bottom { order: 99; }
.sea-left, .sea-right { writing-mode: vertical-rl; padding: 1rem 0.375rem; }

.map-toolbar {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 0.75rem;
    flex-wrap: wrap;
}
.map-search {
    flex: 1;
    min-width: 120px;
}
.date-picker { width: auto; min-width: 140px; }

.sector-grid {
    display: grid;
    gap: 4px;
    justify-content: center;
    margin: 0 auto;
}
.place-cell {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    font-size: 0.75rem;
    font-weight: 700;
    cursor: pointer;
    transition: transform 0.1s, box-shadow 0.1s;
    text-decoration: none;
    color: inherit;
    border: 2px solid transparent;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}
.place-cell:active { transform: scale(0.92); }
.place-cell.status-free { background: #dcfce7; border-color: #86efac; }
.place-cell.status-reserved { background: #f3e8ff; border-color: #c084fc; }
.place-cell.status-paid { background: #dbeafe; border-color: #60a5fa; }
.place-cell.highlight {
    animation: pulse-highlight 1s ease infinite;
    box-shadow: 0 0 0 3px var(--color-warning);
}
@keyframes pulse-highlight {
    0%, 100% { box-shadow: 0 0 0 3px var(--color-warning); }
    50% { box-shadow: 0 0 0 6px rgba(245,158,11,.4); }
}

.page-nav {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    margin-top: 1rem;
    padding: 0.5rem;
}
.page-dots { display: flex; gap: 0.375rem; }
.page-dot {
    width: 8px; height: 8px;
    border-radius: 50%;
    background: var(--color-border);
}
.page-dot.active { background: var(--color-primary); width: 24px; border-radius: 4px; }

/* Place card */
.place-card-header {
    text-align: center;
    padding: 1.5rem 1rem;
    border-radius: var(--radius);
    margin-bottom: 1rem;
    border: 2px solid transparent;
}
.place-card-header.status-free { background: #dcfce7; border-color: #86efac; }
.place-card-header.status-reserved { background: #f3e8ff; border-color: #c084fc; }
.place-card-header.status-paid { background: #dbeafe; border-color: #60a5fa; }
.place-number { font-size: 3rem; font-weight: 800; line-height: 1; }
.place-type-info { margin-top: 0.5rem; }
.place-price { font-size: 1.5rem; font-weight: 700; color: var(--color-primary); margin-top: 0.5rem; }

.action-buttons {
    display: grid;
    gap: 0.75rem;
    margin: 1.5rem 0;
}
.action-buttons .btn { font-size: 1.0625rem; }

.history-list { list-style: none; }
.history-item {
    padding: 0.75rem 0;
    border-bottom: 1px solid var(--color-border);
    font-size: 0.875rem;
}
.history-item:last-child { border-bottom: none; }

/* Sector/Beach select cards */
.select-card {
    display: block;
    background: var(--color-surface);
    border-radius: var(--radius);
    padding: 1.25rem;
    margin-bottom: 0.75rem;
    box-shadow: var(--shadow);
    text-decoration: none;
    color: inherit;
    border-left: 4px solid var(--color-primary);
    transition: transform 0.15s;
}
.select-card:active { transform: scale(0.98); }
.select-card h3 { margin-bottom: 0.25rem; }

/* Wizard steps */
.wizard-steps {
    display: flex;
    gap: 0.25rem;
    margin-bottom: 2rem;
    overflow-x: auto;
}
.wizard-step {
    flex: 1;
    min-width: 60px;
    text-align: center;
    padding: 0.5rem;
    font-size: 0.6875rem;
    color: var(--color-text-muted);
    border-bottom: 3px solid var(--color-border);
}
.wizard-step.active { color: var(--color-primary); border-color: var(--color-primary); font-weight: 600; }
.wizard-step.done { color: var(--color-success); border-color: var(--color-success); }

/* Layout editor */
.layout-grid { display: grid; gap: 2px; }
.layout-cell {
    width: 40px; height: 40px;
    border: 1px solid var(--color-border);
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.625rem;
    cursor: pointer;
}
.layout-cell.active-place { background: #dcfce7; }
.layout-cell.passage { background: #f1f5f9; }

/* Toast */
.toast {
    position: fixed;
    bottom: calc(80px + var(--safe-bottom));
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    background: #0f172a;
    color: #fff;
    padding: 0.875rem 1.5rem;
    border-radius: var(--radius);
    font-size: 0.875rem;
    font-weight: 500;
    z-index: 200;
    opacity: 0;
    transition: all 0.3s ease;
    max-width: 90vw;
    text-align: center;
}
.toast.show { transform: translateX(-50%) translateY(0); opacity: 1; }
.toast.error { background: var(--color-danger); }

/* Loading */
.spinner {
    width: 24px; height: 24px;
    border: 3px solid var(--color-border);
    border-top-color: var(--color-primary);
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.hidden { display: none !important; }

/* Admin panel */
:root {
    --color-admin: #7c3aed;
    --color-admin-dark: #6d28d9;
    --color-admin-bg: #faf5ff;
}

.layout-admin { display: flex; min-height: 100dvh; }
.sidebar-admin { background: #1e1b4b; }
.sidebar-admin .sidebar-brand span { color: #a78bfa; }

.stat-card-admin .stat-value { color: var(--color-admin); }

.btn-admin {
    background: var(--color-admin);
    color: #fff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.75rem 1.25rem;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 0.9375rem;
    font-weight: 600;
    cursor: pointer;
    min-height: 44px;
    text-decoration: none;
}
.btn-admin:hover { background: var(--color-admin-dark); color: #fff; text-decoration: none; }

.auth-page-admin {
    background: linear-gradient(135deg, #1e1b4b 0%, #4c1d95 50%, #7c3aed 100%);
}

.chart-bars { display: flex; flex-direction: column; gap: 0.625rem; }
.chart-bar-row {
    display: grid;
    grid-template-columns: 48px 1fr 64px 72px;
    align-items: center;
    gap: 0.75rem;
    font-size: 0.8125rem;
}
.chart-label { color: var(--color-text-muted); }
.chart-bar-track {
    height: 24px;
    background: var(--color-admin-bg);
    border-radius: 6px;
    overflow: hidden;
}
.chart-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--color-admin), #a78bfa);
    border-radius: 6px;
    transition: width 0.3s ease;
    min-width: 2px;
}
.chart-value { text-align: right; color: var(--color-text-muted); font-size: 0.75rem; }

.rank-list { list-style: none; }
.rank-list li {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.625rem 0;
    border-bottom: 1px solid var(--color-border);
    font-size: 0.875rem;
}
.rank-list li:last-child { border-bottom: none; }
.rank-num {
    width: 24px; height: 24px;
    background: var(--color-admin-bg);
    color: var(--color-admin);
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-size: 0.75rem; font-weight: 700;
    flex-shrink: 0;
}
.rank-value { margin-left: auto; font-weight: 600; color: var(--color-admin); }

@media (max-width: 900px) {
    .chart-bar-row { grid-template-columns: 40px 1fr 48px; }
    .chart-bar-row .chart-value:last-child { display: none; }
}

/* Language switcher */
.lang-switcher {
    display: flex;
    gap: 0.25rem;
    padding: 0 1.5rem 1rem;
}
.sidebar-admin .lang-switcher { padding: 0 1.5rem 1rem; }
.auth-card .lang-switcher { padding: 0; }
.staff-header .lang-switcher { padding: 0; margin-left: auto; }

.lang-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 36px;
    height: 32px;
    padding: 0 0.5rem;
    border-radius: 6px;
    font-size: 0.6875rem;
    font-weight: 700;
    letter-spacing: 0.05em;
    text-decoration: none;
    color: var(--color-text-muted);
    background: var(--color-bg);
    border: 1px solid var(--color-border);
    transition: all 0.15s;
}
.sidebar .lang-btn {
    background: rgba(255,255,255,.08);
    border-color: rgba(255,255,255,.15);
    color: #94a3b8;
}
.sidebar .lang-btn.active,
.sidebar .lang-btn:hover {
    background: rgba(255,255,255,.15);
    color: #fff;
    text-decoration: none;
}
.lang-btn.active {
    background: var(--color-primary);
    border-color: var(--color-primary);
    color: #fff;
}
.sidebar-admin .lang-btn.active {
    background: var(--color-admin);
    border-color: var(--color-admin);
}

