/* ===== V4: Single-page shift planner ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
    --primary: #3B82F6;
    --primary-dark: #2563EB;
    --primary-light: #EFF6FF;
    --success: #10B981;
    --success-light: #F0FDF4;
    --warning: #F59E0B;
    --warning-light: #FEF3C7;
    --danger: #EF4444;
    --danger-light: #FEE2E2;
    --gray-50: #F9FAFB;
    --gray-100: #F3F4F6;
    --gray-200: #E5E7EB;
    --gray-300: #D1D5DB;
    --gray-400: #9CA3AF;
    --gray-500: #6B7280;
    --gray-700: #374151;
    --gray-900: #111827;
    --radius: 12px;
    --radius-sm: 8px;
    --shadow: 0 1px 3px rgba(0,0,0,0.08);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.1);
    --shadow-lg: 0 8px 24px rgba(0,0,0,0.12);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--gray-50);
    color: var(--gray-900);
    line-height: 1.5;
    font-size: 16px;
    -webkit-font-smoothing: antialiased;
}

/* ===== Header ===== */
.header {
    background: white;
    border-bottom: 1px solid var(--gray-200);
    padding: 12px 16px;
    position: sticky;
    top: 0;
    z-index: 50;
}

.header-inner {
    max-width: 640px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.header-brand {
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--gray-900);
    text-decoration: none;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.header-user {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.85rem;
    color: var(--gray-500);
    font-weight: 500;
}

.user-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    display: inline-block;
}

/* ===== Container ===== */
.container {
    max-width: 640px;
    margin: 0 auto;
    padding: 16px;
}

/* ===== Hero: quien esta ahora ===== */
.hero {
    background: linear-gradient(135deg, #EFF6FF, #DBEAFE);
    border-radius: var(--radius);
    padding: 28px 20px;
    text-align: center;
    margin-bottom: 20px;
    box-shadow: var(--shadow);
}

.hero.empty {
    background: linear-gradient(135deg, #FEF3C7, #FDE68A);
}

.hero-label {
    font-size: 0.85rem;
    color: var(--gray-500);
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 8px;
}

.hero-name {
    font-size: 2rem;
    font-weight: 800;
    margin-bottom: 4px;
}

.hero-time {
    font-size: 1rem;
    color: var(--gray-500);
    font-weight: 500;
}

.hero-next {
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid rgba(0,0,0,0.08);
    font-size: 0.85rem;
    color: var(--gray-500);
}

/* ===== Day groups ===== */
.day-group {
    background: white;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    margin-bottom: 12px;
    overflow: hidden;
}

.day-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 16px;
    background: var(--gray-50);
    border-bottom: 1px solid var(--gray-100);
}

.day-header-label {
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--gray-500);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.day-group.today .day-header {
    background: #FFFBEB;
}

.day-group.today .day-header-label {
    color: #92400E;
}

.day-body {
    padding: 8px;
}

/* ===== Shift chips ===== */
.shift-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.shift-chip {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 14px;
    border-radius: var(--radius-sm);
    border-left: 4px solid;
    background: var(--gray-50);
    flex: 1;
    min-width: 140px;
    transition: background 0.15s;
}

.shift-chip.clickable {
    cursor: pointer;
}

.shift-chip.clickable:hover {
    background: var(--gray-100);
}

.shift-chip-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
}

.shift-chip-info {
    flex: 1;
    min-width: 0;
}

.shift-chip-name {
    font-size: 0.9rem;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.shift-chip-time {
    font-size: 0.8rem;
    color: var(--gray-500);
    font-weight: 500;
}

.shift-chip-note {
    font-size: 0.75rem;
    color: var(--gray-400);
    margin-top: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Free shift */
.shift-chip.free {
    background: var(--success-light);
    border-color: var(--success);
}

/* ===== Gap / overlap warnings ===== */
.shift-gap {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 8px 12px;
    margin: 4px 0;
    border-radius: var(--radius-sm);
    background: var(--warning-light);
    border: 1px dashed var(--warning);
    font-size: 0.8rem;
    color: #92400E;
    font-weight: 600;
}

.shift-gap.clickable {
    cursor: pointer;
    text-decoration: none;
    display: flex;
}

.shift-gap.clickable:hover {
    background: #FDE68A;
}

.shift-overlap {
    padding: 8px 12px;
    margin: 4px 0;
    border-radius: var(--radius-sm);
    background: var(--danger-light);
    border: 1px dashed var(--danger);
    font-size: 0.8rem;
    color: #991B1B;
    font-weight: 600;
}

.empty-day {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px;
    color: var(--gray-400);
    font-size: 0.85rem;
    font-style: italic;
}

/* ===== Buttons ===== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 8px 16px;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s;
    text-decoration: none;
    font-family: inherit;
    line-height: 1.4;
}

.btn:hover { text-decoration: none; opacity: 0.9; }
.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-success { background: var(--success); color: white; }
.btn-warning { background: var(--warning); color: white; }
.btn-danger { background: var(--danger); color: white; }
.btn-outline { background: transparent; border: 1px solid var(--gray-300); color: var(--gray-700); }
.btn-outline:hover { background: var(--gray-100); }
.btn-sm { padding: 5px 10px; font-size: 0.78rem; }
.btn-xs { padding: 3px 8px; font-size: 0.72rem; border-radius: 6px; }
.btn-block { width: 100%; }
.btn-ghost { background: none; border: none; color: var(--gray-500); padding: 6px; }
.btn-ghost:hover { color: var(--gray-900); background: var(--gray-100); }

/* ===== Modal ===== */
.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.4);
    z-index: 100;
    align-items: flex-end;
    justify-content: center;
    padding: 0;
}

