/* ============================================================
   Turkstech Weight Tracker - Styles
   ============================================================ */

:root {
    --primary: #0F766E;
    --primary-dark: #0B5E58;
    --primary-light: #D1FAE5;
    --accent: #F59E0B;
    --danger: #DC2626;
    --success: #10B981;
    --bg: #F8FAFC;
    --card: #FFFFFF;
    --border: #E2E8F0;
    --text: #0F172A;
    --text-muted: #64748B;
    --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.04);
    --shadow: 0 1px 3px rgba(15, 23, 42, 0.06), 0 1px 2px rgba(15, 23, 42, 0.04);
    --shadow-lg: 0 10px 25px -5px rgba(15, 23, 42, 0.08), 0 4px 10px -3px rgba(15, 23, 42, 0.04);
    --radius: 12px;
    --radius-sm: 8px;
    --radius-lg: 16px;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: 'Inter', -apple-system, system-ui, sans-serif;
    background: var(--bg);
    color: var(--text);
    font-size: 15px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

h1, h2, h3, h4 { margin: 0 0 0.5em; font-weight: 700; line-height: 1.25; }
h1 { font-size: 1.75rem; }
h2 { font-size: 1.35rem; }
h3 { font-size: 1.1rem; }

/* ===== Topbar ===== */
.topbar {
    background: white;
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 50;
}
.topbar-inner {
    max-width: 1200px;
    margin: 0 auto;
    padding: 14px 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
}
.brand {
    display: flex;
    align-items: center;
    gap: 12px;
    color: var(--text);
    text-decoration: none;
}
.brand:hover { text-decoration: none; }
.brand-mark {
    width: 42px;
    height: 42px;
    background: var(--primary);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-sm);
    font-size: 1.2rem;
}
.brand-text { display: flex; flex-direction: column; line-height: 1.1; }
.brand-text strong { font-size: 1rem; font-weight: 700; }
.brand-text small { font-size: 0.7rem; color: var(--text-muted); }

.topnav { display: flex; align-items: center; gap: 4px; }
.topnav a {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 14px;
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    font-weight: 500;
    font-size: 0.875rem;
}
.topnav a:hover { color: var(--text); background: var(--bg); text-decoration: none; }
.topnav a.active { color: var(--primary); background: var(--primary-light); }
.topnav a.logout { color: var(--text-muted); }
.topnav a.logout:hover { color: var(--danger); background: #FEE2E2; }

/* ===== Page ===== */
.page {
    max-width: 1200px;
    margin: 0 auto;
    padding: 32px 24px 80px;
}

/* ===== Cards ===== */
.card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 24px;
    box-shadow: var(--shadow-sm);
    margin-bottom: 20px;
}
.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
    gap: 12px;
}
.card-header h2 { margin: 0; }
.card-header .badge { font-size: 0.75rem; font-weight: 600; }

/* ===== Stats grid ===== */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}
.stat {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    box-shadow: var(--shadow-sm);
}
.stat-label {
    color: var(--text-muted);
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
}
.stat-value {
    font-size: 2rem;
    font-weight: 800;
    color: var(--text);
    line-height: 1;
}
.stat-suffix { font-size: 1rem; color: var(--text-muted); font-weight: 500; margin-left: 2px; }
.stat-meta { color: var(--text-muted); font-size: 0.8125rem; margin-top: 6px; }
.stat-meta.success { color: var(--success); }
.stat-meta.warning { color: var(--accent); }
.stat-meta.danger { color: var(--danger); }

/* ===== Progress bar ===== */
.progress-bar {
    height: 10px;
    background: var(--bg);
    border-radius: 999px;
    overflow: hidden;
    margin-top: 12px;
}
.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--primary), var(--success));
    border-radius: 999px;
    transition: width 0.5s ease;
}

