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

:root {
    --bg-main: #F4F7F6; /* Light gray/pearl background */
    --bg-panel: rgba(255, 255, 255, 0.85); /* Frosted Glass */
    --glass-border: rgba(0, 0, 0, 0.05);
    --glass-highlight: rgba(255, 255, 255, 1);
    
    --text-main: #1A1F2B; /* Dark navy/almost black for high contrast */
    --text-muted: #64748B; /* Slate gray */
    
    /* Vibrant Accents */
    --accent-primary: #0066FF; /* Electric Blue */
    --accent-hover: #0052CC;
    --accent-shadow: rgba(0, 102, 255, 0.2);
    
    --success: #00C853; /* Vibrant Green */
    --success-bg: rgba(0, 200, 83, 0.1);
    
    --danger: #FF3B30; /* Apple Red */
    --danger-bg: rgba(255, 59, 48, 0.1);
    
    --warning: #FF9500;
}

body.dark-theme {
    --bg-main: #0F172A; /* Slate navy */
    --bg-panel: rgba(30, 41, 59, 0.75); /* Dark frosted glass */
    --glass-border: rgba(255, 255, 255, 0.08);
    --glass-highlight: rgba(255, 255, 255, 0.03);
    
    --text-main: #F8FAFC; /* Crisp white */
    --text-muted: #94A3B8; /* Muted slate */
    
    --accent-primary: #3B82F6; /* Brighter blue for dark mode visibility */
    --accent-shadow: rgba(59, 130, 246, 0.3);
}
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: 'Outfit', sans-serif;
}

html, body {
    overflow-x: hidden;
    max-width: 100vw;
    overscroll-behavior-y: none; /* Prevents iOS elastic bounce on the main body */
    -webkit-text-size-adjust: 100%;
    -webkit-tap-highlight-color: transparent;
    user-select: none; /* Make it feel like an app */
    -webkit-user-select: none;
    -webkit-touch-callout: none;
}

/* Allow text selection in inputs */
input, textarea, .selectable {
    user-select: auto;
    -webkit-user-select: auto;
}

body {
    background-color: var(--bg-main);
    color: var(--text-main);
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    height: 100vh; /* Fixed height for app feel */
    background-image: 
        radial-gradient(circle at 15% 50%, rgba(0, 102, 255, 0.03), transparent 35%),
        radial-gradient(circle at 85% 30%, rgba(0, 200, 83, 0.03), transparent 35%);
    background-attachment: fixed;
    overflow: hidden; /* Lock the body from scrolling at all */
}

/* Scrollbar moderna */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(0,0,0,0.15); border-radius: 10px; }
::-webkit-scrollbar-thumb:hover { background: rgba(0,0,0,0.25); }

/* --- GLASSMORPHISM COMPONENTS --- */
.glass-panel {
    background: var(--bg-panel);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--glass-border);
    border-top: 1px solid var(--glass-highlight);
    border-radius: 20px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.03);
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275), box-shadow 0.3s ease;
}

.glass-panel:hover {
    transform: translateY(-2px);
    box-shadow: 0 15px 35px rgba(0, 0, 0, 0.06), 0 0 15px rgba(0, 102, 255, 0.05);
}

