/* CSS Premium - Creditsafe History Gateway */

:root {
    --bg-main: #f8fafc; /* Slate 50 (light background) */
    --bg-card: rgba(255, 255, 255, 0.7); /* Light transparent card background */
    --border-glass: rgba(15, 23, 42, 0.08); /* Darker border for light glass */
    --text-primary: #0f172a; /* Slate 900 (dark text) */
    --text-secondary: #475569; /* Slate 600 (muted text) */
    --accent-indigo: #ff6600; /* Brand Accent Orange */
    --accent-cyan: #0e4ce9; /* Sky 500 */
    --accent-emerald: #10b981;
    --accent-rose: #ef4444;
    --accent-amber: #f59e0b;
    --glow-shadow: 0 0 15px rgba(255, 102, 0, 0.2);
}

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

body {
    background-color: var(--bg-main);
    color: var(--text-primary);
    font-family: 'Geist', 'Inter', sans-serif;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    overflow-x: hidden;
    position: relative;
}

.font-corsivo {
    font-family: 'Instrument Serif', 'Instrumental Serif', serif;
    font-style: italic;
    font-weight: normal;
}

/* Sfondo animato a stelle */
#stars {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: -1;
    background: radial-gradient(circle at 50% 50%, #ffffff 0%, #e2e8f0 100%);
    overflow: hidden;
}

/* Effetto Vetro (Glassmorphism) */
.glass {
    background: var(--bg-card);
    backdrop-filter: blur(14px) saturate(200%);
    -webkit-backdrop-filter: blur(14px) saturate(200%);
    border: 1px solid var(--border-glass);
    border-radius: 12px;
    box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.05);
}

.card {
    padding: 24px;
    margin-bottom: 24px;
    transition: transform 0.3s ease, border-color 0.3s ease;
}

.card:hover {
    border-color: rgba(255, 102, 0, 0.25);
}

/* Login Container */
#login-container {
    width: 100%;
    max-width: 420px;
    margin: 20px;
    text-align: center;
}

.card-header h1 {
    font-size: 28px;
    font-weight: 700;
    margin-bottom: 8px;
}

.card-header p {
    color: var(--text-secondary);
    font-size: 14px;
    margin-bottom: 24px;
}

/* Input Form */
.form-group {
    margin-bottom: 20px;
    text-align: left;
}

label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-secondary);
    margin-bottom: 8px;
}

input[type="text"],
input[type="email"],
input[type="password"],
select {
    width: 100%;
    padding: 12px 16px;
    background: rgba(255, 255, 255, 0.85);
    border: 1px solid rgba(15, 23, 42, 0.12);
    border-radius: 8px;
    color: var(--text-primary);
    font-family: inherit;
    font-size: 14px;
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
}

input[type="text"]:focus,
input[type="email"]:focus,
input[type="password"]:focus,
select:focus {
    border-color: var(--accent-indigo);
    box-shadow: 0 0 8px rgba(255, 102, 0, 0.2);
}

.form-row {
    display: flex;
    gap: 16px;
}

.form-row .form-group {
    flex: 1;
}

/* Pulsanti */
.btn {
    display: inline-flex;
    justify-content: center;
    align-items: center;
    padding: 12px 24px;
    font-family: inherit;
    font-size: 14px;
    font-weight: 600;
    border-radius: 8px;
    border: none;
    cursor: pointer;
    transition: all 0.2s ease-in-out;
}

.primary-btn {
    background: linear-gradient(135deg, var(--accent-indigo) 0%, #e65c00 100%);
    color: white;
}

.primary-btn:hover {
    transform: translateY(-2px);
    box-shadow: var(--glow-shadow);
}

.secondary-btn {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-primary);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.secondary-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.2);
}

.btn-sm {
    padding: 6px 12px;
    font-size: 12px;
    border-radius: 6px;
}

