/* ============================================
   Health Automation Scheduler - Styles
   ============================================ */

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

:root {
    --bg-primary: #0f1117;
    --bg-secondary: #1a1d27;
    --bg-card: #1e2130;
    --bg-hover: #252839;
    --border: #2a2d3e;
    --text-primary: #e8eaed;
    --text-secondary: #9aa0b0;
    --text-muted: #5f6578;
    --accent: #6c5ce7;
    --accent-hover: #7e6ff0;
    --success: #00b894;
    --warning: #fdcb6e;
    --danger: #e17055;
    --info: #74b9ff;
    --supplement: #a29bfe;
    --exercise: #55efc4;
    --nutrition: #ffeaa7;
    --mindfulness: #dfe6e9;
    --sleep-color: #74b9ff;
    --radius: 10px;
    --radius-sm: 6px;
    --shadow: 0 2px 12px rgba(0, 0, 0, 0.3);
    --transition: 0.2s ease;
}

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

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
}

#app {
    max-width: 900px;
    margin: 0 auto;
    padding: 0 1rem 3rem;
}

/* Header */
.app-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.25rem 0;
    border-bottom: 1px solid var(--border);
    margin-bottom: 0.5rem;
}

.app-title {
    font-size: 1.35rem;
    font-weight: 700;
    background: linear-gradient(135deg, var(--accent), var(--info));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 1rem;
}

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

/* Tab Navigation */
.tab-nav {
    display: flex;
    gap: 0.25rem;
    padding: 0.75rem 0;
    border-bottom: 1px solid var(--border);
    margin-bottom: 1.5rem;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.tab-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    font-family: inherit;
    font-size: 0.875rem;
    font-weight: 500;
    padding: 0.5rem 1rem;
    border-radius: var(--radius-sm);
    cursor: pointer;
    white-space: nowrap;
    transition: all var(--transition);
}

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

.tab-btn.active {
    color: var(--accent);
    background: rgba(108, 92, 231, 0.12);
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
    animation: fadeIn 0.2s ease;
}

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

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    border: none;
    font-family: inherit;
    font-size: 0.875rem;
    font-weight: 500;
    padding: 0.6rem 1.2rem;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all var(--transition);
}

.btn-primary {
    background: var(--accent);
    color: #fff;
}

.btn-primary:hover {
    background: var(--accent-hover);
}

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

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

.btn-sm {
    padding: 0.4rem 0.8rem;
    font-size: 0.8rem;
}

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

.btn-danger:hover {
    background: rgba(225, 112, 85, 0.1);
}

.btn-group {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

/* Cards */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.25rem;
    margin-bottom: 1rem;
}

.card h3 {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 1rem;
    color: var(--text-primary);
}

/* Section Header */
.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.25rem;
}

.section-header h2 {
    font-size: 1.5rem;
    font-weight: 700;
}

/* Progress Ring */
.progress-ring-container {
    position: relative;
    width: 60px;
    height: 60px;
}

.progress-ring-bg {
    fill: none;
    stroke: var(--bg-hover);
    stroke-width: 5;
}

.progress-ring-bar {
    fill: none;
    stroke: var(--accent);
    stroke-width: 5;
    stroke-linecap: round;
    stroke-dasharray: 163.36;
    stroke-dashoffset: 163.36;
    transform: rotate(-90deg);
    transform-origin: center;
    transition: stroke-dashoffset 0.6s ease;
}

.progress-ring-text {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-primary);
}

/* Time Blocks & Tasks */
.time-block {
    margin-bottom: 1.25rem;
}

.time-block-title {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-secondary);
    padding: 0.5rem 0;
    border-bottom: 1px solid var(--border);
    margin-bottom: 0.5rem;
}

.task-list {
    list-style: none;
}

.task-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.65rem 0.75rem;
    border-radius: var(--radius-sm);
    transition: background var(--transition);
    cursor: pointer;
}

.task-item:hover {
    background: var(--bg-hover);
}

.task-item.completed {
    opacity: 0.5;
}

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

.task-checkbox {
    width: 20px;
    height: 20px;
    border: 2px solid var(--border);
    border-radius: 50%;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition);
}

.task-item.completed .task-checkbox {
    background: var(--success);
    border-color: var(--success);
}

.task-item.completed .task-checkbox::after {
    content: '';
    width: 6px;
    height: 10px;
    border: solid #fff;
    border-width: 0 2px 2px 0;
    transform: rotate(45deg) translate(-1px, -1px);
}

.task-time {
    font-size: 0.8rem;
    color: var(--text-muted);
    min-width: 45px;
    font-variant-numeric: tabular-nums;
}

.task-name {
    flex: 1;
    font-size: 0.9rem;
}

