/* ===========================================
   RangeReport - Business Theme
   Mobile-first, responsive, clean
   PWA Safe Area Support
   =========================================== */

:root {
    --bg-primary: #0a0f1a;
    --bg-secondary: #0f1629;
    --bg-card: rgba(15, 23, 42, 0.7);
    --bg-hover: rgba(30, 41, 59, 0.8);
    --border-color: rgba(71, 85, 105, 0.4);
    --text-primary: #ffffff;
    --text-secondary: #e2e8f0;
    --text-muted: #cbd5e1;
    --accent-blue: #3b82f6;
    --accent-green: #22c55e;
    --accent-orange: #f59e0b;
    --accent-red: #ef4444;
    --sidebar-width: 220px;
    --header-height: 56px;
    /* Safe area per iPhone notch */
    --safe-area-top: env(safe-area-inset-top, 0px);
    --safe-area-bottom: env(safe-area-inset-bottom, 0px);
    --safe-area-left: env(safe-area-inset-left, 0px);
    --safe-area-right: env(safe-area-inset-right, 0px);
}

* {
    box-sizing: border-box;
}

html, body {
    margin: 0;
    padding: 0;
    min-height: 100vh;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    font-size: 14px;
    line-height: 1.5;
    background: linear-gradient(135deg, #0a0f1a 0%, #1e293b 50%, #0f172a 100%);
    background-attachment: fixed;
    color: var(--text-primary);
    /* Padding per safe area su tutto il body */
    padding-top: var(--safe-area-top);
    padding-left: var(--safe-area-left);
    padding-right: var(--safe-area-right);
}

/* ===========================================
   HEADER - CON SAFE AREA IPHONE
   =========================================== */
.rr-header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    /* Altezza include safe area per notch iPhone */
    height: calc(var(--header-height) + var(--safe-area-top));
    padding-top: var(--safe-area-top);
    padding-left: calc(16px + var(--safe-area-left));
    padding-right: calc(16px + var(--safe-area-right));
    background: var(--bg-card);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    z-index: 1000;
}

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

.menu-toggle {
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 8px;
    background: none;
    border: none;
    cursor: pointer;
}

.menu-toggle span {
    width: 20px;
    height: 2px;
    background: var(--text-primary);
    transition: 0.2s;
}

@media (min-width: 992px) {
    .menu-toggle {
        display: none;
    }
}

.logo {
    font-size: 18px;
    font-weight: 600;
    color: var(--text-primary);
    text-decoration: none;
}

.logo:hover {
    color: var(--accent-blue);
}

.header-right {
    display: flex;
    align-items: center;
    gap: 16px;
}

.user-name {
    color: var(--text-secondary);
    font-size: 13px;
}

@media (max-width: 576px) {
    .user-name {
        display: none;
    }
}

.btn-logout {
    padding: 6px 12px;
    background: transparent;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 13px;
    transition: 0.2s;
}

.btn-logout:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

/* ===========================================
   SIDEBAR - CON SAFE AREA
   =========================================== */
.rr-sidebar {
    position: fixed;
    /* Top tiene conto dell'header + safe area */
    top: calc(var(--header-height) + var(--safe-area-top));
    left: 0;
    bottom: 0;
    width: var(--sidebar-width);
    padding-left: var(--safe-area-left);
    padding-bottom: var(--safe-area-bottom);
    background: var(--bg-card);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    z-index: 900;
    transition: transform 0.3s ease;
}

@media (max-width: 991px) {
    .rr-sidebar {
        transform: translateX(-100%);
    }
    
    .rr-sidebar.open {
        transform: translateX(0);
    }
}

.sidebar-nav {
    flex: 1;
    padding: 16px 0;
    overflow-y: auto;
}

.nav-item {
    display: block;
    padding: 10px 20px;
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 14px;
    transition: 0.15s;
}

.nav-item:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.nav-item.active {
    background: var(--bg-card);
    color: var(--accent-blue);
    border-left: 3px solid var(--accent-blue);
}

.nav-divider {
    height: 1px;
    background: var(--border-color);
    margin: 12px 20px;
}

.sidebar-footer {
    padding: 16px 20px;
    border-top: 1px solid var(--border-color);
}

.sidebar-footer a {
    color: var(--text-muted);
    text-decoration: none;
    font-size: 12px;
}

.sidebar-footer a:hover {
    color: var(--text-primary);
}

/* Overlay mobile */
.sidebar-overlay {
    display: none;
    position: fixed;
    top: calc(var(--header-height) + var(--safe-area-top));
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.5);
    z-index: 800;
}