/* --- BUTTONS --- */
.btn-primary {
    background: linear-gradient(135deg, var(--accent-primary), var(--accent-hover));
    color: #FFF;
    border: none;
    padding: 12px 24px;
    border-radius: 12px;
    font-weight: 700;
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 6px 20px var(--accent-shadow);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.btn-primary:hover {
    transform: translateY(-2px) scale(1.02);
    box-shadow: 0 8px 25px var(--accent-shadow);
}

.btn-primary:active {
    transform: translateY(1px) scale(0.98);
}

.btn-secondary {
    background: rgba(0, 0, 0, 0.05);
    color: var(--text-main);
    border: none;
    padding: 10px 20px;
    border-radius: 12px;
    font-weight: 700;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.3s ease;
}

.btn-secondary:hover {
    background: rgba(0, 0, 0, 0.1);
    transform: translateY(-2px);
}

body.dark-theme .btn-secondary {
    background: rgba(255, 255, 255, 0.1);
}

body.dark-theme .btn-secondary:hover {
    background: rgba(255, 255, 255, 0.15);
}

/* --- LOGIN PAGE --- */
.auth-container {
    width: 100%;
    max-width: 420px;
    padding: 20px;
    position: relative;
    z-index: 10;
}

.auth-box {
    padding: 40px;
    text-align: center;
}

.brand {
    font-size: 2.2rem;
    font-weight: 800;
    margin-bottom: 30px;
    background: linear-gradient(135deg, var(--text-main), var(--text-muted));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    letter-spacing: -1px;
}

.brand i {
    color: var(--accent-primary);
    -webkit-text-fill-color: var(--accent-primary);
    margin-right: 5px;
}

.form-group {
    margin-bottom: 25px;
    text-align: left;
    position: relative;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-size: 0.85rem;
    color: var(--text-muted);
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.form-group input {
    width: 100%;
    padding: 15px 15px 15px 45px;
    border-radius: 12px;
    border: 1px solid rgba(0,0,0,0.1);
    background: var(--bg-main);
    color: var(--text-main);
    font-size: 1rem;
    transition: all 0.3s ease;
    box-shadow: inset 0 2px 4px rgba(0,0,0,0.02);
}

.form-group i {
    position: absolute;
    left: 15px;
    bottom: 16px;
    color: var(--text-muted);
    font-size: 1.1rem;
    transition: color 0.3s ease;
}

.form-group input:focus {
    outline: none;
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 4px rgba(0, 102, 255, 0.1);
}

.form-group input:focus + i {
    color: var(--accent-primary);
}

.toggle-auth {
    margin-top: 25px;
    font-size: 0.95rem;
    color: var(--text-muted);
    font-weight: 500;
}

.toggle-auth span {
    color: var(--accent-primary);
    cursor: pointer;
    font-weight: 700;
    transition: color 0.3s ease;
}

.toggle-auth span:hover {
    color: var(--accent-hover);
}

/* --- DASHBOARD APP --- */
.app-container {
    width: 100%;
    max-width: 1200px;
    height: 100vh;
    display: flex;
    flex-direction: column;
}

/* HEADER */
.app-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 30px;
    border-bottom: 1px solid var(--glass-border);
    background: var(--bg-panel);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-brand {
    font-size: 1.6rem;
    font-weight: 800;
    display: flex;
    align-items: center;
    gap: 10px;
    letter-spacing: -0.5px;
    color: var(--text-main);
}

.header-brand i {
    color: var(--accent-primary);
}

.user-profile {
    display: flex;
    align-items: center;
    gap: 12px;
    background: var(--bg-main);
    padding: 8px 16px;
    border-radius: 100px;
    border: 1px solid rgba(0,0,0,0.05);
    box-shadow: 0 2px 10px rgba(0,0,0,0.03);
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
}

.user-profile:hover {
    box-shadow: 0 4px 15px rgba(0,0,0,0.06);
}

.avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--accent-primary), #00D1FF);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    color: #FFF;
}

/* DROPDOWN MENU */
.dropdown-menu {
    position: absolute;
    top: calc(100% + 15px);
    right: 0;
    width: 260px;
    padding: 10px;
    border-radius: 16px;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    z-index: 200;
}

.user-profile.active .dropdown-menu {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.dropdown-header {
    padding: 15px;
    border-bottom: 1px solid var(--glass-border);
    margin-bottom: 10px;
}

.dropdown-item {
    padding: 12px 15px;
    display: flex;
    align-items: center;
    gap: 12px;
    color: var(--text-main);
    text-decoration: none;
    border-radius: 10px;
    transition: background 0.2s ease;
    font-weight: 600;
}

.dropdown-item:hover {
    background: rgba(0,0,0,0.03);
}
.dropdown-item i {
    color: var(--text-muted);
    font-size: 1.1rem;
    width: 20px;
    text-align: center;
}

/* MAIN CONTENT & SIDEBAR */
.main-content {
    display: flex;
    flex-grow: 1;
    overflow: hidden;
}

.sidebar {
    width: 260px;
    border-right: 1px solid var(--glass-border);
    padding: 30px 20px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    background: transparent;
}

.menu-item {
    display: flex;
    align-items: center;
    gap: 15px;
    padding: 15px 20px;
    border-radius: 14px;
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.3s ease;
    font-weight: 700;
    font-size: 1.05rem;
}

.menu-item i {
    font-size: 1.2rem;
}

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

.menu-item.active {
    background: var(--accent-shadow);
    color: var(--accent-primary);
    border-left: 4px solid var(--accent-primary);
}

.content-area {
    flex-grow: 1;
    padding: 40px;
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch; /* Smooth scroll on iOS */
    position: relative;
    padding-bottom: 80px; /* Spazio per la barra di navigazione */
}

.view-section {
    animation: fadeScale 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes fadeScale {
    from { opacity: 0; transform: scale(0.98) translateY(10px); }
    to { opacity: 1; transform: scale(1) translateY(0); }
}

.topbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
}

.topbar h2 {
    font-size: 2rem;
    font-weight: 800;
    letter-spacing: -1px;
}

/* --- RADAR CARDS (GRID) --- */
.search-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 25px;
}

.search-card {
    padding: 25px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    min-height: 200px;
    position: relative;
    overflow: hidden;
}

.search-card::before {
    content: '';
    position: absolute;
    top: 0; left: 0; width: 100%; height: 4px;
    background: linear-gradient(90deg, var(--accent-primary), transparent);
    opacity: 0;
    transition: opacity 0.3s ease;
}

.search-card:hover::before {
    opacity: 1;
}

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

.card-header h3 {
    font-size: 1.4rem;
    font-weight: 800;
    max-width: 70%;
    word-wrap: break-word;
}

