/* Velloria Villa - Minimalist & Effective (2025) */

/* Import Inter Font */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap');

:root {
    /* Functional Palette */
    --primary: #2563eb;
    /* Blue 600 */
    --primary-dark: #1d4ed8;
    /* Blue 700 */
    --primary-light: #eff6ff;
    /* Blue 50 */

    --success: #059669;
    /* Emerald 600 */
    --success-bg: #ecfdf5;
    /* Emerald 50 */

    --danger: #dc2626;
    /* Red 600 */
    --danger-bg: #fef2f2;
    /* Red 50 */

    --warning: #d97706;
    /* Amber 600 */
    --warning-bg: #fffbeb;
    /* Amber 50 */

    /* Neutrals */
    --bg-body: #f8fafc;
    /* Slate 50 */
    --surface: #ffffff;
    /* White */
    --border: #e2e8f0;
    /* Slate 200 */

    --text-main: #0f172a;
    /* Slate 900 */
    --text-muted: #64748b;
    /* Slate 500 */
    --text-light: #94a3b8;
    /* Slate 400 */

    /* Shadows (Clean & Subtle) */
    --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);
    --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
}

* {
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

body {
    font-family: 'Inter', -apple-system, sans-serif;
    background-color: var(--bg-body);
    color: var(--text-main);
    margin: 0;
    /* Strict Mobile-First Layout */
    padding: 16px 12px;
    min-height: 100dvh;
    max-height: 100dvh;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    display: flex;
    flex-direction: column;
    align-items: center;
}

@media (min-width: 600px) {
    body {
        padding: 40px 20px;
        max-height: none;
    }
}

h1,
h2,
h3 {
    margin: 0;
    font-weight: 700;
    letter-spacing: -0.02em;
}

/* Header */
header {
    width: 100%;
    max-width: 600px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
}

header h1 {
    font-size: 1.5rem;
    color: var(--text-main);
}

@media (min-width: 600px) {
    header h1 {
        font-size: 1.8rem;
    }
}

.icon-btn,
.logout-link {
    width: 44px;
    height: 44px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--surface);
    border: 1px solid var(--border);
    color: var(--text-muted);
    transition: all 0.2s;
    cursor: pointer;
    text-decoration: none;
    padding: 0;
}

.icon-btn svg,
.logout-link svg {
    width: 24px;
    height: 24px;
    stroke-width: 2px;
}

.icon-btn:hover,
.logout-link:hover {
    border-color: var(--text-light);
    color: var(--text-main);
    box-shadow: var(--shadow-sm);
}

.logout-link {
    color: var(--danger);
    background: var(--danger-bg);
    border-color: transparent;
}

.logout-link:hover {
    background: #fee2e2;
    border-color: transparent;
}

/* Month Navigation */
.month-nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    max-width: 600px;
    margin-bottom: 32px;
}

.month-nav h2 {
    font-size: 1.25rem;
}

.month-nav a {
    text-decoration: none;
    color: var(--text-main);
    font-weight: 600;
    font-size: 0.9rem;
    padding: 10px 16px;
    border-radius: 8px;
    background: var(--surface);
    border: 1px solid var(--border);
    transition: all 0.1s ease;
}

.month-nav a:hover {
    background: var(--bg-body);
    border-color: var(--text-light);
}

@media (min-width: 600px) {
    .month-nav h2 {
        font-size: 1.5rem;
    }
}

/* Calendar */
.calendar-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    background: var(--surface);
    width: 100%;
    max-width: 600px;
    padding: 16px;
    gap: 8px;
    border-radius: 20px;
    border: 1px solid var(--border);
    box-shadow: var(--shadow-sm);
    margin-bottom: 32px;
}

@media (min-width: 600px) {
    .calendar-grid {
        padding: 24px;
        gap: 12px;
    }
}

.day-header {
    text-align: center;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding-bottom: 8px;
}

.day {
    aspect-ratio: 1;
    border-radius: 8px;
    /* Soft Square */
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.95rem;
    font-weight: 500;
    color: var(--text-main);
    cursor: default;
    position: relative;
    transition: all 0.1s;
    background: white;
    /* Explicit background */
    border: 1px solid #cbd5e1;
    /* Clearly defined border */
}

/* Hide empty placeholders */
.day:empty {
    background: transparent;
    border: none;
    cursor: default;
    pointer-events: none;
}

@media (min-width: 600px) {
    .day {
        font-size: 1rem;
        border-radius: 12px;
    }
}

/* States */
/* States */
.day.weekend {
    background-color: #fffbeb;
    /* Amber-50 */
    color: #b45309;
    /* Amber-700 */
    border-color: #fbbf24;
    /* Amber-400 */
}

.day.booked {
    background-color: #fef2f2;
    /* Red-50 */
    color: #b91c1c;
    /* Red-700 */
    font-weight: 700;
    border-color: #f87171;
    /* Red-400 */
}