.sidebar-overlay.active {
    display: block;
}

@media (min-width: 992px) {
    .sidebar-overlay {
        display: none !important;
    }
}

/* ===========================================
   MAIN CONTENT - CON SAFE AREA
   =========================================== */
.rr-main {
    /* Margin top tiene conto dell'header + safe area */
    margin-top: calc(var(--header-height) + var(--safe-area-top));
    padding: 24px;
    padding-bottom: calc(24px + var(--safe-area-bottom));
    min-height: calc(100vh - var(--header-height) - var(--safe-area-top) - 48px);
}

@media (min-width: 992px) {
    .rr-main {
        margin-left: var(--sidebar-width);
    }
}

@media (max-width: 576px) {
    .rr-main {
        padding: 16px;
        padding-bottom: calc(16px + var(--safe-area-bottom));
    }
}

/* ===========================================
   FOOTER - CON SAFE AREA
   =========================================== */
.rr-footer {
    padding: 12px 24px;
    padding-bottom: calc(12px + var(--safe-area-bottom));
    text-align: center;
    color: var(--text-muted);
    font-size: 12px;
    border-top: 1px solid var(--border-color);
}

@media (min-width: 992px) {
    .rr-footer {
        margin-left: var(--sidebar-width);
    }
}

/* ===========================================
   CARDS
   =========================================== */
.card {
    background: var(--bg-card);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    color: var(--text-primary);
}

.card-header {
    background: transparent;
    border-bottom: 1px solid var(--border-color);
    padding: 12px 16px;
    font-weight: 500;
}

.card-body {
    padding: 16px;
}

/* ===========================================
   KPI CARDS
   =========================================== */
.kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.kpi-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 20px;
    text-align: center;
}

.kpi-value {
    font-size: 28px;
    font-weight: 600;
    line-height: 1.2;
}

.kpi-value.cyan { color: var(--accent-blue); }
.kpi-value.orange { color: var(--accent-orange); }
.kpi-value.green { color: var(--accent-green); }
.kpi-value.blue { color: var(--accent-blue); }

.kpi-label {
    font-size: 12px;
    color: var(--text-secondary);
    margin-top: 4px;
}

.kpi-sub {
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 8px;
}

/* ===========================================
   TABLES
   =========================================== */
.table {
    width: 100%;
    color: var(--text-primary) !important;
    border-collapse: collapse;
    background: transparent !important;
}

.table th {
    background: rgba(15, 23, 42, 0.9) !important;
    color: var(--text-secondary) !important;
    font-weight: 500;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 12px 16px;
    text-align: left;
    border-bottom: 1px solid var(--border-color) !important;
}

.table td {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-color) !important;
    color: var(--text-primary) !important;
    background: transparent !important;
}

.table tbody {
    background: transparent !important;
}

.table tbody tr {
    background: transparent !important;
}

.table tbody tr:hover {
    background: var(--bg-hover) !important;
}

.table-responsive {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    background: transparent !important;
}

/* Force no white backgrounds */
.table, .table th, .table td, .table tr, .table thead, .table tbody,
.card-body, .card, table, tr, td, th, thead, tbody {
    background-color: transparent !important;
}

/* ===========================================
   FORMS
   =========================================== */
.form-control, .form-select {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    padding: 8px 12px;
    border-radius: 4px;
    font-size: 14px;
}

.form-control:focus, .form-select:focus {
    background: var(--bg-card);
    border-color: var(--accent-blue);
    color: var(--text-primary);
    outline: none;
    box-shadow: 0 0 0 2px rgba(34, 211, 238, 0.2);
}

.form-control::placeholder {
    color: var(--text-muted);
}

.form-label {
    color: var(--text-secondary);
    font-size: 13px;
    margin-bottom: 4px;
}

/* ===========================================
   BUTTONS
   =========================================== */
.btn {
    padding: 8px 16px;
    border-radius: 4px;
    font-size: 14px;
    font-weight: 500;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    cursor: pointer;
    transition: 0.15s;
    border: 1px solid transparent;
}

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

.btn-primary:hover {
    background: #2563eb;
    color: white;
}

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

.btn-success:hover {
    background: #059669;
    color: white;
}

.btn-secondary {
    background: var(--bg-card);
    border-color: var(--border-color);
    color: var(--text-primary);
}

.btn-secondary:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.btn-outline-light {
    background: transparent;
    border-color: var(--border-color);
    color: var(--text-secondary);
}