/* Glow Text */
.glow-text {
    background: linear-gradient(135deg, #ff6a00 0%, #ffab79 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

/* App Container */
#app-container {
    width: 100%;
    display: flex;
    flex-direction: row;
    min-height: 100vh;
    justify-content: flex-start;
}

header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 24px;
    border-radius: 12px;
    margin-bottom: 24px;
}

.logo-area {
    display: flex;
    align-items: center;
    gap: 12px;
}

.pulse-dot {
    width: 10px;
    height: 10px;
    background-color: var(--accent-cyan);
    border-radius: 50%;
    box-shadow: 0 0 10px var(--accent-cyan);
    animation: pulse 1.8s infinite;
}

@keyframes pulse {
    0% { transform: scale(0.9); opacity: 0.6; }
    50% { transform: scale(1.15); opacity: 1; }
    100% { transform: scale(0.9); opacity: 0.6; }
}

.user-area {
    display: flex;
    align-items: center;
    gap: 16px;
}

#user-display {
    font-weight: 500;
    color: var(--accent-cyan);
}

/* Grid Layout */
.grid-container {
    display: grid;
    grid-template-columns: 380px 1fr;
    gap: 24px;
    align-items: stretch;
    flex-grow: 1;
    height: 100%;
    min-height: 0;
    overflow: hidden;
}

.left-panel {
    display: flex;
    flex-direction: column;
    height: 100%;
    overflow-y: auto;
    padding-right: 4px;
}

.right-panel {
    display: flex;
    flex-direction: column;
    height: 100%;
    min-height: 0;
    overflow: hidden;
}

/* Badges per la Cache */
.badge {
    padding: 6px 12px;
    border-radius: 9999px;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    display: inline-block;
}

.badge-hit {
    background-color: rgba(16, 185, 129, 0.15);
    color: var(--accent-emerald);
    border: 1px solid rgba(16, 185, 129, 0.3);
}

.badge-miss {
    background-color: rgba(239, 68, 68, 0.15);
    color: var(--accent-rose);
    border: 1px solid rgba(239, 68, 68, 0.3);
}

.badge-fallback {
    background-color: rgba(245, 158, 11, 0.15);
    color: var(--accent-amber);
    border: 1px solid rgba(245, 158, 11, 0.3);
}

/* Stats */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
    margin-top: 16px;
}

.stat-item {
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: 8px;
    padding: 16px 8px;
    text-align: center;
}

.stat-val {
    display: block;
    font-size: 20px;
    font-weight: 700;
    color: var(--accent-cyan);
    margin-bottom: 4px;
}

.stat-lbl {
    font-size: 10px;
    color: var(--text-secondary);
    text-transform: uppercase;
}

/* Report visualizer */
.report-card {
    flex-grow: 1;
    height: 100%;
    min-height: 0;
    display: flex;
    flex-direction: column;
}

#report-content {
    display: flex;
    flex-direction: column;
    flex-grow: 1;
    min-height: 0;
    overflow: hidden;
}

#summary-view {
    flex-grow: 1;
    overflow-y: auto;
    min-height: 0;
    padding-right: 4px;
}

#json-view {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
    overflow: hidden;
}

.report-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    padding-bottom: 16px;
    margin-bottom: 24px;
}

.report-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}

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

/* Loader */
.loader-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 16px;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 4px solid rgba(255, 255, 255, 0.1);
    border-top-color: var(--accent-indigo);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

/* Widgets */
.widgets-row {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
    margin-bottom: 24px;
}

.widget {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: 10px;
    padding: 16px;
}

.w-lbl {
    display: block;
    font-size: 11px;
    color: var(--text-secondary);
    text-transform: uppercase;
    margin-bottom: 6px;
}

.w-val {
    font-size: 16px;
    font-weight: 600;
    color: white;
}

/* JSON Code Highlight */
.json-viewer-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
    font-size: 12px;
    color: var(--text-secondary);
}

.json-code {
    background: #030712;
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: 8px;
    padding: 16px;
    overflow: auto;
    flex-grow: 1;
    min-height: 0;
    font-family: 'Courier New', Courier, monospace;
    font-size: 13px;
    line-height: 1.5;
    text-align: left;
}

