/* Καταγραφή Ινσουλίνης — Responsive styles */

:root {
    --color-bg: #f0f2f5;
    --color-surface: #ffffff;
    --color-text: #1a1a2e;
    --color-muted: #6b7280;
    --color-primary: #2563eb;
    --color-primary-dark: #1d4ed8;
    --color-success: #059669;
    --color-error: #dc2626;
    --color-novo: #fef3c7;
    --color-novo-border: #f59e0b;
    --color-tresiba: #d1fae5;
    --color-tresiba-border: #10b981;
    --color-meas: #dc2626;
    --radius: 12px;
    --shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    --font: 'Segoe UI', system-ui, -apple-system, sans-serif;
}

*,
*::before,
*::after {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: var(--font);
    font-size: 16px;
    line-height: 1.5;
    color: var(--color-text);
    background: var(--color-bg);
    -webkit-font-smoothing: antialiased;
}

.container {
    max-width: 1100px;
    margin: 0 auto;
    padding: 0 1rem;
}

/* Header */
.site-header {
    background: linear-gradient(135deg, #1e3a5f, #2563eb);
    color: #fff;
    padding: 1.5rem 0;
    margin-bottom: 1.5rem;
}

.site-header h1 {
    margin: 0;
    font-size: 1.5rem;
    font-weight: 700;
}

.subtitle {
    margin: 0.25rem 0 0;
    opacity: 0.85;
    font-size: 0.95rem;
}

/* Cards */
.card {
    background: var(--color-surface);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 1.25rem;
    margin-bottom: 1.25rem;
}

.card h2 {
    margin: 0 0 1rem;
    font-size: 1.15rem;
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.card-header h2 {
    margin: 0;
}

/* Alerts */
.alert {
    padding: 0.875rem 1rem;
    border-radius: 8px;
    margin-bottom: 1rem;
    font-weight: 500;
}

.alert-success {
    background: #d1fae5;
    color: #065f46;
    border: 1px solid #6ee7b7;
}

.alert-error {
    background: #fee2e2;
    color: #991b1b;
    border: 1px solid #fca5a5;
}

/* Form */
.entry-form fieldset {
    border: none;
    margin: 0 0 1rem;
    padding: 1rem;
    border-radius: var(--radius);
}

.insulin-section legend {
    font-weight: 700;
    font-size: 1rem;
    padding: 0 0.5rem;
}

.insulin-section.novo {
    background: var(--color-novo);
    border: 2px solid var(--color-novo-border);
}

.insulin-section.tresiba {
    background: var(--color-tresiba);
    border: 2px solid var(--color-tresiba-border);
}

.date-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
    margin-bottom: 1rem;
}

.field {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.field label {
    font-weight: 600;
    font-size: 0.9rem;
}

.optional {
    font-weight: 400;
    color: var(--color-muted);
    font-size: 0.85rem;
}

.day-badge {
    display: flex;
    align-items: center;
    height: 48px;
    padding: 0 1rem;
    background: #e5e7eb;
    border-radius: 8px;
    font-weight: 700;
    font-size: 1.1rem;
}

input[type="date"],
input[type="number"],
input[type="text"] {
    width: 100%;
    padding: 0.75rem 1rem;
    font-size: 1.1rem;
    border: 2px solid #d1d5db;
    border-radius: 8px;
    background: #fff;
    transition: border-color 0.15s;
}

input:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

.time-slots {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1rem;
}

.tresiba-slots {
    grid-template-columns: repeat(2, 1fr);
}

.time-slot h3 {
    margin: 0 0 0.5rem;
    font-size: 0.95rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.field-pair {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.5rem;
}

.hint {
    margin: 0.75rem 0 0;
    font-size: 0.85rem;
    color: var(--color-muted);
}

.form-actions {
    margin-top: 1rem;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.75rem 1.5rem;
    font-size: 1rem;
    font-weight: 600;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    text-decoration: none;
    transition: background 0.15s, transform 0.1s;
    min-height: 48px;
}

.btn:active {
    transform: scale(0.98);
}

.btn-primary {
    background: var(--color-primary);
    color: #fff;
    width: 100%;
}

.btn-primary:hover {
    background: var(--color-primary-dark);
}

.btn-secondary {
    background: #e5e7eb;
    color: var(--color-text);
}

.btn-secondary:hover {
    background: #d1d5db;
}

.btn-sm {
    padding: 0.4rem 0.75rem;
    font-size: 0.85rem;
    min-height: auto;
}

/* Dose scale table */
.scale-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.95rem;
}

.scale-table th,
.scale-table td {
    padding: 0.5rem 0.75rem;
    text-align: left;
    border-bottom: 1px solid #e5e7eb;
}

.scale-table th {
    background: #f9fafb;
    font-weight: 600;
}

.scale-table td:last-child {
    font-weight: 700;
    text-align: center;
    width: 80px;
}

/* History table (desktop) */
.history-table-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.history-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
    white-space: nowrap;
}

.history-table th,
.history-table td {
    padding: 0.5rem 0.4rem;
    text-align: center;
    border: 1px solid #e5e7eb;
}

.history-table thead th {
    background: #f3f4f6;
    font-weight: 600;
    font-size: 0.75rem;
}

.history-table .col-novo {
    background: #fffbeb;
}

.history-table .col-tresiba {
    background: #ecfdf5;
}

.history-table .meas {
    color: var(--color-meas);
    font-weight: 700;
}

.history-table tbody tr:hover {
    background: #f9fafb;
}

/* History cards (mobile) */
.history-cards {
    display: none;
}

.day-card {
    border: 1px solid #e5e7eb;
    border-radius: var(--radius);
    margin-bottom: 0.75rem;
    overflow: hidden;
}

.day-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 1rem;
    background: #f3f4f6;
}

