/* === RESET & BASE === */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
    --keto: #27ae60;
    --elec: #8e44ad;
    --neuro: #2980b9;
    --antiinf: #e74c3c;
    --membrane: #d35400;
    --mito: #00b7c3;
    --general: #7f8c8d;
    --bg: #f5f6fa;
    --card-bg: #ffffff;
    --text: #2c3e50;
    --text-light: #7f8c8d;
    --border: #dfe6e9;
    --pulse-bg: #fffacd;
    --success: #27ae60;
    --progress-bg: #ecf0f1;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.4;
    min-height: 100vh;
    padding-bottom: 72px; /* space for bottom nav */
}

/* === HEADER === */
.header {
    background: var(--card-bg);
    border-bottom: 1px solid var(--border);
    padding: 12px 16px;
    text-align: center;
    position: sticky;
    top: 0;
    z-index: 100;
}

.header h1 {
    font-size: 1.1em;
    color: var(--text);
    margin-bottom: 2px;
}

.header .day-label {
    font-size: 0.85em;
    color: var(--text-light);
}

.header .day-label.pulse {
    color: #b8860b;
    font-weight: 600;
}

/* === PROGRESS BAR === */
.progress-container {
    background: var(--card-bg);
    padding: 8px 16px 12px;
    border-bottom: 1px solid var(--border);
}

.progress-bar-wrapper {
    background: var(--progress-bg);
    border-radius: 10px;
    height: 20px;
    overflow: hidden;
    position: relative;
}

.progress-bar-fill {
    background: linear-gradient(90deg, var(--success), #2ecc71);
    height: 100%;
    border-radius: 10px;
    transition: width 0.3s ease;
    min-width: 0;
}

.progress-text {
    text-align: center;
    font-size: 0.8em;
    color: var(--text-light);
    margin-top: 4px;
}

/* === TIME BLOCK SECTIONS === */
.time-block {
    margin: 8px 12px;
}

.time-block-header {
    font-size: 0.75em;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-light);
    padding: 6px 4px 4px;
}

/* === CHECKLIST ITEMS === */
.item {
    display: flex;
    align-items: center;
    background: var(--card-bg);
    border-radius: 8px;
    padding: 12px;
    margin-bottom: 6px;
    border-left: 4px solid var(--general);
    cursor: pointer;
    transition: opacity 0.2s, transform 0.1s;
    min-height: 48px;
    -webkit-tap-highlight-color: transparent;
}

.item:active {
    transform: scale(0.98);
}

.item.checked {
    opacity: 0.5;
}

.item.checked .item-name {
    text-decoration: line-through;
}

/* Category border colors */
.item.cat-keto { border-left-color: var(--keto); }
.item.cat-elec { border-left-color: var(--elec); }
.item.cat-neuro { border-left-color: var(--neuro); }
.item.cat-antiinf { border-left-color: var(--antiinf); }
.item.cat-membrane { border-left-color: var(--membrane); }
.item.cat-mito { border-left-color: var(--mito); }
.item.cat-general { border-left-color: var(--general); }

.item input[type="checkbox"] {
    width: 22px;
    height: 22px;
    margin-right: 12px;
    flex-shrink: 0;
    accent-color: var(--success);
    cursor: pointer;
}

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

.item-name {
    font-weight: 600;
    font-size: 0.95em;
}

.item-detail {
    font-size: 0.8em;
    color: var(--text-light);
    font-style: italic;
}

/* === BOTTOM NAV === */
.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--card-bg);
    border-top: 1px solid var(--border);
    display: flex;
    z-index: 100;
    padding-bottom: env(safe-area-inset-bottom, 0);
}

.nav-tab {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 8px 4px;
    text-decoration: none;
    color: var(--text-light);
    font-size: 0.7em;
    font-weight: 600;
    border: none;
    background: none;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}

.nav-tab.active {
    color: var(--neuro);
}

.nav-tab svg {
    width: 24px;
    height: 24px;
    margin-bottom: 2px;
}

/* === VIEW CONTAINERS === */
.view {
    display: none;
}

.view.active {
    display: block;
}

/* === WEEK VIEW === */
.week-grid {
    display: grid;
    gap: 8px;
    padding: 12px;
}

.week-day-card {
    background: var(--card-bg);
    border-radius: 10px;
    padding: 12px;
    border: 1px solid var(--border);
}

.week-day-card.pulse {
    background: var(--pulse-bg);
    border-color: #e6d98a;
}

.week-day-card.today {
    border-color: var(--neuro);
    border-width: 2px;
}

.week-day-name {
    font-weight: 700;
    font-size: 0.95em;
}

