/* SickLog - Mobile-first PWA Styles */

:root {
    --primary: #4a90a4;
    --primary-dark: #3a7a8f;
    --danger: #dc3545;
    --danger-dark: #c82333;
    --success: #28a745;
    --warning: #ffc107;
    --bg: #f5f7fa;
    --surface: #ffffff;
    --text: #333333;
    --text-muted: #6c757d;
    --border: #dee2e6;
    --shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 4px 16px rgba(0, 0, 0, 0.15);
    --radius: 12px;
    --radius-sm: 8px;
    --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
}

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

html, body {
    font-family: var(--font);
    font-size: 16px;
    line-height: 1.5;
    color: var(--text);
    background: var(--bg);
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
}

body {
    padding-bottom: env(safe-area-inset-bottom);
}

#app {
    max-width: 600px;
    margin: 0 auto;
    min-height: 100vh;
}

.hidden {
    display: none !important;
}

/* Views */
.view {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Landing View */
#landing-view header {
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: white;
    padding: 3rem 1.5rem;
    text-align: center;
}

#landing-view h1 {
    font-size: 2.5rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
}

.subtitle {
    font-size: 1.1rem;
    opacity: 0.9;
}

.landing-content {
    padding: 1.5rem;
    flex: 1;
}

.admin-link {
    margin-top: 2rem;
    text-align: center;
}

.admin-link a {
    color: var(--text-muted);
    text-decoration: none;
    font-size: 0.9rem;
}

.admin-link a:hover {
    color: var(--primary);
}

/* Buttons */
.primary-btn, .secondary-btn, .small-btn {
    border: none;
    border-radius: var(--radius-sm);
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.primary-btn {
    background: var(--primary);
    color: white;
    padding: 1rem 1.5rem;
    width: 100%;
}

.primary-btn:hover, .primary-btn:focus {
    background: var(--primary-dark);
}

.primary-btn .icon {
    font-size: 1.5rem;
    font-weight: 300;
}

.secondary-btn {
    background: var(--surface);
    color: var(--text);
    border: 1px solid var(--border);
    padding: 0.75rem 1.25rem;
}

.secondary-btn:hover {
    background: var(--bg);
}

.small-btn {
    background: var(--bg);
    color: var(--text);
    padding: 0.4rem 0.75rem;
    font-size: 0.85rem;
    border: 1px solid var(--border);
}

.small-btn:hover {
    background: var(--border);
}

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

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

.icon-btn {
    background: transparent;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    padding: 0.5rem;
    color: var(--text);
    border-radius: var(--radius-sm);
    transition: background 0.2s;
}

.icon-btn:hover {
    background: rgba(0, 0, 0, 0.05);
}

/* Recent Logs */
.recent-logs {
    margin-top: 2rem;
}

.recent-logs h2 {
    font-size: 1.1rem;
    color: var(--text-muted);
    margin-bottom: 1rem;
    font-weight: 600;
}

#recent-logs-list {
    list-style: none;
}

.recent-log-item {
    background: var(--surface);
    border-radius: var(--radius-sm);
    padding: 1rem;
    margin-bottom: 0.75rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    box-shadow: var(--shadow);
    cursor: pointer;
    transition: transform 0.2s;
}

.recent-log-item:hover {
    transform: translateY(-2px);
}

.recent-log-item:active {
    transform: translateY(0);
}

.log-info {
    display: flex;
    flex-direction: column;
}

.log-name {
    font-weight: 600;
    font-size: 1rem;
}

.log-date {
    color: var(--text-muted);
    font-size: 0.85rem;
}

.delete-log-btn {
    font-size: 1rem;
    opacity: 0.6;
}

.delete-log-btn:hover {
    opacity: 1;
}

/* Data Management */
.data-management {
    margin-top: 2rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--border);
}

.data-management h2 {
    font-size: 1.1rem;
    color: var(--text-muted);
    margin-bottom: 1rem;
    font-weight: 600;
}

.data-actions {
    display: flex;
    gap: 0.75rem;
}

.data-actions .secondary-btn {
    flex: 1;
}

.import-label {
    cursor: pointer;
}

/* Log View */
.log-header {
    background: var(--surface);
    padding: 1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    box-shadow: var(--shadow);
    position: sticky;
    top: 0;
    z-index: 100;
}

.log-header h1 {
    flex: 1;
    font-size: 1.25rem;
    font-weight: 600;
    padding: 0.25rem 0.5rem;
    border-radius: var(--radius-sm);
    outline: none;
}

.log-header h1:focus {
    background: var(--bg);
}

