/* Garmin Sync - Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background: #f5f5f5;
    color: #333;
    line-height: 1.6;
}

.container {
    max-width: 900px;
    margin: 0 auto;
    padding: 20px;
}

/* Navigation */
.navbar {
    background: #2c3e50;
    color: white;
    padding: 0 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 50px;
}

.nav-brand {
    font-weight: bold;
    font-size: 1.1em;
}

.nav-links a {
    color: #bdc3c7;
    text-decoration: none;
    padding: 15px 10px;
    display: inline-block;
}

.nav-links a:hover,
.nav-links a.active {
    color: white;
    border-bottom: 2px solid #3498db;
}

.nav-user {
    color: #95a5a6;
    padding: 0 10px;
}

/* Cards */
.card {
    background: white;
    border-radius: 8px;
    padding: 20px;
    margin-bottom: 20px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.card h3 {
    margin-bottom: 15px;
    color: #2c3e50;
    border-bottom: 1px solid #eee;
    padding-bottom: 10px;
}

/* Forms */
.form-group {
    margin-bottom: 15px;
}

.form-group label {
    display: block;
    margin-bottom: 5px;
    font-weight: 500;
    color: #555;
}

.form-group input[type="text"],
.form-group input[type="password"],
.form-group input[type="email"],
.form-group input[type="number"],
.form-group input[type="time"],
.form-group select {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 14px;
}

.form-group input:focus,
.form-group select:focus {
    border-color: #3498db;
    outline: none;
    box-shadow: 0 0 0 2px rgba(52,152,219,0.2);
}

/* Buttons */
.btn {
    display: inline-block;
    padding: 8px 20px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    text-decoration: none;
    background: #95a5a6;
    color: white;
}

.btn-primary {
    background: #3498db;
}

.btn-primary:hover {
    background: #2980b9;
}

.btn-sm {
    padding: 4px 12px;
    font-size: 12px;
}

/* Alerts */
.alert {
    padding: 12px 16px;
    border-radius: 4px;
    margin-bottom: 15px;
}

.alert-success {
    background: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}

.alert-error {
    background: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}

.alert-warning {
    background: #fff3cd;
    color: #856404;
    border: 1px solid #ffeaa7;
}

.alert-info {
    background: #d1ecf1;
    color: #0c5460;
    border: 1px solid #bee5eb;
}

/* Badges */
.badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 12px;
    font-weight: normal;
    background: #95a5a6;
    color: white;
}

