:root {
    --bg: #f8faff;
    --primary: #4f65f1;
    --primary-hover: #3e52d6;
    --accent: #f59f00;
    --text: #1f2633;
    --muted: #6b7280;
    --success: #10b981;
    --danger: #ef4444;
    --border: #e5e7eb;
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    --radius-md: 0.5rem;
    --radius-lg: 0.75rem;
    --radius-xl: 1rem;
}

* {
    box-sizing: border-box;
    font-family: 'Segoe UI', Tahoma, sans-serif;
}

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
}

.page-shell {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.page-content {
    flex: 1 0 auto;
}

.bg-gradient {
    background: linear-gradient(180deg, #dbe2f9, #fdfbff);
    padding: 20px;
}

.auth-page {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
}

.auth-container {
    width: 100%;
    max-width: 360px;
    text-align: center;
}

.app-logo {
    width: 96px;
    height: 96px;
    margin-bottom: 12px;
}

.subtitle {
    color: var(--muted);
    margin-bottom: 24px;
}

.card {
    background: #fff;
    border-radius: var(--radius-xl);
    padding: 24px;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border);
}

.card label {
    display: block;
    color: var(--muted);
    font-size: 0.9rem;
    margin-bottom: 4px;
}

.card input,
.card select {
    width: 100%;
    padding: 12px;
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
    margin-bottom: 16px;
    font-size: 1rem;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.card input:focus,
.card select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(79, 101, 241, 0.1);
}

.lowercase {
    text-transform: lowercase;
}

.admin-form label {
    display: block;
    color: var(--muted);
    font-size: 0.9rem;
    margin-bottom: 4px;
}

.admin-form input,
.admin-form select {
    width: 100%;
    padding: 10px;
    border-radius: 10px;
    border: 1px solid #e1e4ec;
    margin-bottom: 16px;
    font-size: 1rem;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    border: none;
    border-radius: var(--radius-lg);
    padding: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 1rem;
}

.btn.primary {
    background: var(--primary);
    color: white;
    box-shadow: var(--shadow-md);
}

.btn.primary:hover {
    background: var(--primary-hover);
    transform: translateY(-1px);
    box-shadow: var(--shadow-lg);
}

.btn.ghost {
    background: transparent;
    color: var(--primary);
    border: 1px solid var(--primary);
    width: auto;
    padding: 8px 16px;
}

.btn.ghost.danger {
    color: var(--danger);
    border-color: var(--danger);
}

.btn:hover {
    transform: translateY(-2px);
}

.message {
    min-height: 20px;
    font-size: 0.9rem;
}

.muted {
    color: var(--muted);
}

.app {
    flex: 1 0 auto;
    max-width: 1200px;
    margin: 0 auto;
    width: 100%;
}

.app-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px;
    background: #fff;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.06);
    position: sticky;
    top: 0;
    z-index: 10;
}

.app-header h1 {
    font-size: 1.25rem;
    margin: 0;
}

.hamburger {
    width: 42px;
    height: 42px;
    border-radius: 12px;
    border: 1px solid #e1e4ec;
    background: #fff;
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 4px;
    cursor: pointer;
}

.hamburger span {
    height: 3px;
    border-radius: 3px;
    width: 60%;
    margin: 0 auto;
    background: var(--text);
}

.side-menu {
    position: fixed;
    inset: 0 auto 0 0;
    width: 240px;
    transform: translateX(-100%);
    transition: transform 0.3s ease;
    background: #fff;
    box-shadow: 6px 0 24px rgba(0, 0, 0, 0.08);
    z-index: 20;
}

.side-menu.open {
    transform: translateX(0);
}

.side-menu-content {
    padding: 32px 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.menu-link {
    background: #f1f3ff;
    border: none;
    border-radius: 10px;
    padding: 12px;
    text-align: left;
    font-size: 1rem;
    cursor: pointer;
}

.welcome {
    color: var(--muted);
}

.badge {
    display: inline-block;
    margin-left: 8px;
    padding: 2px 8px;
    font-size: 0.75rem;
    border-radius: 999px;
    background: var(--accent);
    color: white;
}

main {
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.section {
    display: none;
    width: 100%;
}

.section.active {
    display: block;
}

.admin-forms {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.admin-form {
    flex: 1;
    border: 1px solid #eceff5;
    border-radius: 14px;
    padding: 16px;
    background: #fafaff;
}

.admin-form h3,
.admin-form h4 {
    margin-top: 0;
}

.admin-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.user-modal {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.35);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    z-index: 40;
}

.user-modal-content {
    width: min(620px, 100%);
    background: #fff;
    border-radius: 18px;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.2);
    padding: 20px;
}

.user-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
}