.week-day-label {
    font-size: 0.75em;
    color: var(--text-light);
    margin-bottom: 8px;
}

.week-day-progress {
    display: flex;
    align-items: center;
    gap: 8px;
}

.week-progress-ring {
    width: 44px;
    height: 44px;
    flex-shrink: 0;
}

.week-progress-ring circle {
    fill: none;
    stroke-width: 4;
}

.week-progress-ring .bg {
    stroke: var(--progress-bg);
}

.week-progress-ring .fill {
    stroke: var(--success);
    stroke-linecap: round;
    transition: stroke-dashoffset 0.3s;
}

.week-progress-text {
    font-size: 0.85em;
    color: var(--text-light);
}

.week-progress-count {
    font-weight: 700;
    color: var(--text);
}

/* === SETTINGS VIEW === */
.settings-container {
    padding: 12px;
    max-width: 480px;
    margin: 0 auto;
}

.settings-group {
    background: var(--card-bg);
    border-radius: 10px;
    padding: 16px;
    margin-bottom: 12px;
    border: 1px solid var(--border);
}

.settings-group h3 {
    font-size: 0.85em;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-light);
    margin-bottom: 12px;
}

.setting-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 0;
    border-bottom: 1px solid var(--border);
}

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

.setting-label {
    font-size: 0.9em;
    font-weight: 500;
}

.setting-input {
    font-size: 0.9em;
    padding: 6px 10px;
    border: 1px solid var(--border);
    border-radius: 6px;
    width: 120px;
    text-align: center;
}

/* Toggle switch */
.toggle {
    position: relative;
    width: 48px;
    height: 28px;
}

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

.toggle-slider {
    position: absolute;
    cursor: pointer;
    top: 0; left: 0; right: 0; bottom: 0;
    background: #ccc;
    border-radius: 28px;
    transition: 0.3s;
}

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

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

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

.btn {
    display: inline-block;
    padding: 10px 20px;
    border-radius: 8px;
    border: none;
    font-weight: 600;
    font-size: 0.9em;
    cursor: pointer;
    text-align: center;
    -webkit-tap-highlight-color: transparent;
}

.btn-primary {
    background: var(--neuro);
    color: white;
}

.btn-primary:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-secondary {
    background: var(--progress-bg);
    color: var(--text);
}

.btn-danger {
    background: var(--antiinf);
    color: white;
}

.btn-block {
    display: block;
    width: 100%;
}

.settings-msg {
    font-size: 0.85em;
    padding: 8px;
    border-radius: 6px;
    margin-top: 8px;
    display: none;
}

.settings-msg.success {
    display: block;
    background: #d4edda;
    color: #155724;
}

.settings-msg.error {
    display: block;
    background: #f8d7da;
    color: #721c24;
}

/* === LOGIN PAGE === */
.login-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 20px;
}

.login-card {
    background: var(--card-bg);
    border-radius: 16px;
    padding: 32px 24px;
    width: 100%;
    max-width: 320px;
    text-align: center;
    box-shadow: 0 2px 16px rgba(0,0,0,0.08);
}

.login-card h1 {
    font-size: 1.3em;
    margin-bottom: 4px;
}

.login-card p {
    color: var(--text-light);
    font-size: 0.85em;
    margin-bottom: 24px;
}

.pin-input {
    font-size: 2em;
    text-align: center;
    letter-spacing: 0.3em;
    padding: 12px;
    border: 2px solid var(--border);
    border-radius: 10px;
    width: 100%;
    margin-bottom: 16px;
    -webkit-text-security: disc;
}

.pin-input:focus {
    outline: none;
    border-color: var(--neuro);
}

.login-error {
    color: var(--antiinf);
    font-size: 0.85em;
    margin-bottom: 12px;
    display: none;
}

/* === DESKTOP RESPONSIVE === */
@media (min-width: 768px) {
    body {
        padding-bottom: 0;
    }

    .bottom-nav {
        position: static;
        max-width: 600px;
        margin: 0 auto;
        border: 1px solid var(--border);
        border-radius: 10px;
        margin-top: 8px;
        margin-bottom: 8px;
    }

    .week-grid {
        grid-template-columns: repeat(7, 1fr);
        max-width: 960px;
        margin: 0 auto;
    }

    .time-block {
        max-width: 600px;
        margin-left: auto;
        margin-right: auto;
    }

    .progress-container {
        max-width: 600px;
        margin: 0 auto;
        border: none;
    }

    .header {
        max-width: 600px;
        margin: 0 auto;
        border-radius: 0 0 10px 10px;
    }
}