.badge-success { background: #27ae60; }
.badge-warning { background: #f39c12; }
.badge-error { background: #e74c3c; }

/* Tables - base reset */
table {
    width: 100%;
    border-collapse: collapse;
}

table td, table th {
    padding: 8px 12px;
    text-align: left;
    border-bottom: 1px solid #eee;
}

/* Key-value detail table (used in detail page, schedule page) */
.detail-table {
    border: none;
}

.detail-table td {
    padding: 14px 16px;
    border-bottom: 1px solid #f0f0f0;
    font-size: 14px;
}

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

.detail-table td:first-child {
    color: #7f8c8d;
    font-size: 13px;
    font-weight: 600;
    white-space: nowrap;
    width: 120px;
    letter-spacing: 0.02em;
}

.detail-table td:last-child {
    color: #2c3e50;
    font-weight: 500;
}

/* Data table (used in admin, activities, etc.) */
.data-table {
    border-collapse: separate;
    border-spacing: 0;
}

.data-table thead th {
    background: #f8f9fa;
    color: #666;
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    padding: 12px 16px;
    border-bottom: 2px solid #e9ecef;
    white-space: nowrap;
}

.data-table tbody td {
    padding: 12px 16px;
    font-size: 14px;
    color: #2c3e50;
    border-bottom: 1px solid #f0f2f5;
    vertical-align: middle;
}

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

.data-table tbody tr {
    transition: background 0.12s ease;
}

.data-table tbody tr:hover {
    background: #f8f9fc;
}

/* Table link */
.table-link {
    color: #3498db;
    text-decoration: none;
    font-weight: 600;
    font-size: 13px;
    padding: 4px 10px;
    border-radius: 4px;
    transition: background 0.12s ease;
}

.table-link:hover {
    background: rgba(52, 152, 219, 0.08);
    color: #2471a3;
}

/* Role badge in tables */
.role-admin {
    display: inline-flex;
    align-items: center;
    padding: 2px 10px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
    color: #8e44ad;
    background: rgba(142, 68, 173, 0.1);
    border: 1px solid rgba(142, 68, 173, 0.2);
}

.role-user {
    display: inline-flex;
    align-items: center;
    padding: 2px 10px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
    color: #2471a3;
    background: rgba(52, 152, 219, 0.1);
    border: 1px solid rgba(52, 152, 219, 0.2);
}

/* Account count badge in admin table */
.account-count {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 28px;
    height: 24px;
    padding: 0 8px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 700;
}

.account-count-full {
    color: #155724;
    background: #d4edda;
}

.account-count-partial {
    color: #856404;
    background: #fff3cd;
}

.account-count-none {
    color: #666;
    background: #f1f3f5;
}

/* records-table compat (remove later) */
.records-table thead {
    background: #f8f9fa;
}

.records-table th {
    font-weight: 600;
    color: #555;
}

/* Status colors */
.status-SUCCESS { color: #27ae60; font-weight: 600; }
.status-FAILED { color: #e74c3c; font-weight: 600; }
.status-RUNNING { color: #3498db; font-weight: 600; }
.status-SKIPPED { color: #95a5a6; font-weight: 600; }

/* Month navigation */
.month-nav {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 20px;
    margin-bottom: 20px;
}

.month-display {
    font-size: 1.2em;
    font-weight: bold;
}

/* Changelog */
.changelog-entry {
    margin-bottom: 20px;
}

.changelog-entry h4 {
    color: #2c3e50;
    margin-bottom: 8px;
}

.changelog-entry ul {
    padding-left: 20px;
}

.changelog-entry li {
    margin-bottom: 4px;
}

/* Utilities */
.text-center { text-align: center; }
.text-muted { color: #95a5a6; }

/* ==========================================
   Dashboard: Account Cards & Submit Button
   ========================================== */

/* Account card grid */
.account-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 20px;
    margin-bottom: 20px;
}

@media (max-width: 768px) {
    .account-grid {
        grid-template-columns: 1fr;
    }
}

/* Account card states */
.account-card {
    position: relative;
    overflow: hidden;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.account-card::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: transparent;
}

.card-empty {
    border-style: dashed;
    border-color: #bdc3c7;
}

.card-empty::before {
    background: #bdc3c7;
}

.card-success {
    border-color: #27ae60;
}

.card-success::before {
    background: linear-gradient(90deg, #27ae60, #2ecc71);
}

.card-editing {
    border-color: #3498db;
    box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.15);
}

.card-editing::before {
    background: linear-gradient(90deg, #3498db, #5dade2);
}

/* Card header */
.card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 15px;
}

.card-header h3 {
    border-bottom: none;
    padding-bottom: 5px;
    margin-bottom: 5px;
}

/* Region link (open Garmin website) */
.region-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 5px 12px;
    border-radius: 4px;
    border: 1px solid #ddd;
    background: #f8f9fa;
    color: #555;
    font-size: 12px;
    font-weight: 600;
    text-decoration: none;
    white-space: nowrap;
    transition: background 0.12s ease;
}

.region-link:hover {
    background: #e9ecef;
    color: #333;
}

.link-icon {
    font-size: 14px;
    line-height: 1;
}

/* Status pills */
.status-line {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-top: 4px;
}

.status-pill {
    display: inline-flex;
    align-items: center;
    padding: 2px 10px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
}

.status-saved {
    color: #155724;
    background: #d4edda;
    border: 1px solid #c3e6cb;
}

.status-editing {
    color: #1a5276;
    background: #d6eaf8;
    border: 1px solid #aed6f1;
}

.status-unconfigured {
    color: #856404;
    background: #fff3cd;
    border: 1px solid #ffeaa7;
}

/* Account summary (read-only view) */
.account-summary {
    display: grid;
    gap: 8px;
    margin-bottom: 15px;
}

.summary-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 14px;
    border-radius: 6px;
    background: #f8f9fa;
    border: 1px solid #eee;
}

.summary-label {
    color: #666;
    font-size: 13px;
    font-weight: 600;
}

.summary-value {
    color: #2c3e50;
    font-size: 14px;
    font-weight: 600;
    word-break: break-all;
}

.masked-secret {
    letter-spacing: 2px;
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}

/* Card-level alerts */
.card-alert {
    margin-bottom: 12px;
}

/* Form actions */
.form-actions {
    display: flex;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap;
    margin-top: 5px;
}

/* Submit button with loading state */
.btn-submit {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-width: 120px;
    position: relative;
}

.btn-spinner,
.btn-loading-text {
    display: none;
}

.btn-submit.is-loading .btn-label {
    display: none;
}

.btn-submit.is-loading .btn-spinner,
.btn-submit.is-loading .btn-loading-text {
    display: inline-flex;
}

.btn-submit.is-loading {
    opacity: 0.8;
    cursor: not-allowed;
}

.btn-spinner {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    border: 2px solid rgba(255, 255, 255, 0.4);
    border-top-color: #fff;
    animation: spin 0.8s linear infinite;
}

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

/* Secondary button */
.btn-secondary {
    background: #ecf0f1;
    color: #2c3e50;
}

.btn-secondary:hover {
    background: #d5dbdb;
}

/* Sync hint */
.sync-hint {
    margin-bottom: 15px;
    padding: 10px 14px;
    border-radius: 6px;
    background: #eaf2f8;
    border: 1px solid #d4e6f1;
    color: #2471a3;
    font-size: 13px;
    line-height: 1.6;
}

/* ==========================================
   Detail Grid (key-value card layout)
   ========================================== */

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

.detail-item {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 14px 16px;
    border-radius: 8px;
    background: #f8f9fa;
    border: 1px solid #eee;
}

.detail-item-wide {
    grid-column: 1 / -1;
}

.detail-item-error {
    background: #fff5f5;
    border-color: #f5c6cb;
}

.detail-label {
    color: #7f8c8d;
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.03em;
    text-transform: uppercase;
}

.detail-value {
    color: #2c3e50;
    font-size: 14px;
    font-weight: 600;
}

code {
    background: #e9ecef;
    padding: 1px 6px;
    border-radius: 4px;
    font-size: 13px;
    color: #495057;
}

@media (max-width: 768px) {
    .detail-grid {
        grid-template-columns: 1fr;
    }
}

/* ==========================================
   Records Page: Expandable Day-Grouped Table
   ========================================== */

.container-wide {
    max-width: 1200px;
}

/* Records panel */
.records-panel {
    padding: 24px;
}

.records-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 16px;
    margin-bottom: 20px;
}

.records-header h2 {
    font-size: 20px;
    font-weight: 700;
    color: #2c3e50;
    margin: 0;
}

.eyebrow {
    display: inline-block;
    margin-bottom: 6px;
    font-size: 11px;
    letter-spacing: 0.14em;
    font-weight: 700;
    color: #3498db;
    text-transform: uppercase;
}

.month-nav {
    display: flex;
    align-items: center;
    gap: 12px;
}

.current-month {
    font-size: 14px;
    font-weight: 700;
    color: #2c3e50;
    padding: 0 8px;
    min-width: 100px;
    text-align: center;
}

.btn-ghost {
    background: #f8f9fa;
    border: 1px solid #ddd;
    color: #555;
    padding: 6px 12px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 600;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
}

.btn-ghost:hover {
    background: #e9ecef;
}

.btn-small {
    padding: 5px 10px;
    font-size: 12px;
}

/* Table styles */
.table-wrap {
    overflow-x: auto;
    border-radius: 8px;
    border: 1px solid #e9ecef;
    background: #fff;
}

.table {
    width: 100%;
    border-collapse: collapse;
}

.table th,
.table td {
    padding: 12px 16px;
    border-bottom: 1px solid #e9ecef;
    text-align: left;
    font-size: 14px;
}

.table thead th {
    color: #666;
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    background: #f8f9fa;
    white-space: nowrap;
}

.table tbody tr:last-child td {
    border-bottom: 0;
}

/* Day row */
.day-row {
    cursor: default;
}

.day-row > td {
    vertical-align: middle;
}

.day-row:hover {
    background: #f8f9fa;
}

.day-date {
    font-weight: 700;
    font-size: 14px;
    color: #2c3e50;
}

.day-weekday {
    margin-left: 8px;
    font-size: 12px;
    font-weight: 600;
    color: #95a5a6;
}

/* Sync count badge */
.sync-count-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 40px;
    height: 26px;
    padding: 0 10px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
    color: #fff;
    background: linear-gradient(135deg, #3498db, #5dade2);
    box-shadow: 0 2px 6px rgba(52, 152, 219, 0.25);
}

.sync-count-zero {
    color: #95a5a6;
    font-size: 13px;
}

/* Day toggle button */
.day-toggle {
    transition: background 0.15s ease;
}

.day-toggle[aria-expanded="true"] {
    background: #e8f4fc;
    border-color: rgba(52, 152, 219, 0.3);
    color: #2980b9;
}

/* Day detail row */
.day-detail-row[hidden] {
    display: none;
}

.day-detail-cell {
    padding: 0 !important;
    background: #f8f9fa;
    border-bottom: 2px solid #ddd !important;
}

.day-detail-panel {
    padding: 16px;
}

/* Nested table */
.nested-table-wrap {
    background: #fff;
    border-radius: 6px;
}

.nested-table thead th {
    background: #f1f3f5;
    font-size: 11px;
}

.nested-table td {
    font-size: 13px;
    padding: 10px 14px;
}

/* Record time */
.record-time {
    font-size: 13px;
    font-weight: 600;
    color: #2c3e50;
    font-variant-numeric: tabular-nums;
}

.record-time-sep {
    color: #95a5a6;
    font-size: 12px;
}

.record-time-end {
    color: #7f8c8d;
}

/* Record tags */
.record-tag {
    display: inline-flex;
    align-items: center;
    min-height: 24px;
    padding: 0 10px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
    white-space: nowrap;
    border: 1px solid transparent;
}

.record-tag-manual {
    color: #2471a3;
    background: rgba(52, 152, 219, 0.1);
    border-color: rgba(52, 152, 219, 0.2);
}

.record-tag-scheduled {
    color: #1e8449;
    background: rgba(39, 174, 96, 0.1);
    border-color: rgba(39, 174, 96, 0.2);
}

.record-tag-webhook {
    color: #b7950b;
    background: rgba(241, 196, 15, 0.15);
    border-color: rgba(241, 196, 15, 0.25);
}

/* Status pills for records */
.status-ok {
    color: #155724;
    background: #d4edda;
    border: 1px solid #c3e6cb;
}

.status-fail {
    color: #856404;
    background: #fff3cd;
    border: 1px solid #ffeaa7;
}

.status-skip {
    color: #666;
    background: #f1f3f5;
    border: 1px solid #ddd;
}

.status-running {
    color: #1a5276;
    background: #d6eaf8;
    border: 1px solid #aed6f1;
}

/* Record detail row (activities) */
.record-detail-row[hidden] {
    display: none;
}

.record-detail-cell {
    padding: 0 !important;
    background: #fafbfc;
}

.record-detail-panel {
    padding: 12px 16px;
}

/* Activity table */
.activity-table thead th {
    background: #f1f3f5;
    font-size: 11px;
}

.activity-table td {
    font-size: 12px;
    padding: 8px 10px;
}

/* Record toggle */
.record-toggle[aria-expanded="true"] {
    background: #e8f4fc;
    border-color: rgba(52, 152, 219, 0.3);
    color: #2980b9;
}

/* Week separator */
.week-label-row > td {
    padding: 0 !important;
    border-bottom: none !important;
    position: relative;
    height: 28px;
    background: transparent;
}

.week-label-row > td::before {
    content: "";
    position: absolute;
    left: 16px;
    right: 16px;
    top: 50%;
    height: 1px;
    background: #ddd;
}

.week-label {
    position: relative;
    float: right;
    margin-right: 12px;
    padding: 0 8px;
    background: #fff;
    font-size: 11px;
    font-weight: 600;
    color: #95a5a6;
    letter-spacing: 0.03em;
}

.week-label-row:hover > td {
    background: transparent !important;
}

/* Empty text */
.empty-text {
    color: #95a5a6;
    font-size: 14px;
    padding: 20px 0;
}

@media (max-width: 768px) {
    .records-header {
        flex-direction: column;
    }
    .container-wide {
        max-width: 100%;
    }
}