.day.past {
    opacity: 1;
    /* Fully visible but distinct style */
    background-color: #f1f5f9;
    /* Slate-100 */
    color: #94a3b8;
    /* Slate-400 */
    border: 1px dashed #cbd5e1;
    /* Dashed border indicates past */
}

/* Past + Booked: Booked style takes priority (admin panel) */
.day.past.booked {
    background-color: #fef2f2;
    color: #b91c1c;
    font-weight: 700;
    border: 1px solid #f87171;
}

/* Interaction */
.day.selectable:not(.past):not(.booked):hover {
    background-color: var(--primary-light);
    color: var(--primary);
    cursor: pointer;
}

/* Selection */
.day.selected {
    background-color: var(--primary) !important;
    color: white !important;
    border-radius: 50%;
    /* Circle for selection */
    box-shadow: var(--shadow-sm);
    z-index: 2;
}

.day.in-range {
    background-color: var(--primary-light) !important;
    color: var(--primary) !important;
    border-radius: 0;
}

.day.in-range:first-of-type,
.day[data-start] {
    border-top-left-radius: 50%;
    border-bottom-left-radius: 50%;
}

.day.in-range:last-of-type,
.day[data-end] {
    border-top-right-radius: 50%;
    border-bottom-right-radius: 50%;
}

/* Legend */
.legend {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 20px;
    margin: 32px 0 64px 0;
    /* Large bottom margin for separation */
    padding: 0 10px;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.85rem;
    color: var(--text-main);
    font-weight: 600;
}

.legend-color {
    width: 14px;
    height: 14px;
    border-radius: 4px;
}

.legend-color.bg-booked {
    background: #fef2f2;
    border: 2px solid #f87171;
}

.legend-color.bg-weekend {
    background: #fffbeb;
    border: 2px solid #fbbf24;
}

.legend-color.bg-white {
    background: white;
    border: 2px solid #cbd5e1;
}

.legend-color.bg-past {
    background: #f1f5f9;
    border: 2px dashed #cbd5e1;
}


/* Modal - Clean Canvas */
.modal-overlay {
    position: fixed;
    inset: 0;
    z-index: 2000;
    background: rgba(0, 0, 0, 0.4);
    /* Simple dim */
    backdrop-filter: blur(4px);
    /* Slight blur */
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: all 0.2s ease-out;
    padding: 16px;
}

.modal-overlay.active {
    opacity: 1;
    visibility: visible;
}

.modal {
    background: var(--surface);
    width: 100%;
    max-width: 480px;
    border-radius: 20px;
    box-shadow: var(--shadow-xl);
    display: flex;
    flex-direction: column;
    overflow: hidden;

    /* Mobile Scroll Logic */
    max-height: calc(100dvh - 32px);
    transform: translateY(10px);
    transition: transform 0.2s ease-out;
}

.modal-overlay.active .modal {
    transform: translateY(0);
}

/* FIX: Propagate Flex to Form */
.modal>form {
    display: flex;
    flex-direction: column;
    flex: 1;
    /* Take full available space */
    min-height: 0;
    /* Enable internal scrolling */
    overflow: hidden;
    /* Prevent form overflow */
}

@media (min-width: 600px) {
    .modal {
        border-radius: 24px;
        max-height: 85vh;
    }
}

.modal-header {
    padding: 20px 24px;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
    background: white;
}

.modal-header span:first-child {
    font-size: 1.1rem;
    font-weight: 700;
}

.modal-header span:last-child {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    cursor: pointer;
    transition: background 0.1s;
}

.modal-header span:last-child:hover {
    background: var(--bg-body);
    color: var(--text-main);
}

.modal-body {
    padding: 24px;
    overflow-y: auto;
    flex: 1;
    min-height: 0;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-y: contain;
}

.modal-footer {
    padding: 16px 24px;
    border-top: 1px solid var(--border);
    display: flex;
    gap: 12px;
    flex-shrink: 0;
    background: #fdfdfd;
}

/* Forms */
.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 6px;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-main);
}

.form-group input,
.form-group textarea,
.form-group select {
    width: 100%;
    max-width: 100%;
    /* Ensure no overflow */
    box-sizing: border-box;
    /* Strict sizing */
    padding: 12px 16px;
    border-radius: 10px;
    border: 1px solid var(--border);
    background: white;
    font-family: inherit;
    font-size: 0.95rem;
    color: var(--text-main);
    transition: border-color 0.15s, box-shadow 0.15s;
}

.form-group input:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-light);
}

/* Stats Grid */
.stats-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-bottom: 32px;
}

@media (min-width: 600px) {
    .stats-grid {
        grid-template-columns: repeat(4, 1fr);
        gap: 16px;
    }
}

.stat-card {
    background: white;
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    box-shadow: var(--shadow-sm);
}

