/* ============================================
   FokusKontrol+ — Design System
   ============================================ */

:root {
    --primary: #1B4F72;
    --primary-light: #2471A3;
    --secondary: #2E75B6;
    --accent: #3498DB;
    --accent-light: #5DADE2;

    --bg: #F4F6F8;
    --bg-card: #FFFFFF;
    --bg-header: #1B4F72;
    --bg-nav: #FFFFFF;

    --text: #2C3E50;
    --text-secondary: #7F8C8D;
    --text-light: #BDC3C7;
    --text-on-dark: #FFFFFF;

    --success: #27AE60;
    --warning: #F39C12;
    --danger: #E74C3C;
    --info: #3498DB;

    --shadow-sm: 0 1px 3px rgba(0,0,0,0.08);
    --shadow-md: 0 2px 8px rgba(0,0,0,0.1);
    --shadow-lg: 0 4px 16px rgba(0,0,0,0.12);

    --radius: 12px;
    --radius-sm: 8px;
    --radius-lg: 16px;

    --header-height: 56px;
    --nav-height: 64px;

    --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

/* ============================================
   Reset & Base
   ============================================ */

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

html {
    height: 100%;
}

html, body {
    font-family: var(--font);
    font-size: 16px;
    color: var(--text);
    background: var(--bg);
    -webkit-font-smoothing: antialiased;
    -webkit-tap-highlight-color: transparent;
    overscroll-behavior: contain;
}

body {
    min-height: 100%;
    overflow-x: hidden;
}

a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; border: none; background: none; }
input, select { font-family: inherit; font-size: inherit; }

.hidden { display: none !important; }

/* ============================================
   Header
   ============================================ */

#app-header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: var(--header-height);
    background: var(--bg-header);
    color: var(--text-on-dark);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 8px;
    z-index: 100;
    box-shadow: var(--shadow-md);
}

.header-left {
    display: flex;
    align-items: center;
    gap: 4px;
}

#header-title {
    font-size: 18px;
    font-weight: 600;
    padding-left: 8px;
}

.header-btn {
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-on-dark);
    border-radius: 50%;
    transition: background 0.2s;
}

.header-btn:active {
    background: rgba(255,255,255,0.15);
}

/* ============================================
   Bottom Navigation
   ============================================ */

#bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: var(--nav-height);
    background: var(--bg-nav);
    display: flex;
    border-top: 1px solid #E8ECF0;
    z-index: 100;
    padding-bottom: env(safe-area-inset-bottom, 0);
    box-shadow: 0 -2px 8px rgba(0,0,0,0.06);
}

.nav-tab {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    color: var(--text-secondary);
    font-size: 11px;
    font-weight: 500;
    transition: color 0.2s;
    min-height: 44px;
}

.nav-tab.active {
    color: var(--primary);
}

.nav-tab.active svg {
    stroke: var(--primary);
}

.nav-tab:active {
    background: rgba(0,0,0,0.04);
}

/* ============================================
   Main Content Area
   ============================================ */

#app-content {
    padding: calc(var(--header-height) + 16px) 16px calc(var(--nav-height) + 16px);
}

#app-content.no-nav {
    padding-bottom: 16px;
}

#app-content.no-header {
    padding-top: 16px;
}

/* ============================================
   Hamburger Menu
   ============================================ */

#menu-overlay {
    position: fixed;
    inset: 0;
    z-index: 200;
    background: rgba(0,0,0,0.5);
    opacity: 0;
    transition: opacity 0.3s;
}

#menu-overlay.visible {
    opacity: 1;
}

#menu-panel {
    position: absolute;
    right: 0;
    top: 0;
    bottom: 0;
    width: 280px;
    max-width: 85vw;
    background: #fff;
    display: flex;
    flex-direction: column;
    transform: translateX(100%);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: var(--shadow-lg);
}

#menu-overlay.visible #menu-panel {
    transform: translateX(0);
}

.menu-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid #E8ECF0;
    font-size: 18px;
    font-weight: 600;
    color: var(--primary);
}

.menu-header button {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-secondary);
}

.menu-nav {
    flex: 1;
    padding: 8px 0;
    overflow-y: auto;
}

.menu-item {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 14px 20px;
    font-size: 15px;
    color: var(--text);
    transition: background 0.15s;
}

.menu-item:active {
    background: #F0F4F8;
}

.menu-item svg {
    flex-shrink: 0;
    color: var(--text-secondary);
}

.menu-item-danger {
    color: var(--danger);
}

.menu-item-danger svg {
    color: var(--danger);
}

.menu-divider {
    height: 1px;
    background: #E8ECF0;
    margin: 4px 20px;
}