.close-modal {
    background: transparent;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
}

.user-modal-body {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.settings-layout {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
}

.settings-card {
    flex: 1;
    border: 1px solid #eceff5;
    border-radius: 14px;
    padding: 16px;
    background: #fafaff;
    min-width: 260px;
}

.rule-row {
    display: grid;
    grid-template-columns: 1.4fr 0.9fr auto 0.9fr auto;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
    width: 100%;
}

.rule-row strong {
    font-weight: 600;
}

.rule-row span {
    text-align: center;
    color: #4d5c7c;
}

.rule-row input {
    width: 100%;
}

@media (max-width: 640px) {
    .rule-row {
        grid-template-columns: 1fr;
        gap: 4px;
    }

    .rule-row span {
        text-align: left;
    }

    .rule-row button {
        justify-self: start;
    }
}

.holiday-list {
    margin-top: 12px;
}

.holiday-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid #eceff5;
    padding: 6px 0;
}

.hidden {
    display: none;
}

.reservations-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 12px;
}

.calendar-nav {
    display: flex;
    align-items: center;
    gap: 8px;
}

.calendar-nav #calendarLabel {
    font-weight: 600;
}

.calendar {
    display: grid;
    grid-template-columns: repeat(7, minmax(42px, 1fr));
    gap: 6px;
    margin-bottom: 16px;
}

.calendar-day {
    border: 1px solid #eceff5;
    border-radius: 10px;
    padding: 10px;
    min-height: 60px;
    position: relative;
    cursor: pointer;
    background: #f8f9ff;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

.calendar-day.calendar-day-header {
    background: transparent;
    border: none;
    cursor: default;
    font-weight: 600;
    text-align: center;
}

.calendar-day.disabled {
    background: transparent;
    border: none;
    cursor: default;
}

.calendar-day.selected {
    border-color: var(--accent);
    box-shadow: 0 0 0 2px rgba(245, 159, 0, 0.2);
}

.calendar-day.has-reservation {
    border-color: var(--primary);
    background: rgba(79, 101, 241, 0.1);
}

.calendar-day .date-number {
    font-weight: 600;
}

.calendar-day .dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--primary);
    position: absolute;
    bottom: 8px;
    right: 8px;
}

.schedule-calendar {
    margin-bottom: 16px;
}

.duration-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 16px;
}

.duration-buttons .field-label {
    width: 100%;
    margin-bottom: 8px;
    color: var(--muted);
    font-weight: 600;
}

.duration-button {
    border: 1px solid #d0d7ff;
    background: #fff;
    padding: 8px 14px;
    border-radius: 999px;
    cursor: pointer;
    font-weight: 600;
}

.duration-button.active {
    background: var(--primary);
    color: #fff;
    border-color: var(--primary);
}

.slots-container {
    min-height: 60px;
    border: 1px dashed #d7dbe8;
    border-radius: 14px;
    padding: 12px;
    margin-bottom: 12px;
}

.slot-list {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.slot-button {
    border: 1px solid #e1e4ec;
    border-radius: 999px;
    padding: 6px 12px;
    background: #fff;
    cursor: pointer;
}

.slot-button.active {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
}

.selected-info {
    padding: 10px;
    border-radius: 10px;
    background: #eef2ff;
    margin-bottom: 12px;
    font-weight: 600;
}

@media (max-width: 600px) {
    .calendar-nav {
        width: 100%;
        justify-content: space-between;
    }

    .calendar-nav .btn {
        padding: 6px 10px;
    }

    .calendar-nav #calendarLabel {
        font-size: 0.95rem;
    }

    .calendar {
        grid-template-columns: repeat(7, minmax(36px, 1fr));
        gap: 4px;
    }

    .calendar-day {
        padding: 6px;
        min-height: 48px;
        font-size: 0.8rem;
    }

    .calendar-day .date-number {
        font-size: 0.85rem;
    }
}