/* Sync Status Indicator */
.sync-status {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.35rem 0.6rem;
    border: none;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    background: var(--bg);
    color: var(--text-muted);
}

.sync-status:hover {
    background: var(--border);
}

.sync-icon {
    font-size: 0.85rem;
}

.sync-icon.spinning {
    animation: spin 1s linear infinite;
}

@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

.sync-synced {
    background: #d4edda;
    color: #155724;
}

.sync-pending {
    background: #fff3cd;
    color: #856404;
}

.sync-syncing {
    background: #cce5ff;
    color: #004085;
}

.sync-offline {
    background: var(--bg);
    color: var(--text-muted);
}

.sync-never {
    background: var(--bg);
    color: var(--text-muted);
}

.log-content {
    padding: 1rem;
    padding-bottom: 5rem;
    flex: 1;
}

/* Groups / Episodes */
.groups-section {
    margin-bottom: 2rem;
}

.section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1rem;
}

.section-header h2 {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-muted);
}

.groups-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.group-card {
    background: var(--surface);
    border-radius: var(--radius);
    padding: 1rem;
    box-shadow: var(--shadow);
}

.group-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0.5rem;
}

.group-name {
    font-size: 1rem;
    font-weight: 600;
    outline: none;
    padding: 0.25rem;
    border-radius: 4px;
}

.group-name:focus {
    background: var(--bg);
}

.entry-count {
    font-size: 0.85rem;
    color: var(--text-muted);
}

.group-notes {
    font-size: 0.9rem;
    color: var(--text-muted);
    margin-bottom: 0.5rem;
}

.group-actions {
    display: flex;
    gap: 0.5rem;
    margin-top: 0.5rem;
}

/* Entries */
.entries-section h2 {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-muted);
    margin-bottom: 1rem;
}

.entries-list {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.entry-card {
    background: var(--surface);
    border-radius: var(--radius);
    padding: 1rem;
    box-shadow: var(--shadow);
}

.entry-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.75rem;
    flex-wrap: wrap;
}

.entry-icon {
    font-size: 1.25rem;
}

.entry-time {
    font-size: 0.9rem;
    color: var(--text-muted);
}

.entry-group-label {
    font-size: 0.75rem;
    background: var(--primary);
    color: white;
    padding: 0.2rem 0.5rem;
    border-radius: 4px;
    margin-left: auto;
}

.entry-content {
    margin-bottom: 0.75rem;
}

.entry-symptoms, .entry-actions-list {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    margin-bottom: 0.5rem;
}

.symptom-tag, .action-tag {
    background: var(--bg);
    padding: 0.25rem 0.6rem;
    border-radius: 4px;
    font-size: 0.85rem;
}

.symptom-tag {
    border-left: 3px solid var(--warning);
}

.action-tag {
    border-left: 3px solid var(--success);
}

.entry-notes {
    font-size: 0.9rem;
    color: var(--text-muted);
    margin-top: 0.5rem;
}

.severity-indicator {
    font-size: 0.85rem;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    display: inline-block;
    margin-top: 0.5rem;
}

.severity-indicator[data-level="1"],
.severity-indicator[data-level="2"],
.severity-indicator[data-level="3"] {
    background: #d4edda;
    color: #155724;
}

.severity-indicator[data-level="4"],
.severity-indicator[data-level="5"],
.severity-indicator[data-level="6"] {
    background: #fff3cd;
    color: #856404;
}

.severity-indicator[data-level="7"],
.severity-indicator[data-level="8"],
.severity-indicator[data-level="9"],
.severity-indicator[data-level="10"] {
    background: #f8d7da;
    color: #721c24;
}

.temp-reading {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.temp-value {
    font-size: 1.5rem;
    font-weight: 700;
}

.temp-status {
    font-size: 0.9rem;
    padding: 0.2rem 0.5rem;
    border-radius: 4px;
}

.temp-low {
    color: #0c5460;
}

.temp-low .temp-status {
    background: #d1ecf1;
}

.temp-normal {
    color: #155724;
}

.temp-normal .temp-status {
    background: #d4edda;
}

.temp-elevated {
    color: #856404;
}

.temp-elevated .temp-status {
    background: #fff3cd;
}

.temp-fever {
    color: #721c24;
}

.temp-fever .temp-status {
    background: #f8d7da;
}

.temp-method {
    font-size: 0.85rem;
    color: var(--text-muted);
}

.entry-actions {
    display: flex;
    gap: 0.5rem;
    border-top: 1px solid var(--border);
    padding-top: 0.75rem;
}

.empty-message {
    color: var(--text-muted);
    font-size: 0.95rem;
    text-align: center;
    padding: 2rem 1rem;
}

/* FAB */
.fab {
    position: fixed;
    bottom: 1.5rem;
    right: 1.5rem;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: var(--primary);
    color: white;
    font-size: 2rem;
    border: none;
    box-shadow: var(--shadow-lg);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s, background 0.2s;
    z-index: 90;
}

.fab:hover {
    background: var(--primary-dark);
    transform: scale(1.05);
}

.fab:active {
    transform: scale(0.95);
}

/* Modal */
.modal {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: flex-end;
    justify-content: center;
    z-index: 1000;
    padding: 1rem;
}

.modal-content {
    background: var(--surface);
    border-radius: var(--radius) var(--radius) 0 0;
    width: 100%;
    max-width: 600px;
    max-height: 90vh;
    overflow-y: auto;
    animation: slideUp 0.3s ease;
}

.modal-content.small {
    max-height: auto;
}

@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: 1rem 1.25rem;
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    background: var(--surface);
}

