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

:root {
    --bg-main: hsl(222, 47%, 11%);
    --bg-card: hsla(223, 47%, 16%, 0.7);
    --bg-card-border: hsla(223, 47%, 25%, 0.4);
    --text-primary: hsl(210, 40%, 98%);
    --text-secondary: hsl(215, 20%, 65%);
    
    --primary: hsl(263, 90%, 51%);
    --primary-gradient: linear-gradient(135deg, hsl(263, 90%, 51%), hsl(280, 90%, 60%));
    --accent: hsl(190, 90%, 50%);
    --accent-gradient: linear-gradient(135deg, hsl(190, 90%, 50%), hsl(200, 90%, 40%));
    
    --green: hsl(145, 80%, 45%);
    --green-gradient: linear-gradient(135deg, hsl(145, 80%, 45%), hsl(150, 80%, 35%));
    --red: hsl(355, 85%, 55%);
    --red-gradient: linear-gradient(135deg, hsl(355, 85%, 55%), hsl(360, 80%, 45%));
    
    --nav-bg: hsla(223, 47%, 16%, 0.85);
    
    --shadow-soft: 0 8px 32px 0 rgba(0, 0, 0, 0.37);
    --shadow-inset: inset 0 2px 4px 0 rgba(255, 255, 255, 0.05);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

body {
    background-color: var(--bg-main);
    color: var(--text-primary);
    font-family: 'Outfit', sans-serif;
    min-height: 100vh;
    padding-bottom: 80px; /* Safe space for bottom nav */
    overflow-x: hidden;
}

/* Base Wrapper for Mobile PWA Feel */
.app-container {
    max-width: 480px; /* Force mobile viewport constraint on desktop */
    margin: 0 auto;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    padding: 16px;
}

/* Glassmorphism Card Style */
.premium-card {
    background: var(--bg-card);
    border: 1px solid var(--bg-card-border);
    border-radius: 20px;
    box-shadow: var(--shadow-soft), var(--shadow-inset);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    padding: 20px;
    margin-bottom: 16px;
    transition: transform 0.2s cubic-bezier(0.4, 0, 0.2, 1), box-shadow 0.2s ease;
}

.premium-card.clickable:active {
    transform: scale(0.98);
}

/* Headings */
h1, h2, h3, h4, h5, h6 {
    color: var(--text-primary);
    font-weight: 600;
    letter-spacing: -0.02em;
}

/* Header/Top Bar */
.top-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 4px 20px 4px;
    flex-wrap: nowrap;
    gap: 8px;
}

.top-bar > div:first-child {
    min-width: 0;
    flex: 1;
}

.store-name {
    font-size: 1.15rem;
    font-weight: 700;
    background: var(--primary-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    display: block;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sincronia-status {
    font-size: 0.72rem;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: 6px;
}

.sync-dot {
    width: 6px;
    height: 6px;
    background-color: var(--green);
    border-radius: 50%;
    box-shadow: 0 0 8px var(--green);
}

/* Modern Bottom Navigation for PWA (Fish Mobile) */
.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 100%;
    max-width: 480px;
    height: 68px;
    background: var(--nav-bg);
    border-top: 1px solid var(--bg-card-border);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    display: flex;
    justify-content: space-around;
    align-items: center;
    box-shadow: 0 -8px 24px rgba(0, 0, 0, 0.4);
    z-index: 999;
}

.nav-tab {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 0.7rem;
    font-weight: 500;
    transition: color 0.25s ease;
    gap: 4px;
    width: 20%;
    height: 100%;
}

.nav-tab i {
    font-size: 1.35rem;
    transition: transform 0.2s ease;
}

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

.nav-tab.active i {
    transform: translateY(-2px);
    color: hsl(263, 90%, 65%);
}

/* KPI Summary Cards Grid */
.kpi-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
    margin-bottom: 16px;
}

.kpi-card {
    background: var(--bg-card);
    border: 1px solid var(--bg-card-border);
    border-radius: 16px;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    box-shadow: var(--shadow-soft);
}