/* ===== Badges ===== */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 600;
    background: var(--bg);
    color: var(--text-muted);
}
.badge.success { background: var(--primary-light); color: var(--primary-dark); }
.badge.warning { background: #FEF3C7; color: #92400E; }
.badge.danger { background: #FEE2E2; color: #991B1B; }

/* ===== Forms ===== */
.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 16px;
}
.form-group { display: flex; flex-direction: column; gap: 6px; }
.form-group.full { grid-column: 1 / -1; }
.form-group label {
    font-weight: 600;
    font-size: 0.8125rem;
    color: var(--text);
    display: flex;
    align-items: center;
    gap: 6px;
}
.form-group label i { color: var(--text-muted); width: 16px; }
.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-size: 0.9375rem;
    background: white;
    color: var(--text);
    transition: border 0.15s, box-shadow 0.15s;
}
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-light);
}
.form-group textarea { min-height: 80px; resize: vertical; }
.form-group .hint { font-size: 0.75rem; color: var(--text-muted); }

.checkbox-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px;
    background: var(--bg);
    border-radius: var(--radius-sm);
    cursor: pointer;
}
.checkbox-row:hover { background: var(--primary-light); }
.checkbox-row input { width: auto; margin: 0; }
.checkbox-row label { margin: 0; cursor: pointer; }

/* ===== Buttons ===== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 18px;
    border: none;
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-weight: 600;
    font-size: 0.9375rem;
    cursor: pointer;
    transition: all 0.15s;
    background: var(--primary);
    color: white;
    text-decoration: none;
}
.btn:hover { background: var(--primary-dark); text-decoration: none; }
.btn-secondary { background: var(--bg); color: var(--text); border: 1px solid var(--border); }
.btn-secondary:hover { background: white; }
.btn-block { width: 100%; }
.btn-sm { padding: 6px 12px; font-size: 0.8125rem; }

/* ===== Flash ===== */
.flash {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    margin-bottom: 20px;
    font-weight: 500;
    font-size: 0.9375rem;
}
.flash-success { background: var(--primary-light); color: var(--primary-dark); }
.flash-error { background: #FEE2E2; color: #991B1B; }

/* ===== Table ===== */
.table-wrap { overflow-x: auto; }
table.data {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.875rem;
}
table.data th, table.data td {
    padding: 12px 14px;
    text-align: left;
    border-bottom: 1px solid var(--border);
}
table.data th {
    font-weight: 600;
    color: var(--text-muted);
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}
table.data tr:hover { background: var(--bg); }

/* ===== Workout / Recipe cards ===== */
.list-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 16px;
}
.item-card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    box-shadow: var(--shadow-sm);
    transition: transform 0.15s, box-shadow 0.15s;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.item-card:hover { transform: translateY(-2px); box-shadow: var(--shadow); }
.item-card-icon {
    width: 44px;
    height: 44px;
    background: var(--primary-light);
    color: var(--primary);
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    margin-bottom: 4px;
}
.item-card h3 { margin: 0; font-size: 1rem; }
.item-card .tagline { color: var(--text-muted); font-size: 0.875rem; margin: 0; }
.item-card .item-meta {
    display: flex;
    gap: 12px;
    margin-top: 8px;
    font-size: 0.75rem;
    color: var(--text-muted);
    font-weight: 500;
}
.item-card .item-meta span { display: flex; align-items: center; gap: 4px; }

/* ===== Detail view ===== */
.detail-header {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 20px;
}
.detail-icon {
    width: 56px;
    height: 56px;
    background: var(--primary-light);
    color: var(--primary);
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.4rem;
    flex-shrink: 0;
}
.detail-header h2 { margin: 0 0 4px; }
.detail-header .tagline { color: var(--text-muted); margin: 0; }

.detail-meta {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 12px;
    padding: 16px;
    background: var(--bg);
    border-radius: var(--radius-sm);
    margin-bottom: 24px;
}
.detail-meta-item .label {
    font-size: 0.7rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-weight: 600;
}
.detail-meta-item .value {
    font-size: 1rem;
    font-weight: 700;
    color: var(--text);
    margin-top: 2px;
}