.menu-footer {
    padding: 16px 20px;
    font-size: 12px;
    color: var(--text-light);
    border-top: 1px solid #E8ECF0;
}

/* ============================================
   Cards
   ============================================ */

.card {
    background: var(--bg-card);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    padding: 16px;
    margin-bottom: 12px;
}

.card-header {
    font-size: 13px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-secondary);
    margin-bottom: 12px;
}

.card-clickable {
    cursor: pointer;
    transition: box-shadow 0.15s;
}

.card-clickable:active {
    box-shadow: var(--shadow-md);
}

/* ============================================
   Big Stat Card (Pulse, Index)
   ============================================ */

.stat-big {
    text-align: center;
    padding: 24px 16px;
}

.stat-big .stat-number {
    font-size: 48px;
    font-weight: 700;
    color: var(--primary);
    line-height: 1;
}

.stat-big .stat-label {
    font-size: 13px;
    color: var(--text-secondary);
    margin-top: 4px;
}

.stat-big .stat-delta {
    font-size: 16px;
    font-weight: 600;
    margin-top: 8px;
}

/* ============================================
   Delta / Trend Badges
   ============================================ */

.delta-up { color: var(--success); }
.delta-down { color: var(--danger); }
.delta-flat { color: var(--text-secondary); }

.badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 8px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 600;
}