.task-category {
    font-size: 0.7rem;
    padding: 0.15rem 0.5rem;
    border-radius: 10px;
    text-transform: uppercase;
    font-weight: 600;
    letter-spacing: 0.03em;
}

.cat-supplement { background: rgba(162, 155, 254, 0.15); color: var(--supplement); }
.cat-exercise { background: rgba(85, 239, 196, 0.15); color: var(--exercise); }
.cat-nutrition { background: rgba(255, 234, 167, 0.15); color: var(--nutrition); }
.cat-mindfulness { background: rgba(223, 230, 233, 0.15); color: var(--mindfulness); }
.cat-sleep { background: rgba(116, 185, 255, 0.15); color: var(--sleep-color); }
.cat-custom { background: rgba(232, 234, 237, 0.1); color: var(--text-secondary); }

.task-delete {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 0.25rem;
    opacity: 0;
    transition: opacity var(--transition);
    font-size: 1.1rem;
}

.task-item:hover .task-delete {
    opacity: 1;
}

.task-delete:hover {
    color: var(--danger);
}

/* Quick Add */
.quick-add {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.quick-add input,
.quick-add select {
    flex: 1;
    min-width: 120px;
}

/* Forms */
.form-group {
    margin-bottom: 1rem;
}

.form-group label {
    display: block;
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 0.35rem;
}

.form-group input[type="checkbox"] {
    margin-right: 0.5rem;
    accent-color: var(--accent);
}

input[type="text"],
input[type="number"],
input[type="password"],
input[type="date"],
input[type="time"],
input[type="url"],
select,
textarea {
    width: 100%;
    padding: 0.55rem 0.75rem;
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-family: inherit;
    font-size: 0.875rem;
    transition: border-color var(--transition);
}

input:focus,
select:focus,
textarea:focus {
    outline: none;
    border-color: var(--accent);
}

select {
    cursor: pointer;
}

textarea {
    resize: vertical;
}

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

.form-help {
    font-size: 0.78rem;
    color: var(--text-muted);
    margin-top: 0.3rem;
}

.form-help a {
    color: var(--info);
}

.form-actions {
    display: flex;
    justify-content: flex-end;
    gap: 0.5rem;
    margin-top: 1.5rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border);
}

.input-with-btn {
    display: flex;
    gap: 0.5rem;
}

.input-with-btn input {
    flex: 1;
}

/* Modal */
.modal {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    padding: 1rem;
    backdrop-filter: blur(4px);
}

.modal.hidden {
    display: none;
}

.modal-content {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.5rem;
    width: 100%;
    max-width: 550px;
    max-height: 85vh;
    overflow-y: auto;
}

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

.modal-header h3 {
    font-size: 1.15rem;
}

.modal-close {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 1.5rem;
    cursor: pointer;
    padding: 0;
    line-height: 1;
}

.modal-close:hover {
    color: var(--text-primary);
}

/* Protocols */
.protocol-list {
    display: grid;
    gap: 1rem;
}

.protocol-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.25rem;
    transition: border-color var(--transition);
}

.protocol-card:hover {
    border-color: var(--text-muted);
}

.protocol-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 0.75rem;
}

.protocol-header h3 {
    font-size: 1.05rem;
    margin-bottom: 0.2rem;
}

.protocol-desc {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-bottom: 0.75rem;
}

.protocol-meta {
    font-size: 0.78rem;
    color: var(--text-muted);
}

.protocol-actions {
    display: flex;
    gap: 0.5rem;
}

.protocol-actions button {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 0.8rem;
    padding: 0.25rem 0.5rem;
    border-radius: var(--radius-sm);
    transition: all var(--transition);
}

.protocol-actions button:hover {
    color: var(--text-primary);
    background: var(--bg-hover);
}

.protocol-actions .delete-btn:hover {
    color: var(--danger);
}

.proto-items-list {
    display: grid;
    gap: 0.5rem;
}

.proto-item-row {
    display: grid;
    grid-template-columns: 1fr 80px 120px 32px;
    gap: 0.5rem;
    align-items: center;
}

.proto-item-row input,
.proto-item-row select {
    padding: 0.4rem 0.6rem;
    font-size: 0.82rem;
}

.proto-item-remove {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 1.2rem;
    padding: 0;
}

.proto-item-remove:hover {
    color: var(--danger);
}

/* Protocol category badges */
.badge {
    font-size: 0.72rem;
    padding: 0.15rem 0.5rem;
    border-radius: 10px;
    font-weight: 600;
    text-transform: uppercase;
}