.day-card-header .date {
    display: block;
    font-size: 0.85rem;
    color: var(--color-muted);
}

.day-card-section {
    padding: 0.75rem 1rem;
}

.day-card-section.novo {
    background: var(--color-novo);
}

.day-card-section.tresiba {
    background: var(--color-tresiba);
}

.day-card-section h4 {
    margin: 0 0 0.5rem;
    font-size: 0.85rem;
    text-transform: uppercase;
}

.day-card-grid {
    display: grid;
    gap: 0.35rem;
    font-size: 0.95rem;
}

.day-card-grid .lbl {
    color: var(--color-muted);
    font-size: 0.8rem;
    display: block;
}

.day-card-grid .meas {
    color: var(--color-meas);
    font-weight: 700;
}

.empty-state {
    text-align: center;
    color: var(--color-muted);
    padding: 2rem 0;
}

/* Footer */
.site-footer {
    text-align: center;
    padding: 1.5rem 0;
    color: var(--color-muted);
    font-size: 0.85rem;
}

/* Responsive */
@media (max-width: 768px) {
    .time-slots {
        grid-template-columns: 1fr;
    }

    .tresiba-slots {
        grid-template-columns: 1fr;
    }

    .history-table-wrap {
        display: none;
    }

    .history-cards {
        display: block;
    }

    .date-row {
        grid-template-columns: 1fr;
    }
}

@media (min-width: 769px) {
    .site-header h1 {
        font-size: 1.75rem;
    }

    .btn-primary {
        width: auto;
        min-width: 200px;
    }

    .form-actions {
        text-align: right;
    }
}

/* Auto-filled dose highlight */
.dose-input.auto-filled {
    background: #eff6ff;
    border-color: var(--color-primary);
}

/* Tresiba advice panel */
.tresiba-advice {
    margin-top: 1rem;
    padding: 1rem;
    background: rgba(255, 255, 255, 0.7);
    border: 2px solid var(--color-tresiba-border);
    border-radius: var(--radius);
}

.tresiba-advice h4 {
    margin: 0 0 0.75rem;
    font-size: 1rem;
}

.advice-summary {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.75rem;
    margin-bottom: 0.75rem;
}