.badge {
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.card-body .detail {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 12px;
    color: var(--text-muted);
    font-size: 0.95rem;
    font-weight: 500;
}

.card-body .detail i {
    color: var(--accent-primary);
    width: 20px;
    text-align: center;
}

.card-body .detail strong {
    color: var(--text-main);
    font-weight: 700;
}

.card-footer {
    display: flex;
    justify-content: flex-end;
    margin-top: 20px;
    border-top: 1px solid var(--glass-border);
    padding-top: 15px;
}

.btn-icon {
    background: transparent;
    color: var(--text-muted);
    border: none;
    font-size: 1.2rem;
    cursor: pointer;
    transition: all 0.3s ease;
    padding: 8px;
    border-radius: 8px;
}

.btn-icon:hover {
    background: var(--danger-bg);
    color: var(--danger);
    transform: scale(1.1);
}

.search-card.add-new {
    border: 2px dashed rgba(0,0,0,0.1);
    background: transparent;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: none;
}

.search-card.add-new:hover {
    border-color: var(--accent-primary);
    background: var(--bg-main);
    box-shadow: 0 10px 30px rgba(0, 102, 255, 0.05);
}

.search-card.add-new i {
    font-size: 3rem;
    color: var(--text-muted);
    margin-bottom: 15px;
    transition: all 0.3s ease;
}

.search-card.add-new:hover i {
    color: var(--accent-primary);
    transform: scale(1.1);
}

/* --- INBOX --- */
.inbox-list {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.inbox-item {
    padding: 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-left: 4px solid var(--accent-primary);
}

.inbox-item.unread {
    border-left: 4px solid var(--accent-primary);
}

.inbox-item h4 {
    font-size: 1.2rem;
    margin-bottom: 5px;
    font-weight: 700;
}

.inbox-price {
    font-size: 1.4rem;
    font-weight: 800;
    color: var(--success);
}

/* --- SETTINGS --- */
.settings-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 25px;
}

.setting-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 15px;
    padding: 15px 0;
    border-bottom: 1px solid var(--glass-border);
}

.setting-row:last-child {
    border-bottom: none;
    padding-bottom: 0;
}

/* --- MODAL --- */
.modal-overlay {
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0,0,0,0.4);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

.modal-overlay.active {
    opacity: 1;
    visibility: visible;
}

.modal-box {
    width: 90%;
    max-width: 500px;
    padding: 40px;
    transform: translateY(20px) scale(0.95);
    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.modal-overlay.active .modal-box {
    transform: translateY(0) scale(1);
}

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

.modal-header h3 {
    font-size: 1.5rem;
    font-weight: 800;
}

/* --- MOBILE BOTTOM NAV --- */
.bottom-nav {
    display: none;
    position: fixed;
    bottom: 0; left: 0; width: 100%;
    background: var(--bg-panel);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-top: 1px solid var(--glass-border);
    z-index: 100;
    padding-bottom: env(safe-area-inset-bottom);
}

.bottom-nav .nav-item {
    flex: 1;
    background: none;
    border: none;
    color: var(--text-muted);
    padding: 15px 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    font-size: 0.75rem;
    font-weight: 700;
    transition: all 0.3s ease;
}

.bottom-nav .nav-item i {
    font-size: 1.3rem;
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.bottom-nav .nav-item.active {
    color: var(--accent-primary);
}

.bottom-nav .nav-item.active i {
    transform: translateY(-4px) scale(1.1);
}

@media (max-width: 768px) {
    .sidebar { display: none; }
    .bottom-nav { display: flex; }
    .app-header { padding: 10px 15px; } /* Ancora più compatta */
    .header-brand { font-size: 1.4rem; } /* Testo logo più piccolo */
    .user-profile { padding: 6px 10px; gap: 8px; }
    #profileNameDisplay { display: none !important; } /* Nascondi nome su mobile per non sbordare */
    .content-area { padding: 20px; padding-bottom: 100px; }
    .settings-grid { grid-template-columns: 1fr; }
    .search-grid { grid-template-columns: 1fr; }
    .auth-box { padding: 30px 20px; }
}

/* Toggle Switch UI */
.switch {
  position: relative;
  display: inline-block;
  width: 50px;
  height: 28px;
}
.switch input { 
  opacity: 0;
  width: 0;
  height: 0;
}
.slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: #ccc;
  transition: .4s;
  border-radius: 34px;
}
.slider:before {
  position: absolute;
  content: "";
  height: 20px;
  width: 20px;
  left: 4px;
  bottom: 4px;
  background-color: white;
  transition: .4s;
  border-radius: 50%;
}
input:checked + .slider {
  background-color: var(--accent-primary);
}
input:checked + .slider:before {
  transform: translateX(22px);
}

/* Skeleton Loading Animation */
@keyframes shimmer {
    0% { background-position: -1000px 0; }
    100% { background-position: 1000px 0; }
}
.skeleton {
    background: linear-gradient(90deg, rgba(0,0,0,0.05) 25%, rgba(0,0,0,0.1) 50%, rgba(0,0,0,0.05) 75%);
    background-size: 1000px 100%;
    animation: shimmer 2s infinite linear;
    border-radius: 8px;
    color: transparent !important;
}