.kpi-title {
    font-size: 0.75rem;
    color: var(--text-secondary);
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.kpi-value {
    font-size: 1.3rem;
    font-weight: 700;
}

.kpi-value.money {
    color: var(--green);
}

.kpi-value.accent {
    color: var(--accent);
}

/* Beautiful Inputs & Forms for Logon */
.form-group {
    margin-bottom: 18px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.form-label {
    font-size: 0.8rem;
    color: var(--text-secondary);
    font-weight: 500;
}

.form-input {
    background: hsla(223, 47%, 8%, 0.6);
    border: 1px solid var(--bg-card-border);
    border-radius: 12px;
    color: var(--text-primary);
    padding: 14px 16px;
    font-family: inherit;
    font-size: 0.95rem;
    outline: none;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.form-input:focus {
    border-color: hsl(263, 90%, 65%);
    box-shadow: 0 0 0 3px hsla(263, 90%, 51%, 0.25);
}

/* Premium Buttons */
.btn-primary {
    background: var(--primary-gradient);
    border: none;
    border-radius: 14px;
    color: white;
    font-family: inherit;
    font-size: 0.98rem;
    font-weight: 600;
    padding: 16px;
    cursor: pointer;
    transition: transform 0.15s ease, opacity 0.2s ease;
    box-shadow: 0 8px 16px rgba(138, 43, 226, 0.3);
    text-align: center;
    width: 100%;
}

.btn-primary:active {
    transform: scale(0.97);
    opacity: 0.9;
}

/* Alert Styling */
.alert {
    border-radius: 12px;
    padding: 14px 16px;
    margin-bottom: 16px;
    font-size: 0.85rem;
    font-weight: 500;
    line-height: 1.4;
}

.alert-danger {
    background: hsla(355, 85%, 55%, 0.15);
    border: 1px solid hsla(355, 85%, 55%, 0.3);
    color: hsl(355, 95%, 70%);
}

.alert-success {
    background: hsla(145, 80%, 45%, 0.15);
    border: 1px solid hsla(145, 80%, 45%, 0.3);
    color: hsl(145, 90%, 70%);
}

/* Chart Containers */
.chart-container {
    position: relative;
    width: 100%;
    height: 220px;
    margin-top: 10px;
}

/* Branch Selector in Header */
.branch-selector-container {
    background: hsla(223, 47%, 8%, 0.5);
    border: 1px solid var(--bg-card-border);
    border-radius: 12px;
    padding: 2px 8px;
    display: flex;
    align-items: center;
    max-width: 150px;
    flex: 0 0 auto;
}

.branch-select {
    background: transparent;
    border: none;
    color: var(--text-primary);
    font-family: inherit;
    font-size: 0.78rem;
    font-weight: 600;
    outline: none;
    cursor: pointer;
    padding: 6px 12px 6px 4px;
    width: 100%;
    text-overflow: ellipsis;
    overflow: hidden;
    white-space: nowrap;
}

.branch-select option {
    background: var(--bg-main);
    color: var(--text-primary);
}

/* Floating Action Button (Alternative) */
.logout-btn {
    color: var(--text-secondary);
    font-size: 1.1rem;
    cursor: pointer;
    background: none;
    border: none;
}

.logout-btn:active {
    color: var(--red);
}

/* Utility classes */
.d-none {
    display: none !important;
}

/* PWA Installation Card */
.pwa-install-card {
    align-items: center;
    background: var(--bg-card);
    border: 1px solid var(--bg-card-border);
    border-radius: 16px;
    box-shadow: var(--shadow-soft), var(--shadow-inset);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    display: flex;
    gap: 12px;
    justify-content: space-between;
    left: 50%;
    max-width: 440px;
    padding: 14px;
    position: fixed;
    top: 90px;
    transform: translateX(-50%);
    width: calc(100% - 32px);
    z-index: 1200;
}

.pwa-install-card strong {
    color: var(--text-primary);
    display: block;
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 2px;
}

.pwa-install-card span {
    color: var(--text-secondary);
    display: block;
    font-size: 12px;
    font-weight: 500;
    line-height: 1.3;
}

.pwa-install-actions {
    display: flex;
    flex: 0 0 auto;
    gap: 8px;
}

.pwa-install-actions button {
    border: 0;
    border-radius: 12px;
    cursor: pointer;
    font-size: 12px;
    font-weight: 600;
    padding: 8px 12px;
    white-space: nowrap;
    transition: transform 0.15s ease;
}

.pwa-install-actions button:active {
    transform: scale(0.95);
}

.pwa-install-actions button:first-child {
    background: var(--primary-gradient);
    color: #fff;
}

.pwa-install-actions button:last-child {
    background: hsla(223, 47%, 25%, 0.4);
    color: var(--text-primary);
    border: 1px solid var(--bg-card-border);
}

/* Theme Customization Switcher */
.theme-btn {
    background: hsla(223, 47%, 8%, 0.5);
    border: 1px solid var(--bg-card-border);
    border-radius: 12px;
    color: var(--text-primary);
    padding: 8px 10px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    outline: none;
    transition: transform 0.15s ease, background-color 0.2s ease, border-color 0.2s ease;
}

.theme-btn:hover {
    background: hsla(223, 47%, 12%, 0.7);
    border-color: var(--primary);
}

.theme-btn:active {
    transform: scale(0.95);
}

.theme-btn i {
    font-size: 0.85rem;
    color: var(--text-primary);
}

.theme-dropdown {
    position: absolute;
    right: 0;
    top: 42px;
    background: var(--bg-card);
    border: 1px solid var(--bg-card-border);
    border-radius: 16px;
    padding: 10px;
    display: flex;
    gap: 8px;
    box-shadow: var(--shadow-soft);
    z-index: 1300;
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    animation: themeMenuFadeIn 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes themeMenuFadeIn {
    from {
        opacity: 0;
        transform: translateY(-8px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.theme-dot {
    position: relative;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    display: inline-block;
    cursor: pointer;
    border: 2px solid rgba(255, 255, 255, 0.25);
    transition: transform 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275), border-color 0.2s ease, box-shadow 0.2s ease;
}

.theme-dot:hover {
    transform: scale(1.2);
    border-color: rgba(255, 255, 255, 0.8);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.theme-dot.active {
    border-color: #ffffff;
    transform: scale(1.1);
    box-shadow: 0 0 12px var(--primary);
}

.theme-dot.active::after {
    content: "\f00c";
    font-family: "Font Awesome 6 Free";
    font-weight: 900;
    font-size: 10px;
    color: #ffffff;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.5);
}
.btn-period {
    flex: 1;
    background: hsla(223, 47%, 8%, 0.4);
    border: 1px solid var(--bg-card-border);
    border-radius: 10px;
    color: var(--text-secondary);
    padding: 8px 4px;
    font-family: inherit;
    font-size: 0.78rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}
.btn-period:active {
    transform: scale(0.95);
}
.btn-period.active {
    background: var(--primary-gradient);
    border-color: transparent;
    color: white;
    box-shadow: 0 4px 12px rgba(99, 13, 243, 0.25);
}