.advice-stat {
    padding: 0.75rem;
    background: #fff;
    border-radius: 8px;
    border: 1px solid #d1fae5;
}

.advice-stat.highlight {
    border-color: var(--color-tresiba-border);
    background: #ecfdf5;
}

.advice-label {
    display: block;
    font-size: 0.8rem;
    color: var(--color-muted);
    margin-bottom: 0.25rem;
}

.advice-stat strong {
    font-size: 1.25rem;
}

.recommended-dose {
    color: #047857;
}

.adjustment-badge {
    display: inline-block;
    margin-left: 0.5rem;
    padding: 0.15rem 0.5rem;
    border-radius: 999px;
    font-size: 0.85rem;
    font-weight: 700;
}

.adjustment-badge.up {
    background: #fee2e2;
    color: #991b1b;
}

.adjustment-badge.down {
    background: #dbeafe;
    color: #1e40af;
}

.advice-target,
.advice-today {
    margin: 0.5rem 0;
    font-size: 0.9rem;
}

.advice-today.status-low { color: #1d4ed8; }
.advice-today.status-high { color: #b91c1c; }
.advice-today.status-target { color: #047857; }
.advice-today.status-below_target { color: #b45309; }
.advice-today.status-missing { color: var(--color-muted); }

.streak-box {
    margin: 0.75rem 0;
    font-size: 0.9rem;
}

.streak-list {
    list-style: none;
    margin: 0.5rem 0 0;
    padding: 0;
}

.streak-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.35rem 0;
    border-bottom: 1px solid #e5e7eb;
}

.streak-item:last-child {
    border-bottom: none;
}

.streak-date {
    flex: 1;
}

.streak-val {
    font-weight: 700;
    min-width: 70px;
    text-align: right;
}

.streak-item.ok .streak-val { color: #b91c1c; }
.streak-item.fail .streak-val { color: var(--color-muted); }
.streak-item.missing .streak-val { color: var(--color-muted); }

.streak-icon {
    width: 1.25rem;
    text-align: center;
    font-weight: 700;
}

.streak-item.ok .streak-icon { color: #059669; }
.streak-item.fail .streak-icon { color: #dc2626; }
.streak-item.missing .streak-icon { color: #9ca3af; }

.advice-messages {
    margin: 0.75rem 0;
    padding-left: 1.25rem;
    font-size: 0.9rem;
}

.advice-messages li {
    margin-bottom: 0.35rem;
}

#apply-tresiba-dose {
    margin-top: 0.5rem;
}

/* Tresiba rules info */
.tresiba-rules {
    margin-top: 1.5rem;
    padding-top: 1.25rem;
    border-top: 2px solid #e5e7eb;
}

.tresiba-rules h2 {
    font-size: 1.05rem;
    color: #047857;
}

.rules-baseline {
    margin: 0.5rem 0 1rem;
    padding: 0.75rem 1rem;
    background: #ecfdf5;
    border-radius: 8px;
    border: 1px solid var(--color-tresiba-border);
    font-size: 0.95rem;
    line-height: 1.6;
}

.rules-list {
    margin: 0.5rem 0;
    padding-left: 1.25rem;
    font-size: 0.95rem;
}

.rules-list li {
    margin-bottom: 0.5rem;
}

.rules-note {
    margin: 0.75rem 0 0;
    font-size: 0.85rem;
    color: var(--color-muted);
    font-style: italic;
}

@media (max-width: 768px) {
    .advice-summary {
        grid-template-columns: 1fr;
    }
}

@media (min-width: 900px) {
    .scale-card {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 1.5rem;
        align-items: start;
    }

    .scale-card > h2:first-of-type {
        grid-column: 1;
    }

    .scale-card > .scale-table {
        grid-column: 1;
    }

    .tresiba-rules {
        grid-column: 2;
        margin-top: 0;
        padding-top: 0;
        border-top: none;
        padding-left: 1.25rem;
        border-left: 2px solid #e5e7eb;
    }
}