.modal-overlay.active {
    display: flex;
}

.modal {
    background: white;
    width: 100%;
    max-width: 640px;
    max-height: 90vh;
    overflow-y: auto;
    border-radius: 20px 20px 0 0;
    box-shadow: var(--shadow-lg);
    animation: slideUp 0.25s ease-out;
}

@keyframes slideUp {
    from { transform: translateY(100%); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid var(--gray-100);
    position: sticky;
    top: 0;
    background: white;
    border-radius: 20px 20px 0 0;
    z-index: 1;
}

.modal-title {
    font-size: 1.1rem;
    font-weight: 700;
}

.modal-close {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: none;
    background: var(--gray-100);
    color: var(--gray-500);
    font-size: 1.2rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-close:hover { background: var(--gray-200); }

.modal-body {
    padding: 20px;
}

.modal-footer {
    display: flex;
    gap: 8px;
    padding: 16px 20px;
    border-top: 1px solid var(--gray-100);
    position: sticky;
    bottom: 0;
    background: white;
}

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

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

.form-control {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--gray-300);
    border-radius: var(--radius-sm);
    font-size: 1rem;
    font-family: inherit;
    background: white;
    transition: border-color 0.15s;
}

.form-control:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}

textarea.form-control { resize: vertical; min-height: 80px; }
select.form-control { appearance: auto; }

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

.form-hint {
    font-size: 0.78rem;
    color: var(--gray-400);
    margin-top: 4px;
}

/* Toggle switch */
.toggle-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 0;
}

.toggle {
    position: relative;
    width: 44px;
    height: 24px;
    flex-shrink: 0;
}

.toggle input { opacity: 0; width: 0; height: 0; }

.toggle-slider {
    position: absolute;
    inset: 0;
    background: var(--gray-300);
    border-radius: 12px;
    cursor: pointer;
    transition: background 0.2s;
}

.toggle-slider::before {
    content: '';
    position: absolute;
    width: 18px;
    height: 18px;
    left: 3px;
    bottom: 3px;
    background: white;
    border-radius: 50%;
    transition: transform 0.2s;
}

.toggle input:checked + .toggle-slider {
    background: var(--primary);
}

.toggle input:checked + .toggle-slider::before {
    transform: translateX(20px);
}

.toggle-label {
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--gray-700);
}

/* Duration indicator */
.duration-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 600;
    margin-top: 8px;
}

.duration-badge.ok { background: var(--success-light); color: #065F46; }
.duration-badge.warn { background: var(--warning-light); color: #92400E; }
.duration-badge.error { background: var(--danger-light); color: #991B1B; }

/* ===== Alert / Flash ===== */
.alert {
    padding: 10px 14px;
    border-radius: var(--radius-sm);
    margin-bottom: 12px;
    font-size: 0.85rem;
    font-weight: 500;
}

.alert-success { background: #D1FAE5; color: #065F46; }
.alert-error { background: #FEE2E2; color: #991B1B; }

/* ===== Login form (inline in header or modal) ===== */
.login-form {
    display: flex;
    gap: 8px;
    align-items: center;
}

.login-form .form-control {
    padding: 6px 10px;
    font-size: 0.85rem;
    width: auto;
    min-width: 0;
}

/* Login modal */
.login-modal-body {
    max-width: 360px;
    margin: 0 auto;
    padding: 40px 20px;
    text-align: center;
}

.login-modal-body h2 {
    font-size: 1.3rem;
    margin-bottom: 4px;
}

.login-modal-body .subtitle {
    color: var(--gray-500);
    font-size: 0.9rem;
    margin-bottom: 24px;
}

.login-modal-body .form-group { text-align: left; }

/* ===== Responsive ===== */
@media (min-width: 641px) {
    .modal-overlay {
        align-items: center;
        padding: 20px;
    }

    .modal {
        border-radius: var(--radius);
        max-height: 85vh;
    }

    .modal-header {
        border-radius: var(--radius) var(--radius) 0 0;
    }
}

@media (max-width: 400px) {
    .form-row {
        grid-template-columns: 1fr;
    }

    .hero-name {
        font-size: 1.6rem;
    }

    .shift-chip {
        min-width: 100%;
    }
}

/* ===== Weekend nights ===== */
.weekend-nights {
    background: white;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    margin-bottom: 20px;
    overflow: hidden;
}

.weekend-header {
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--gray-500);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 10px 16px;
    background: var(--gray-50);
    border-bottom: 1px solid var(--gray-100);
}

.weekend-list {
    padding: 4px 0;
}

.weekend-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 16px;
    border-bottom: 1px solid var(--gray-50);
    font-size: 0.9rem;
}

.weekend-row:last-child { border-bottom: none; }

.weekend-row.past {
    opacity: 0.5;
}

.weekend-row.current {
    background: #FFFBEB;
    font-weight: 600;
    opacity: 1;
}

.weekend-date {
    color: var(--gray-700);
    font-weight: 500;
    min-width: 80px;
}

.weekend-person {
    display: flex;
    align-items: center;
    gap: 6px;
    font-weight: 600;
}

.weekend-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}

.weekend-empty {
    color: var(--gray-400);
    font-style: italic;
    font-size: 0.85rem;
}

/* ===== Utility ===== */
.text-center { text-align: center; }
.text-muted { color: var(--gray-500); }
.mt-8 { margin-top: 8px; }
.mb-8 { margin-bottom: 8px; }
.hidden { display: none !important; }
