/* ============================================
   Base CSS - Design System
   Variabili, reset, tipografia, utility
   ============================================ */

:root {
    /* Brand Colors */
    --accent: #005a86;
    --accent-light: #0074ad;
    --accent-dark: #004a70;
    --accent-glow: rgba(0, 90, 134, 0.25);
    --accent-gradient: linear-gradient(135deg, #005a86 0%, #0074ad 100%);
    --success: #2ed573;
    --success-dark: #26b860;
    --warning: #ffa502;
    --danger: #ff4757;
    --danger-dark: #e63e4d;

    /* Dark theme (default) */
    --bg-primary: #0a1628;
    --bg-secondary: #101d30;
    --bg-tertiary: #162a42;
    --bg-card: #152238;
    --bg-input: #1a2d45;
    --text-primary: #f0f4f8;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    --border-color: rgba(255, 255, 255, 0.07);
    --border-light: rgba(255, 255, 255, 0.1);
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.5);

    /* Spacing */
    --space-xs: 4px;
    --space-sm: 8px;
    --space-md: 16px;
    --space-lg: 24px;
    --space-xl: 32px;
    --space-2xl: 48px;

    /* Radius */
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 24px;
    --radius-full: 9999px;

    /* Typography */
    --font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    --font-size-xs: 0.75rem;
    --font-size-sm: 0.875rem;
    --font-size-md: 1rem;
    --font-size-lg: 1.125rem;
    --font-size-xl: 1.25rem;
    --font-size-2xl: 1.5rem;
    --font-size-3xl: 2rem;

    /* Transitions */
    --transition-fast: 150ms ease;
    --transition-normal: 250ms ease;
    --transition-slow: 400ms ease;

    /* Safe areas */
    --safe-top: env(safe-area-inset-top, 0px);
    --safe-bottom: env(safe-area-inset-bottom, 0px);
    --safe-left: env(safe-area-inset-left, 0px);
    --safe-right: env(safe-area-inset-right, 0px);
}

/* Light theme */
body.light-theme {
    --bg-primary: #f4f7fa;
    --bg-secondary: #ffffff;
    --bg-tertiary: #e8eef4;
    --bg-card: #ffffff;
    --bg-input: #eef2f7;
    --text-primary: #1a2332;
    --text-secondary: #475569;
    --text-muted: #94a3b8;
    --border-color: rgba(0, 90, 134, 0.08);
    --border-light: rgba(0, 90, 134, 0.12);
    --shadow-sm: 0 2px 8px rgba(0, 42, 64, 0.06);
    --shadow-md: 0 4px 16px rgba(0, 42, 64, 0.1);
    --shadow-lg: 0 8px 32px rgba(0, 42, 64, 0.14);
}

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

html {
    font-size: 16px;
    -webkit-text-size-adjust: 100%;
    -webkit-tap-highlight-color: transparent;
}

body {
    font-family: var(--font-family);
    font-size: var(--font-size-md);
    line-height: 1.5;
    color: var(--text-primary);
    background-color: var(--bg-primary);
    overflow: hidden;
    height: 100vh;
    height: 100dvh;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

img {
    max-width: 100%;
    display: block;
}

button {
    font-family: inherit;
    font-size: inherit;
    cursor: pointer;
    border: none;
    background: none;
    color: inherit;
    -webkit-tap-highlight-color: transparent;
}

select,
input {
    font-family: inherit;
    font-size: inherit;
}

/* Screens */
.screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    height: 100dvh;
    display: none;
    flex-direction: column;
}

.screen.active {
    display: flex;
}

/* Hidden utility */
.hidden {
    display: none !important;
}

/* Buttons */
.btn-primary {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-sm);
    padding: var(--space-md) var(--space-lg);
    background: var(--accent-gradient);
    color: #fff;
    border-radius: var(--radius-lg);
    font-weight: 600;
    font-size: var(--font-size-md);
    transition: all var(--transition-fast);
    border: none;
    white-space: nowrap;
    box-shadow: 0 2px 8px rgba(0, 90, 134, 0.3);
}

