/* GestoPrix Web App - Styles */

:root {
    --primary: #2563eb;
    --success: #22c55e;
    --warning: #f97316;
    --danger: #ef4444;
    --gold: #c9a227;
    --bg: #121212;
    --card: #1e1e1e;
    --border: #2a2a2a;
    --text: #ffffff;
    --text-muted: #a3a3a3;
    --text-sec: #707070;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html, body {
    height: 100%;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
}

/* ============ LOGIN PAGE ============ */

.login-page {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.login-container {
    width: 100%;
    max-width: 450px;
}

.login-card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 40px 30px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
}

.login-header {
    text-align: center;
    margin-bottom: 32px;
}

.logo-large {
    width: 80px;
    height: 80px;
    margin: 0 auto 16px;
    border-radius: 16px;
    background: linear-gradient(135deg, var(--primary), var(--gold));
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 36px;
    font-weight: 900;
    color: white;
}

.login-header h1 {
    font-size: 28px;
    margin-bottom: 8px;
    font-weight: 700;
}

.login-header p {
    color: var(--text-muted);
    font-size: 14px;
}

.login-form {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.form-group label {
    font-size: 13px;
    font-weight: 600;
    color: var(--text);
}

.form-group input,
.form-group select {
    padding: 12px 14px;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: #252525;
    color: var(--text);
    font-size: 14px;
    transition: border-color 0.2s, background-color 0.2s;
    pointer-events: auto;
    position: relative;
    z-index: 2;
    -webkit-user-select: text;
    user-select: text;
}

.form-group input:focus,
.form-group select:focus {
    outline: none;
    border-color: var(--primary);
    background: #2a2a2a;
}

.form-hint {
    font-size: 12px;
    color: var(--text-muted);
}

/* ============ BUTTONS ============ */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 16px;
    border-radius: 8px;
    border: none;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    text-decoration: none;
    white-space: nowrap;
}

.btn:active {
    transform: scale(0.98);
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary), #1d4ed8);
    color: white;
    width: 100%;
}

.btn-primary:hover {
    background: linear-gradient(135deg, #1d4ed8, #1e40af);
    box-shadow: 0 8px 16px rgba(37, 99, 235, 0.3);
}

.btn-secondary {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text);
    width: 100%;
}

.btn-secondary:hover {
    background: #252525;
    border-color: var(--primary);
}

.btn-ghost {
    background: transparent;
    color: var(--text-muted);
    padding: 8px 12px;
}

.btn-ghost:hover {
    color: var(--text);
    background: rgba(255, 255, 255, 0.1);
}

.btn-large {
    padding: 14px 20px;
    font-size: 15px;
}

.btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

/* ============ ALERTS ============ */

.alert {
    padding: 12px 14px;
    border-radius: 8px;
    font-size: 14px;
    border: 1px solid;
    margin-bottom: 12px;
}

.alert[hidden] {
    display: none !important;
}

.alert-error {
    background: rgba(239, 68, 68, 0.1);
    border-color: var(--danger);
    color: var(--danger);
}

.alert-success {
    background: rgba(34, 197, 94, 0.1);
    border-color: var(--success);
    color: var(--success);
}

.alert-warning {
    background: rgba(249, 115, 22, 0.1);
    border-color: var(--warning);
    color: var(--warning);
}

.alert-info {
    background: rgba(37, 99, 235, 0.1);
    border-color: var(--primary);
    color: var(--primary);
}

.alert-box {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 20px;
}

/* ============ LOGIN FOOTER ============ */

.login-footer {
    margin-top: 32px;
    padding-top: 24px;
    border-top: 1px solid var(--border);
    font-size: 13px;
}

.login-footer p {
    color: var(--text-muted);
    margin-bottom: 10px;
}

.login-footer p strong {
    color: var(--text);
}

.login-footer ul {
    margin: 12px 0 0 20px;
    color: var(--text-muted);
}

.login-footer li {
    margin-bottom: 6px;
}

/* ============ WEB APP ============ */

.web-app {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

.web-header {
    background: #0f0f0f;
    border-bottom: 1px solid var(--border);
    padding: 12px 20px;
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-content {
    max-width: 1400px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 30px;
}

.logo-section {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-shrink: 0;
}

.logo {
    width: 40px;
    height: 40px;
    border-radius: 8px;
    background: linear-gradient(135deg, var(--primary), var(--gold));
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 900;
    font-size: 18px;
    color: white;
}

.logo-section h1 {
    font-size: 20px;
    font-weight: 700;
}

.header-nav {
    display: flex;
    gap: 4px;
    flex: 1;
    overflow-x: auto;
    white-space: nowrap;
    scrollbar-width: thin;
}

.nav-link {
    padding: 8px 16px;
    border-radius: 6px;
    text-decoration: none;
    color: var(--text-muted);
    font-size: 14px;
    font-weight: 500;
    transition: all 0.2s;
    cursor: pointer;
    border: none;
    background: none;
}

.nav-link:hover,
.nav-link.active {
    color: var(--primary);
    background: rgba(37, 99, 235, 0.1);
}

.header-user {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-shrink: 0;
}

#userDisplay {
    font-size: 14px;
    color: var(--text-muted);
}

.web-main {
    flex: 1;
    max-width: 1400px;
    width: 100%;
    margin: 0 auto;
    padding: 30px 20px;
    overflow-y: auto;
}

.page {
    display: none;
}

.page.active {
    display: block;
    animation: fadeIn 0.3s ease-in;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.page h2 {
    font-size: 24px;
    margin-bottom: 20px;
    font-weight: 700;
}

.page h3 {
    font-size: 18px;
    margin-bottom: 16px;
    font-weight: 600;
}

/* ============ CARDS & GRIDS ============ */

.card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 20px;
    margin-bottom: 20px;
}

.kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.kpi-card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 16px;
    text-align: center;
}