.json-code code {
    white-space: pre-wrap;
    word-break: break-all;
}

/* JSON Syntax Colors */
.json-key { color: #06b6d4; }
.json-string { color: #10b981; }
.json-number { color: #f59e0b; }
.json-boolean { color: #a855f7; }
.json-null { color: #6b7280; }

/* Admin Only Section & Tables */
.admin-only-block {
    border-left: 3px solid var(--accent-indigo);
}

.table-container {
    width: 100%;
    overflow-x: auto;
    margin-top: 16px;
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
    text-align: left;
}

th, td {
    padding: 12px;
    border-bottom: 1px solid var(--border-glass);
}

th {
    color: var(--text-secondary);
    font-weight: 600;
    text-transform: uppercase;
    font-size: 11px;
}

tr:hover td {
    background: rgba(0, 0, 0, 0.015);
}

.key-output-box {
    margin-top: 16px;
    background: rgba(0, 0, 0, 0.03);
    border: 1px dashed var(--accent-indigo);
    border-radius: 8px;
    padding: 12px;
    text-align: center;
}

.key-output-box code {
    font-size: 13px;
    color: var(--accent-cyan);
    word-break: break-all;
}

.warning-text {
    font-size: 11px;
    color: var(--accent-amber);
    margin-bottom: 8px;
}

.error-message {
    color: var(--accent-rose);
    font-size: 13px;
    margin-bottom: 16px;
    text-align: left;
}

/* Custom Scrollbar */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}
::-webkit-scrollbar-track {
    background: var(--bg-main);
}
::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.2);
}

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

/* Tabbed Layout for Reports */
.tabs-navigation {
    display: flex;
    gap: 8px;
    margin-bottom: 20px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    padding-bottom: 8px;
}

.tab-btn {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    padding: 8px 16px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    border-radius: 6px;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 6px;
}

.tab-btn:hover {
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.03);
}

.tab-btn.active {
    color: var(--accent-cyan);
    background: rgba(6, 182, 212, 0.1);
    border: 1px solid rgba(6, 182, 212, 0.2);
    box-shadow: 0 0 10px rgba(6, 182, 212, 0.1);
}

/* Simplified Report Styles */
.summary-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 16px;
    margin-bottom: 20px;
}

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

.summary-card {
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid rgba(0, 0, 0, 0.5);
    border-radius: 12px;
    padding: 16px;
}

.summary-card h4 {
    color: var(--accent-cyan);
    font-size: 14px;
    margin-bottom: 12px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    padding-bottom: 6px;
    font-weight: 600;
}

.summary-detail-row {
    display: flex;
    justify-content: space-between;
    font-size: 13px;
    margin-bottom: 8px;
    line-height: 1.4;
}

.summary-detail-lbl {
    color: var(--text-secondary);
}

.summary-detail-val {
    font-weight: 500;
    text-align: right;
    max-width: 60%;
    word-break: break-word;
}

.commentary-item {
    padding: 10px;
    border-radius: 8px;
    margin-bottom: 8px;
    font-size: 13px;
    line-height: 1.4;
}

.commentary-Positive {
    background: rgba(16, 185, 129, 0.08);
    border: 1px solid rgba(16, 185, 129, 0.15);
    color: #007800;
}

.commentary-Negative {
    background: rgba(239, 68, 68, 0.08);
    border: 1px solid rgba(239, 68, 68, 0.15);
    color: #7a0000;
}

.commentary-Neutral {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.06);
    color: #e5e7eb;
}

/* Sidebar & Multi-section Layout */
.dashboard-layout {
    display: flex;
    min-height: 100vh;
    width: 100%;
}

.sidebar {
    width: 280px;
    min-width: 280px;
    background: rgba(255, 255, 255, 0.8);
    border-right: 1px solid var(--border-glass);
    display: flex;
    flex-direction: column;
    padding: 24px;
    height: 100vh;
    position: sticky;
    top: 0;
    z-index: 100;
}