.modal-header h2 {
    font-size: 1.25rem;
    font-weight: 600;
}

#entry-form, #group-form {
    padding: 1.25rem;
}

.form-group {
    margin-bottom: 1.25rem;
}

.form-group label {
    display: block;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-muted);
    margin-bottom: 0.5rem;
}

.form-group input[type="text"],
.form-group input[type="datetime-local"],
.form-group input[type="number"],
.form-group textarea,
.form-group select {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 1rem;
    font-family: inherit;
    background: var(--surface);
    color: var(--text);
}

.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(74, 144, 164, 0.15);
}

.form-group textarea {
    resize: vertical;
    min-height: 80px;
}

/* Entry Type Tabs */
.entry-type-tabs {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1.25rem;
    background: var(--bg);
    padding: 0.25rem;
    border-radius: var(--radius-sm);
}

.tab-btn {
    flex: 1;
    padding: 0.6rem;
    border: none;
    background: transparent;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-muted);
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
}

.tab-btn.active {
    background: var(--surface);
    color: var(--primary);
    box-shadow: var(--shadow);
}

/* Tags */
.tags-container {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.tag {
    padding: 0.5rem 0.9rem;
    border: 1px solid var(--border);
    border-radius: 20px;
    background: var(--surface);
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.2s;
}

.tag:hover {
    border-color: var(--primary);
}

.tag.selected {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

.tag.dynamic {
    border-style: dashed;
}

/* Severity Slider */
input[type="range"] {
    width: 100%;
    height: 8px;
    -webkit-appearance: none;
    background: var(--border);
    border-radius: 4px;
    outline: none;
}

input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 24px;
    height: 24px;
    background: var(--primary);
    border-radius: 50%;
    cursor: pointer;
    box-shadow: var(--shadow);
}

.severity-labels, .temp-labels {
    display: flex;
    justify-content: space-between;
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-top: 0.5rem;
}

#severity-value {
    font-weight: 700;
    color: var(--text);
}

/* Temperature Picker */
.temperature-picker {
    text-align: center;
}

.temp-control {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    margin: 1rem 0;
}

.temp-btn {
    width: 48px;
    height: 48px;
    border: 1px solid var(--border);
    border-radius: 50%;
    background: var(--surface);
    font-size: 1.5rem;
    cursor: pointer;
    transition: all 0.2s;
}

.temp-btn:hover {
    background: var(--bg);
    border-color: var(--primary);
}

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

#temperature-value {
    width: 6.5ch;
    min-width: 110px;
    font-size: 2rem;
    font-weight: 700;
    text-align: center;
    border: none;
    background: transparent;
    -moz-appearance: textfield;
}

#temperature-value::-webkit-outer-spin-button,
#temperature-value::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

#temperature-value:focus {
    outline: none;
}

#temperature-slider {
    margin: 1rem 0;
}

.temp-indicator {
    font-weight: 600;
}

/* Form Actions */
.form-actions {
    display: flex;
    gap: 1rem;
    margin-top: 1.5rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border);
}

.form-actions .secondary-btn {
    flex: 1;
}

.form-actions .primary-btn {
    flex: 2;
}

/* Responsive */
@media (min-width: 600px) {
    .modal {
        align-items: center;
        padding: 2rem;
    }

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

/* PWA Install */
@media (display-mode: standalone) {
    body {
        padding-top: env(safe-area-inset-top);
    }
}

/* Accessibility */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        transition-duration: 0.01ms !important;
    }
}

/* Dark mode support (future) */
@media (prefers-color-scheme: dark) {
    :root {
        --bg: #1a1a2e;
        --surface: #16213e;
        --text: #eaeaea;
        --text-muted: #a0a0a0;
        --border: #2a2a4a;
    }
}