.badge-longevity { background: rgba(162, 155, 254, 0.15); color: var(--supplement); }
.badge-fitness { background: rgba(85, 239, 196, 0.15); color: var(--exercise); }
.badge-nutrition { background: rgba(255, 234, 167, 0.15); color: var(--nutrition); }
.badge-sleep { background: rgba(116, 185, 255, 0.15); color: var(--sleep-color); }
.badge-cognitive { background: rgba(255, 118, 117, 0.15); color: #ff7675; }
.badge-custom { background: rgba(232, 234, 237, 0.1); color: var(--text-secondary); }

/* Biomarkers */
.biomarker-summary {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 0.75rem;
    margin-bottom: 1rem;
}

.bio-stat {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1rem;
}

.bio-stat-label {
    font-size: 0.78rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.bio-stat-value {
    font-size: 1.5rem;
    font-weight: 700;
    margin: 0.25rem 0;
}

.bio-stat-date {
    font-size: 0.72rem;
    color: var(--text-muted);
}

.bio-stat.optimal .bio-stat-value { color: var(--success); }
.bio-stat.warning .bio-stat-value { color: var(--warning); }
.bio-stat.danger .bio-stat-value { color: var(--danger); }

/* Data Table */
.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
}

.data-table th {
    text-align: left;
    font-weight: 600;
    color: var(--text-muted);
    padding: 0.6rem 0.75rem;
    border-bottom: 1px solid var(--border);
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.data-table td {
    padding: 0.6rem 0.75rem;
    border-bottom: 1px solid var(--border);
    color: var(--text-secondary);
}

.data-table tr:last-child td {
    border-bottom: none;
}

.status-optimal { color: var(--success); font-weight: 500; }
.status-normal { color: var(--text-secondary); }
.status-warning { color: var(--warning); font-weight: 500; }
.status-high { color: var(--danger); font-weight: 500; }

/* Oura Ring */
.oura-scores {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.75rem;
    margin-bottom: 1rem;
}

.score-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.25rem;
    text-align: center;
}

.score-label {
    font-size: 0.8rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-bottom: 0.5rem;
}

.score-value {
    font-size: 2rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 0.5rem;
}

.score-bar {
    height: 4px;
    background: var(--bg-hover);
    border-radius: 2px;
    overflow: hidden;
}

.score-fill {
    height: 100%;
    border-radius: 2px;
    background: var(--accent);
    transition: width 0.6s ease;
    width: 0%;
}

.detail-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 1rem;
}

.detail-item {
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
}

.detail-label {
    font-size: 0.78rem;
    color: var(--text-muted);
}

.detail-value {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-primary);
}

.trend-chart {
    display: flex;
    align-items: flex-end;
    gap: 0.5rem;
    height: 120px;
    padding-top: 1rem;
}

.trend-bar {
    flex: 1;
    background: var(--accent);
    border-radius: 4px 4px 0 0;
    min-height: 8px;
    position: relative;
    transition: height 0.4s ease;
    opacity: 0.7;
}

.trend-bar:last-child {
    opacity: 1;
}

.trend-bar .trend-label {
    position: absolute;
    bottom: -20px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 0.65rem;
    color: var(--text-muted);
    white-space: nowrap;
}

.trend-bar .trend-value {
    position: absolute;
    top: -18px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 0.7rem;
    color: var(--text-secondary);
    font-weight: 500;
}

/* Connection Status */
.connection-status {
    margin-top: 0.75rem;
    font-size: 0.85rem;
}

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

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

/* Empty States */
.empty-state {
    text-align: center;
    padding: 2rem 1rem;
    color: var(--text-muted);
}

.empty-state h3 {
    color: var(--text-secondary);
    margin: 1rem 0 0.5rem;
}

.empty-state p {
    max-width: 360px;
    margin: 0 auto 1.25rem;
    font-size: 0.9rem;
    line-height: 1.5;
}

/* Hidden utility */
.hidden {
    display: none !important;
}

/* Responsive */
@media (max-width: 600px) {
    #app {
        padding: 0 0.75rem 2rem;
    }

    .app-header {
        flex-wrap: wrap;
        gap: 0.5rem;
    }

    .tab-nav {
        gap: 0.1rem;
    }

    .tab-btn {
        padding: 0.4rem 0.7rem;
        font-size: 0.8rem;
    }

    .section-header {
        flex-wrap: wrap;
        gap: 0.75rem;
    }

    .oura-scores {
        grid-template-columns: 1fr;
    }

    .form-row {
        grid-template-columns: 1fr;
    }

    .quick-add {
        flex-direction: column;
    }

    .quick-add input,
    .quick-add select {
        min-width: 100%;
    }

    .proto-item-row {
        grid-template-columns: 1fr 70px 100px 28px;
    }

    .biomarker-summary {
        grid-template-columns: repeat(2, 1fr);
    }

    .detail-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}