.stat-label {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.stat-value {
    font-size: 1.5rem;
    font-weight: 800;
    color: var(--text-main);
    line-height: 1.2;
}

.text-success {
    color: var(--success);
}

.text-danger {
    color: var(--danger);
}

/* Quick Payment Button */
.btn-quick-pay {
    background: var(--success);
    color: white;
    border: none;
    border-radius: 8px;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.15s;
    flex-shrink: 0;
}

.btn-quick-pay:hover {
    background: #047857;
    transform: scale(1.05);
}

.btn-quick-pay:active {
    transform: scale(0.95);
}

/* Date Row - Mobile First */
.date-row {
    display: grid;
    grid-template-columns: 1fr;
    gap: 12px;
    margin-bottom: 20px;
}

.date-row>div {
    display: flex;
    flex-direction: column;
}

.date-row label {
    display: block;
    margin-bottom: 6px;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-main);
}

.date-row input {
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
    padding: 12px 16px;
    border-radius: 10px;
    border: 1px solid var(--border);
    background: white;
    font-family: inherit;
    font-size: 0.95rem;
    color: var(--text-main);
    transition: border-color 0.15s, box-shadow 0.15s;

    /* iOS Safari fixes */
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    min-height: 44px;
    /* iOS minimum touch target */
}

/* iOS date input specific styling */
.date-row input[type="date"]::-webkit-date-and-time-value {
    text-align: left;
}

.date-row input[type="date"]::-webkit-calendar-picker-indicator {
    cursor: pointer;
}

.date-row input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-light);
}

@media (min-width: 600px) {
    .date-row {
        grid-template-columns: 1fr 1fr;
    }
}

.finance-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 12px;
    margin-bottom: 24px;
}

@media (min-width: 600px) {
    .finance-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

.finance-card {
    background: transparent;
    padding: 12px;
    border-radius: 12px;
    border: 1px solid var(--border);
}

.finance-card.is-price {
    background: var(--success-bg);
    border-color: #d1fae5;
}

.finance-card.is-price input,
.finance-card.is-price .finance-value {
    color: var(--success);
}

.finance-card.is-deposit {
    background: var(--primary-light);
    border-color: #dbeafe;
}

.finance-card.is-deposit input,
.finance-card.is-deposit .finance-value {
    color: var(--primary);
}

.finance-card.is-balance {
    background: var(--danger-bg);
    border-color: #fee2e2;
}

.finance-card.is-balance input,
.finance-card.is-balance .finance-value {
    color: var(--danger);
}

.finance-card label {
    margin: 0;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    color: var(--text-muted);
}

.finance-card input,
.finance-value {
    background: transparent;
    border: none;
    font-size: 1.25rem;
    font-weight: 700;
    padding: 0;
    width: 100%;
}

.finance-card input:focus {
    outline: none;
}

/* Buttons */
.btn {
    border: none;
    cursor: pointer;
    padding: 12px 20px;
    border-radius: 10px;
    font-size: 0.95rem;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s ease;
}

.btn:hover {
    opacity: 0.9;
}

.btn:active {
    transform: translateY(1px);
}

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

.btn-primary:hover {
    box-shadow: var(--shadow-md);
}

.btn-secondary {
    background: white;
    border: 1px solid var(--border);
    color: var(--text-main);
}

.btn-secondary:hover {
    background: var(--bg-body);
    border-color: var(--text-light);
}

.btn-danger {
    background: var(--danger-bg);
    color: var(--danger);
    border: 1px solid transparent;
}

.btn-danger:hover {
    background: #fee2e2;
    border-color: #fca5a5;
}

/* Quick Actions */
.btn-row {
    display: flex;
    gap: 12px;
    justify-content: center;
    margin-top: 32px;
}

.action-btn {
    width: 56px;
    height: 56px;
    border-radius: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    box-shadow: var(--shadow-sm);
    /* Lighter shadow */
    border: 1px solid transparent;
    transition: all 0.2s ease;
}

.action-btn:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.action-btn svg {
    width: 32px;
    height: 32px;
}

/* Brand Colors - White BG Style */
.bg-green {
    background-color: white;
    color: #10b981;
    /* Emerald-500 */
    border-color: #10b981;
}

.bg-green:hover {
    background-color: #ecfdf5;
}

.bg-whatsapp {
    background-color: white;
    color: #25D366;
    /* Official WhatsApp */
    border-color: #25D366;
}

.bg-whatsapp:hover {
    background-color: #f0fdf4;
}

.bg-blue {
    background-color: white;
    color: #2563eb;
    /* Blue-600 */
    border-color: #2563eb;
}

.bg-blue:hover {
    background-color: #eff6ff;
}

.bg-orange {
    background-color: white;
    color: #f59e0b;
    /* Amber-500 */
    border-color: #f59e0b;
}

.bg-orange:hover {
    background-color: #fffbeb;
}

/* Footer */
.nav-footer {
    text-align: center;
    margin-top: 40px;
    margin-bottom: 40px;
}

.nav-link {
    display: inline-block;
    color: var(--text-muted);
    font-size: 0.9rem;
    font-weight: 500;
    text-decoration: none;
    padding: 8px 16px;
    border-radius: 20px;
}

.nav-link:hover {
    color: var(--primary);
    background: white;
    box-shadow: var(--shadow-sm);
}