.reservations {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.user-list {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 12px;
    margin-bottom: 20px;
}

.user-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
    margin-bottom: 16px;
}

.user-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.user-card {
    border: 1px solid #eceff5;
    border-radius: 14px;
    padding: 14px;
    background: #fdfdfd;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.user-card h4 {
    margin: 0;
}

.user-card small {
    color: var(--muted);
}

.user-card .badge {
    margin-left: 0;
}

.reservation-card {
    background: #fefefe;
    border-radius: 14px;
    padding: 16px;
    border: 1px solid #eceff5;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.reservation-info {
    font-size: 0.95rem;
}

.status {
    font-weight: bold;
}

.status.ATIVO {
    color: var(--success);
}

.status.CANCELADO {
    color: var(--danger);
}

.overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.35);
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease;
    z-index: 15;
}

.overlay.visible {
    opacity: 1;
    visibility: visible;
}

.app-footer,
.auth-footer {
    text-align: center;
    padding: 16px;
    font-size: 0.85rem;
    color: var(--muted);
    flex-shrink: 0;
}

.toast-container {
    position: fixed;
    inset: auto 0 24px 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    pointer-events: none;
    z-index: 50;
}

.toast {
    background: #fff;
    padding: 12px 18px;
    border-radius: 999px;
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.15);
    font-weight: 600;
    color: var(--text);
    animation: fadeIn 0.3s ease;
    transition: opacity 0.3s ease, transform 0.3s ease;
}

.toast.hide {
    opacity: 0;
    transform: translateY(20px);
}

.toast.success {
    border: 1px solid rgba(44, 182, 125, 0.4);
    color: var(--success);
}

.toast.error {
    border: 1px solid rgba(242, 92, 84, 0.4);
    color: var(--danger);
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@media (min-width: 768px) {
    body {
        background: var(--bg);
    }

    .admin-forms {
        flex-direction: row;
    }
}
.slots-container .field-label {
    font-weight: 600;
    margin-bottom: 6px;
    color: var(--muted);
}
.holiday-form label {
    display: block;
    margin-bottom: 8px;
    color: var(--muted);
}

.holiday-form input {
    width: 100%;
    padding: 8px;
    border-radius: 8px;
    border: 1px solid #e1e4ec;
    margin-top: 4px;
}

.holiday-form button {
    margin-top: 8px;
}

.offline-screen {
    position: fixed;
    inset: 0;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
    background: radial-gradient(circle at top, rgba(86, 91, 249, 0.15), rgba(20, 21, 37, 0.85));
    backdrop-filter: blur(6px);
    z-index: 9999;
}

.offline-screen.visible {
    display: flex;
}

.offline-card {
    max-width: 320px;
    width: 100%;
    background: #fff;
    border-radius: 24px;
    text-align: center;
    padding: 2rem 1.5rem;
    box-shadow: 0 20px 60px rgba(20, 21, 37, 0.2);
    animation: pop-in 400ms ease-out;
}

.offline-illustration {
    font-size: 4rem;
    margin-bottom: 1rem;
    animation: floaty 3s ease-in-out infinite;
}

.offline-card h2 {
    font-size: 1.5rem;
    margin-bottom: 0.75rem;
    color: var(--text);
}

.offline-card p {
    color: var(--muted);
    margin-bottom: 1rem;
}

.offline-card .tip {
    font-size: 0.9rem;
    color: var(--muted);
}

.offline-card.wiggle {
    animation: wiggle 0.4s ease;
}

.offline-retry {
    width: 100%;
    margin-top: 0.5rem;
}

body.offline-block {
    overflow: hidden;
}

@keyframes pop-in {
    from {
        opacity: 0;
        transform: translateY(15px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

@keyframes floaty {
    0%, 100% {
        transform: translateY(0);
    }
    50% {
        transform: translateY(-10px);
    }
}

@keyframes wiggle {
    0% { transform: rotate(0deg); }
    25% { transform: rotate(-3deg); }
    50% { transform: rotate(3deg); }
    75% { transform: rotate(-2deg); }
    100% { transform: rotate(0deg); }
}