.detail-section { margin-bottom: 24px; }
.detail-section h3 {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 10px;
    font-size: 1rem;
    color: var(--primary-dark);
}
.detail-section h3 i { font-size: 0.875rem; }
.detail-section ul, .detail-section ol { padding-left: 22px; margin: 0; }
.detail-section li { margin-bottom: 6px; }
.detail-section p { margin: 0 0 10px; }

.tip-box {
    background: #FFFBEB;
    border-left: 3px solid var(--accent);
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    font-size: 0.875rem;
    color: #78350F;
}
.tip-box strong { color: #92400E; }

/* ===== Schedule ===== */
.schedule {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 8px;
    margin-bottom: 24px;
}
.schedule-day {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 12px;
    text-align: center;
}
.schedule-day .day-name {
    font-size: 0.7rem;
    text-transform: uppercase;
    color: var(--text-muted);
    font-weight: 600;
    margin-bottom: 4px;
}
.schedule-day .day-routine { font-weight: 700; font-size: 0.875rem; }
.schedule-day.today {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}
.schedule-day.today .day-name { color: rgba(255,255,255,0.8); }
.schedule-day.rest { background: var(--bg); }

/* ===== Login page ===== */
.login-wrap {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
}
.login-card {
    background: white;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    padding: 40px;
    width: 100%;
    max-width: 400px;
}
.login-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 24px;
}
.login-card h1 { margin: 0; font-size: 1.5rem; }
.login-card .subtitle { color: var(--text-muted); margin: 0 0 24px; font-size: 0.9375rem; }

/* ===== Two column layout ===== */
.two-col {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 20px;
}

/* ===== Footer ===== */
.footer {
    border-top: 1px solid var(--border);
    background: white;
    margin-top: 40px;
}
.footer-inner {
    max-width: 1200px;
    margin: 0 auto;
    padding: 16px 24px;
    display: flex;
    justify-content: space-between;
    color: var(--text-muted);
    font-size: 0.8125rem;
}

/* ===== Filter pills ===== */
.filter-pills {
    display: flex;
    gap: 8px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}
.filter-pill {
    padding: 6px 14px;
    border-radius: 999px;
    background: white;
    border: 1px solid var(--border);
    color: var(--text-muted);
    font-size: 0.8125rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s;
}
.filter-pill:hover { color: var(--text); }
.filter-pill.active { background: var(--primary); color: white; border-color: var(--primary); }

/* ===== Modal ===== */
.modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.5);
    backdrop-filter: blur(4px);
    z-index: 100;
    display: none;
    align-items: flex-start;
    justify-content: center;
    padding: 24px;
    overflow-y: auto;
}
.modal-backdrop.open { display: flex; }
.modal {
    background: white;
    border-radius: var(--radius-lg);
    max-width: 720px;
    width: 100%;
    margin-top: 5vh;
    margin-bottom: 5vh;
    box-shadow: var(--shadow-lg);
}
.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 24px;
    border-bottom: 1px solid var(--border);
}
.modal-body { padding: 24px; }
.modal-close {
    background: var(--bg);
    border: none;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    cursor: pointer;
    color: var(--text-muted);
    font-size: 0.875rem;
}
.modal-close:hover { background: var(--border); color: var(--text); }

/* ===== Chart container ===== */
.chart-wrap { position: relative; height: 360px; }

/* ===== Responsive ===== */
@media (max-width: 860px) {
    .topbar-inner { padding: 12px 16px; }
    .topnav a span { display: none; }
    .topnav a { padding: 8px 10px; }
    .brand-text small { display: none; }
    .page { padding: 20px 16px 60px; }
    .schedule { grid-template-columns: repeat(7, 1fr); gap: 4px; }
    .schedule-day { padding: 8px 4px; font-size: 0.75rem; }
    .schedule-day .day-name { font-size: 0.6rem; }
    .schedule-day .day-routine { font-size: 0.7rem; }
    .two-col { grid-template-columns: 1fr; }
    h1 { font-size: 1.4rem; }
}