.btn-outline-light:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

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

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

.btn-lg {
    padding: 12px 24px;
    font-size: 16px;
}

/* ===========================================
   BADGES
   =========================================== */
.badge {
    padding: 3px 8px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 500;
}

.bg-secondary {
    background: var(--bg-hover) !important;
    color: var(--text-secondary) !important;
}

.bg-warning {
    background: var(--accent-orange) !important;
    color: #000 !important;
}

.bg-success {
    background: var(--accent-green) !important;
}

.bg-danger {
    background: var(--accent-red) !important;
}

/* ===========================================
   ALERTS
   =========================================== */
.alert {
    padding: 12px 16px;
    border-radius: 6px;
    margin-bottom: 16px;
    border: 1px solid;
}

.alert-success {
    background: rgba(16, 185, 129, 0.1);
    border-color: var(--accent-green);
    color: var(--accent-green);
}

.alert-danger {
    background: rgba(239, 68, 68, 0.1);
    border-color: var(--accent-red);
    color: var(--accent-red);
}

.alert-warning {
    background: rgba(245, 158, 11, 0.1);
    border-color: var(--accent-orange);
    color: var(--accent-orange);
}

/* ===========================================
   YEAR SELECTOR
   =========================================== */
.year-selector {
    display: flex;
    gap: 8px;
    margin-bottom: 24px;
    flex-wrap: wrap;
}

.year-btn {
    padding: 8px 16px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 14px;
    transition: 0.15s;
}

.year-btn:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.year-btn.active {
    background: var(--accent-blue);
    border-color: var(--accent-blue);
    color: #000;
}

/* ===========================================
   UTILITIES
   =========================================== */
.text-cyan { color: var(--accent-blue) !important; }
.text-orange { color: var(--accent-orange) !important; }
.text-green { color: var(--accent-green) !important; }
.text-muted { color: var(--text-muted) !important; }
.text-secondary { color: var(--text-secondary) !important; }

.mb-0 { margin-bottom: 0 !important; }
.mb-2 { margin-bottom: 8px !important; }
.mb-3 { margin-bottom: 16px !important; }
.mb-4 { margin-bottom: 24px !important; }
.mt-2 { margin-top: 8px !important; }
.mt-4 { margin-top: 24px !important; }

.text-end { text-align: right !important; }
.text-center { text-align: center !important; }

.d-flex { display: flex !important; }
.justify-content-between { justify-content: space-between !important; }
.align-items-center { align-items: center !important; }
.gap-2 { gap: 8px !important; }
.gap-3 { gap: 16px !important; }

.w-100 { width: 100% !important; }

/* ===========================================
   PAGE HEADER
   =========================================== */
.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
    flex-wrap: wrap;
    gap: 12px;
}

.page-header h1 {
    font-size: 24px;
    font-weight: 600;
    margin: 0;
}

@media (max-width: 576px) {
    .page-header h1 {
        font-size: 20px;
    }
}

/* ===========================================
   LOGIN PAGE
   =========================================== */
.login-container {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    padding-top: calc(20px + var(--safe-area-top));
    padding-bottom: calc(20px + var(--safe-area-bottom));
    background: url('/Rangereport/images/login-page.png') no-repeat center center;
    background-size: cover;
}

.login-box {
    width: 100%;
    max-width: 400px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 32px;
}

.login-title {
    text-align: center;
    font-size: 28px;
    font-weight: 600;
    margin-bottom: 8px;
}

.login-subtitle {
    text-align: center;
    color: var(--text-muted);
    margin-bottom: 32px;
}

/* ===========================================
   RESPONSIVE GRID
   =========================================== */
.row {
    display: flex;
    flex-wrap: wrap;
    margin: -8px;
}

.row > * {
    padding: 8px;
}

.col-12 { flex: 0 0 100%; max-width: 100%; }

@media (min-width: 576px) {
    .col-sm-6 { flex: 0 0 50%; max-width: 50%; }
}

@media (min-width: 768px) {
    .col-md-3 { flex: 0 0 25%; max-width: 25%; }
    .col-md-4 { flex: 0 0 33.333%; max-width: 33.333%; }
    .col-md-5 { flex: 0 0 41.666%; max-width: 41.666%; }
    .col-md-6 { flex: 0 0 50%; max-width: 50%; }
    .col-md-7 { flex: 0 0 58.333%; max-width: 58.333%; }
    .col-md-8 { flex: 0 0 66.666%; max-width: 66.666%; }
}