.sidebar-logo {
    display: flex;
    align-items: center;
    gap: 12px;
    padding-bottom: 24px;
    border-bottom: 1px solid var(--border-glass);
    margin-bottom: 24px;
}

.sidebar-menu {
    display: flex;
    flex-direction: column;
    gap: 8px;
    flex-grow: 1;
}

.menu-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    border-radius: 8px;
    color: var(--text-secondary);
    text-decoration: none;
    font-weight: 500;
    font-size: 14px;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    border-left: 3px solid transparent;
}

.menu-item:hover {
    color: var(--text-primary);
    background: rgba(0, 0, 0, 0.03);
}

.menu-item.active {
    color: var(--accent-indigo);
    background: linear-gradient(90deg, rgba(255, 102, 0, 0.08) 0%, rgba(255, 102, 0, 0.01) 100%);
    border-left-color: var(--accent-indigo);
}

.menu-icon {
    font-size: 16px;
}

.sidebar-footer {
    border-top: 1px solid var(--border-glass);
    padding-top: 20px;
    margin-top: auto;
}

.user-display-box {
    background: rgba(0, 0, 0, 0.02);
    padding: 10px 12px;
    border-radius: 6px;
    margin-bottom: 8px;
    border: 1px solid var(--border-glass);
}

.user-display-box strong {
    color: var(--accent-cyan);
    font-size: 13px;
    word-break: break-all;
}

.main-viewport {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    height: 100vh;
    overflow: hidden;
}

.dashboard-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 32px;
    border-bottom: 1px solid var(--border-glass);
    position: sticky;
    top: 0;
    z-index: 90;
    background: rgba(255, 255, 255, 0.6);
    backdrop-filter: blur(10px);
}

.dashboard-header h2 {
    margin: 0;
    font-size: 20px;
    font-weight: 600;
}

.viewport-content {
    padding: 32px;
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    height: 0;
    overflow: hidden;
}

/* Sections visibility */
.tab-section {
    display: none;
    animation: fadeInSection 0.3s ease-out;
}

.tab-section.active-section {
    display: flex;
    flex-direction: column;
    flex-grow: 1;
    height: 100%;
    min-height: 0;
    overflow: hidden;
}

#sec-billing.active-section {
    display: block;
    overflow-y: auto;
}

@keyframes fadeInSection {
    from {
        opacity: 0;
        transform: translateY(6px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Invoicing badges & buttons */
.badge-invoiced {
    background: rgba(16, 185, 129, 0.1);
    color: #065f46;
    border: 1px solid rgba(16, 185, 129, 0.2);
}

.badge-pending {
    background: rgba(245, 158, 11, 0.1);
    color: #92400e;
    border: 1px solid rgba(245, 158, 11, 0.2);
}

.btn-invoice-toggle {
    cursor: pointer;
    font-size: 11px;
    padding: 4px 8px;
    border-radius: 4px;
    font-weight: 600;
    transition: all 0.2s;
    background: rgba(255, 255, 255, 0.8);
    border: 1px solid var(--border-glass);
    color: var(--text-primary);
}

.btn-invoice-toggle:hover {
    background: var(--accent-indigo);
    border-color: var(--accent-indigo);
    color: #ffffff;
}

body.dashboard-active {
    display: block;
    overflow: hidden;
}

/* Modal Overlay & Dialog - Cambia Password */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(15, 23, 42, 0.4);
    backdrop-filter: blur(8px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.modal-content {
    width: 100%;
    max-width: 400px;
    margin: 20px;
    position: relative;
    padding: 28px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.15);
    background: rgba(255, 255, 255, 0.85);
    border: 1px solid rgba(15, 23, 42, 0.12);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.modal-header h3 {
    margin: 0;
    font-size: 1.3rem;
    font-weight: 600;
    color: var(--text-primary);
}

.close-btn {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: var(--text-secondary);
    transition: color 0.2s;
    line-height: 1;
}

.close-btn:hover {
    color: var(--accent-rose);
}