.badge-success { background: #E8F8EF; color: var(--success); }
.badge-danger { background: #FDEDEC; color: var(--danger); }
.badge-warning { background: #FEF5E7; color: var(--warning); }
.badge-info { background: #EBF5FB; color: var(--info); }
.badge-gray { background: #F0F0F0; color: var(--text-secondary); }

/* ============================================
   Lists
   ============================================ */

.list-item {
    display: flex;
    align-items: center;
    padding: 12px 0;
    border-bottom: 1px solid #F0F2F5;
    gap: 12px;
    min-height: 56px;
}

.list-item:last-child {
    border-bottom: none;
}

.list-item-content {
    flex: 1;
    min-width: 0;
}

.list-item-title {
    font-size: 15px;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.list-item-subtitle {
    font-size: 13px;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.list-item-right {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 2px;
    flex-shrink: 0;
}

/* ============================================
   Buttons
   ============================================ */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 24px;
    border-radius: var(--radius-sm);
    font-size: 15px;
    font-weight: 600;
    min-height: 48px;
    transition: background 0.15s, opacity 0.15s;
}

.btn:active { opacity: 0.8; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-primary {
    background: var(--primary);
    color: white;
}

.btn-secondary {
    background: #E8ECF0;
    color: var(--text);
}

.btn-accent {
    background: var(--accent);
    color: white;
}

.btn-outline {
    border: 2px solid var(--primary);
    color: var(--primary);
    background: transparent;
}

.btn-block {
    display: flex;
    width: 100%;
}

.btn-sm {
    padding: 8px 16px;
    font-size: 13px;
    min-height: 36px;
}

/* ============================================
   Tab Bar (filter tabs)
   ============================================ */

.tab-bar {
    display: flex;
    background: #E8ECF0;
    border-radius: var(--radius-sm);
    padding: 3px;
    margin-bottom: 16px;
}

.tab-btn {
    flex: 1;
    padding: 8px 16px;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 500;
    text-align: center;
    color: var(--text-secondary);
    transition: all 0.2s;
}

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

/* ============================================
   Forms
   ============================================ */

.form-group {
    margin-bottom: 16px;
}

.form-label {
    display: block;
    font-size: 14px;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 6px;
}

.form-input {
    width: 100%;
    padding: 12px 16px;
    border: 2px solid #E0E4E8;
    border-radius: var(--radius-sm);
    font-size: 16px;
    color: var(--text);
    background: white;
    transition: border-color 0.2s;
    outline: none;
    -webkit-appearance: none;
}

.form-input:focus {
    border-color: var(--accent);
}

.form-input::placeholder {
    color: var(--text-light);
}

.form-error {
    font-size: 13px;
    color: var(--danger);
    margin-top: 8px;
}

/* ============================================
   Login Screen
   ============================================ */

.login-screen {
    display: flex;
    flex-direction: column;
    justify-content: center;
    height: 100%;
    padding: 32px 24px;
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-light) 100%);
}

.login-logo {
    text-align: center;
    margin-bottom: 40px;
}

.login-logo h1 {
    font-size: 28px;
    font-weight: 700;
    color: white;
}

.login-logo p {
    font-size: 14px;
    color: rgba(255,255,255,0.7);
    margin-top: 8px;
}

.login-card {
    background: white;
    border-radius: var(--radius-lg);
    padding: 28px 24px;
    box-shadow: var(--shadow-lg);
}

.login-card .form-group {
    margin-bottom: 20px;
}

/* ============================================
   Live Badge
   ============================================ */

.live-badge {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 14px;
    background: #FFF5F5;
    border: 1px solid #FED7D7;
    border-radius: var(--radius-sm);
    margin-bottom: 12px;
}

.live-dot {
    width: 10px;
    height: 10px;
    background: var(--danger);
    border-radius: 50%;
    animation: livePulse 1.5s infinite;
}

@keyframes livePulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.3; }
}

.live-text {
    font-size: 14px;
    font-weight: 500;
}

.live-text strong {
    color: var(--primary);
}

/* ============================================
   Song Detail Cards (lazy-loaded blocks)
   ============================================ */

.detail-block {
    min-height: 100px;
}

.detail-block .card {
    padding: 16px;
}

.chart-container {
    position: relative;
    width: 100%;
    height: 250px;
}

.chart-container canvas {
    width: 100% !important;
    height: 100% !important;
}

/* ============================================
   Sparkline (inline SVG)
   ============================================ */

.sparkline {
    display: inline-block;
    vertical-align: middle;
}

/* ============================================
   Station Health Badges
   ============================================ */

.health-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    display: inline-block;
    flex-shrink: 0;
}

.health-green { background: var(--success); }
.health-yellow { background: var(--warning); }
.health-red { background: var(--danger); }
.health-gray { background: #CCC; }

/* ============================================
   Heatmap Grid
   ============================================ */

.heatmap-grid {
    display: grid;
    grid-template-columns: auto repeat(7, 1fr);
    gap: 2px;
    font-size: 10px;
}

.heatmap-cell {
    aspect-ratio: 1;
    border-radius: 2px;
    min-width: 20px;
}

.heatmap-label {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    padding-right: 4px;
    font-size: 10px;
    color: var(--text-secondary);
}

/* ============================================
   Horizontal Score Bars (Moj Indeks)
   ============================================ */

.score-bar-wrap {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 6px;
}

.score-bar-track {
    flex: 1;
    height: 8px;
    background: #E8ECF0;
    border-radius: 4px;
    overflow: hidden;
}

.score-bar-fill {
    height: 100%;
    border-radius: 4px;
    background: var(--accent);
    transition: width 0.4s ease;
}

.score-bar-value {
    font-size: 13px;
    font-weight: 600;
    color: var(--text);
    min-width: 60px;
    text-align: right;
}

/* ============================================
   Catalog Health Colors
   ============================================ */

.health-active { border-left: 4px solid var(--success); }
.health-sleeping { border-left: 4px solid var(--warning); }
.health-dead { border-left: 4px solid #CCC; }

/* ============================================
   Loading & Empty States
   ============================================ */

.loading {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 40px;
    color: var(--text-secondary);
}

.spinner {
    width: 32px;
    height: 32px;
    border: 3px solid #E0E4E8;
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

.empty-state {
    text-align: center;
    padding: 48px 24px;
    color: var(--text-secondary);
}

.empty-state-icon {
    font-size: 48px;
    margin-bottom: 12px;
    opacity: 0.4;
}

.empty-state-text {
    font-size: 15px;
}

.error-state {
    text-align: center;
    padding: 32px 24px;
    color: var(--danger);
}

/* ============================================
   Notification Cards
   ============================================ */

.notif-card {
    display: flex;
    gap: 12px;
    align-items: flex-start;
}

.notif-icon {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    flex-shrink: 0;
}

.notif-body {
    flex: 1;
    min-width: 0;
}

.notif-title {
    font-size: 14px;
    font-weight: 500;
    line-height: 1.4;
}

.notif-time {
    font-size: 12px;
    color: var(--text-secondary);
    margin-top: 2px;
}

/* ============================================
   Favorite Star
   ============================================ */

.btn-fav {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    color: var(--text-light);
}

.btn-fav.active {
    color: var(--warning);
}

/* ============================================
   Map Container
   ============================================ */

.map-container {
    width: 100%;
    height: 300px;
    border-radius: var(--radius-sm);
    overflow: hidden;
    margin-top: 8px;
}

/* ============================================
   Responsive Tweaks
   ============================================ */

@media (min-width: 480px) {
    #app-content {
        max-width: 600px;
        margin-left: auto;
        margin-right: auto;
    }

    .login-screen {
        max-width: 400px;
        margin: 0 auto;
    }

}

/* Safe area padding for notched phones */
@supports (padding-top: env(safe-area-inset-top)) {
    #app-header {
        padding-top: env(safe-area-inset-top);
        height: calc(var(--header-height) + env(safe-area-inset-top));
    }

    #app-content {
        padding-top: calc(var(--header-height) + env(safe-area-inset-top) + 16px);
    }
}