.btn-primary:active {
    background: var(--accent-dark);
    transform: scale(0.97);
    box-shadow: 0 1px 4px rgba(0, 90, 134, 0.3);
}

.btn-primary:disabled {
    opacity: 0.5;
    pointer-events: none;
}

.btn-primary.btn-large {
    padding: var(--space-md) var(--space-xl);
    font-size: var(--font-size-lg);
    width: 100%;
    border-radius: var(--radius-lg);
}

.btn-secondary {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-sm);
    padding: var(--space-md) var(--space-lg);
    background: var(--bg-card);
    color: var(--text-primary);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-lg);
    font-weight: 500;
    font-size: var(--font-size-md);
    transition: all var(--transition-fast);
}

.btn-secondary:active {
    background: var(--bg-tertiary);
    transform: scale(0.97);
}

.btn-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    border-radius: var(--radius-md);
    color: var(--text-primary);
    transition: background var(--transition-fast);
}

.btn-icon:active {
    background: var(--bg-card);
}

/* Toast notifications */
.toast-container {
    position: fixed;
    top: calc(var(--safe-top) + var(--space-md));
    left: 50%;
    transform: translateX(-50%);
    z-index: 10000;
    display: flex;
    flex-direction: column;
    gap: var(--space-sm);
    pointer-events: none;
    width: calc(100% - var(--space-xl) * 2);
    max-width: 400px;
}

.toast {
    padding: var(--space-md) var(--space-lg);
    border-radius: var(--radius-md);
    font-size: var(--font-size-sm);
    font-weight: 500;
    text-align: center;
    pointer-events: auto;
    animation: toastIn 300ms ease forwards;
    box-shadow: var(--shadow-md);
}

.toast.success {
    background: var(--success);
    color: #fff;
}

.toast.error {
    background: var(--danger);
    color: #fff;
}

.toast.info {
    background: var(--accent);
    color: #fff;
}

.toast.fade-out {
    animation: toastOut 300ms ease forwards;
}

@keyframes toastIn {
    from { opacity: 0; transform: translateY(-20px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes toastOut {
    from { opacity: 1; transform: translateY(0); }
    to { opacity: 0; transform: translateY(-20px); }
}

/* Custom confirm dialog */
.confirm-dialog {
    position: fixed;
    inset: 0;
    z-index: 10001;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: var(--space-lg);
}

.confirm-dialog.hidden {
    display: none;
}

.confirm-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(4px);
}

.confirm-box {
    position: relative;
    z-index: 1;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-xl);
    padding: var(--space-xl) var(--space-lg) var(--space-lg);
    width: 100%;
    max-width: 320px;
    text-align: center;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
    animation: confirmIn 200ms ease;
}

@keyframes confirmIn {
    from { opacity: 0; transform: scale(0.9); }
    to { opacity: 1; transform: scale(1); }
}

.confirm-icon {
    margin-bottom: var(--space-md);
}

.confirm-icon svg {
    width: 48px;
    height: 48px;
}

.confirm-title {
    font-size: var(--font-size-lg);
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: var(--space-sm);
}

.confirm-message {
    font-size: var(--font-size-sm);
    color: var(--text-muted);
    margin-bottom: var(--space-lg);
    line-height: 1.5;
}

.confirm-actions {
    display: flex;
    gap: var(--space-sm);
}

.confirm-btn {
    flex: 1;
    padding: var(--space-md);
    border-radius: var(--radius-md);
    font-size: var(--font-size-sm);
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s;
    border: 1px solid var(--border-color);
}

.confirm-btn:active {
    transform: scale(0.96);
}

.confirm-btn-cancel {
    background: var(--bg-input);
    color: var(--text-primary);
}

.confirm-btn-danger {
    background: var(--danger);
    color: #fff;
    border-color: var(--danger);
}

/* Scrollbar styling */
::-webkit-scrollbar {
    width: 4px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--text-muted);
    border-radius: 4px;
}