.kpi-card label {
    display: block;
    font-size: 12px;
    color: var(--text-muted);
    margin-bottom: 8px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.kpi-value {
    font-size: 32px;
    font-weight: 700;
    color: var(--gold);
    margin-bottom: 4px;
}

.kpi-card small {
    display: block;
    font-size: 12px;
    color: var(--text-sec);
}

/* ============ FORMS ============ */

.filters {
    display: flex;
    gap: 12px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.form-control {
    padding: 10px 12px;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: #252525;
    color: var(--text);
    font-size: 14px;
    flex: 1;
    min-width: 150px;
}

.form-control:focus {
    outline: none;
    border-color: var(--primary);
    background: #2a2a2a;
}

/* ============ LISTS & TABLES ============ */

.shops-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 16px;
}

.shop-card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 16px;
    cursor: pointer;
    transition: all 0.2s;
}

.shop-card:hover {
    border-color: var(--primary);
    box-shadow: 0 8px 16px rgba(37, 99, 235, 0.1);
}

.shop-card h3 {
    font-size: 16px;
    margin-bottom: 8px;
}

.shop-card .meta {
    font-size: 12px;
    color: var(--text-muted);
    margin-bottom: 12px;
}

.shop-card .stats {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    padding-top: 12px;
    border-top: 1px solid var(--border);
}

.stat {
    text-align: center;
}

.stat-label {
    font-size: 11px;
    color: var(--text-muted);
    text-transform: uppercase;
}

.stat-value {
    font-size: 18px;
    font-weight: 700;
    color: var(--gold);
    margin-top: 4px;
}

.activity-list,
.sales-table,
.stocks-table {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 12px;
    overflow: hidden;
}

.activity-item,
.sales-row,
.stock-row {
    padding: 14px;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.activity-item:last-child,
.sales-row:last-child,
.stock-row:last-child {
    border-bottom: none;
}

.activity-item-content {
    flex: 1;
}

.activity-item-title {
    font-weight: 600;
    font-size: 14px;
    margin-bottom: 4px;
}

.activity-item-meta {
    font-size: 12px;
    color: var(--text-muted);
}

.activity-item-amount {
    font-weight: 700;
    color: var(--gold);
}

.empty {
    text-align: center;
    padding: 40px 20px;
    color: var(--text-muted);
    font-size: 14px;
}

/* ============ LOADING ============ */

.loading-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 999;
}

.loading-overlay[hidden] {
    display: none !important;
    pointer-events: none !important;
}

.spinner {
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid rgba(255, 255, 255, 0.2);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

.spinner[hidden] {
    display: none !important;
}

.spinner-center {
    width: 48px;
    height: 48px;
    border: 3px solid rgba(255, 255, 255, 0.2);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ============ RESPONSIVE ============ */

@media (max-width: 768px) {
    .login-card {
        padding: 30px 20px;
    }

    .header-content {
        flex-wrap: wrap;
        gap: 15px;
    }

    .header-nav {
        flex-basis: 100%;
        order: 3;
    }

    .header-user {
        order: 2;
    }

    .web-main {
        padding: 20px;
    }

    .kpi-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .filters {
        flex-direction: column;
    }

    .form-control {
        min-width: auto;
    }

    .shops-grid {
        grid-template-columns: 1fr;
    }
}

.chart-wrap {
    position: relative;
    height: 260px;
    margin-top: 12px;
}

.chart-wrap--tall {
    height: 340px;
}

.exec-kpi .kpi-card {
    min-height: 88px;
}

.compare-table {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-top: 12px;
}

.compare-row {
    display: grid;
    grid-template-columns: 2fr repeat(4, 1fr);
    gap: 12px;
    padding: 12px 14px;
    background: var(--card-bg, #1e293b);
    border-radius: 10px;
    border: 1px solid rgba(255, 255, 255, 0.06);
    align-items: center;
}

.compare-row--local {
    border-color: rgba(245, 158, 11, 0.45);
}

.exec-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.exec-list li {
    display: flex;
    justify-content: space-between;
    padding: 8px 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.badge-ro {
    display: inline-block;
    font-size: 11px;
    padding: 2px 8px;
    border-radius: 6px;
    background: rgba(249, 115, 22, 0.2);
    color: #fb923c;
    vertical-align: middle;
}

.exec-bar {
    display: grid;
    grid-template-columns: 1fr 2fr auto;
    gap: 8px;
    align-items: center;
    margin-bottom: 8px;
    font-size: 13px;
}

.exec-bar__track {
    height: 8px;
    background: var(--border);
    border-radius: 4px;
    overflow: hidden;
}

.exec-bar__fill {
    height: 100%;
    background: linear-gradient(90deg, var(--gold), var(--primary));
}

.exec-bar__val {
    font-weight: 600;
    color: var(--gold);
    min-width: 48px;
    text-align: right;
}

.exec-hero h2 {
    margin: 0 0 6px;
}

@media (max-width: 768px) {
    .compare-row {
        grid-template-columns: 1fr 1fr;
    }
    .header-nav {
        flex-wrap: wrap;
    }
}

@media (max-width: 480px) {
    .logo-section {
        gap: 8px;
    }

    .logo-section h1 {
        font-size: 16px;
    }

    .header-nav {
        gap: 0;
    }

    .nav-link {
        padding: 6px 8px;
        font-size: 12px;
    }

    .web-main {
        padding: 16px;
    }

    .kpi-grid {
        grid-template-columns: 1fr;
    }

    .page h2 {
        font-size: 20px;
    }

    .btn {
        font-size: 13px;
        padding: 10px 14px;
    }
}
