:root {
    --bg-dark: #0b0f17;
    --bg-card: rgba(23, 32, 51, 0.65);
    --bg-card-hover: rgba(30, 43, 68, 0.85);
    --border-color: rgba(255, 255, 255, 0.08);
    --border-glow: rgba(6, 182, 212, 0.3);
    
    --text-main: #f3f4f6;
    --text-muted: #9ca3af;
    --text-dim: #6b7280;
    
    --primary: #06b6d4;
    --primary-hover: #0891b2;
    --accent: #6366f1;
    --accent-hover: #4f46e5;
    
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    
    --font-heading: 'Outfit', sans-serif;
    --font-body: 'Inter', sans-serif;
    
    --radius-sm: 8px;
    --radius-md: 14px;
    --radius-lg: 20px;
    --shadow-glow: 0 0 25px rgba(6, 182, 212, 0.15);
}

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

body {
    background-color: var(--bg-dark);
    background-image: 
        radial-gradient(at 0% 0%, rgba(99, 102, 241, 0.12) 0px, transparent 50%),
        radial-gradient(at 100% 100%, rgba(6, 182, 212, 0.12) 0px, transparent 50%);
    background-attachment: fixed;
    color: var(--text-main);
    font-family: var(--font-body);
    min-height: 100vh;
    line-height: 1.5;
}

.app-wrapper {
    max-width: 1350px;
    margin: 0 auto;
    padding: 24px 20px;
}

/* Glassmorphism utility */
.glass-card {
    background: var(--bg-card);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.37);
}

/* Header Navbar */
.navbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 24px;
    margin-bottom: 24px;
    background: rgba(15, 23, 42, 0.75);
    backdrop-filter: blur(20px);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
}

.brand {
    display: flex;
    align-items: center;
    gap: 14px;
}

.brand-icon {
    width: 46px;
    height: 46px;
    border-radius: 12px;
    background: linear-gradient(135deg, var(--primary), var(--accent));
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.4rem;
    color: #fff;
    box-shadow: var(--shadow-glow);
}

.brand-text h1 {
    font-family: var(--font-heading);
    font-size: 1.6rem;
    font-weight: 700;
    color: #fff;
    letter-spacing: -0.5px;
    line-height: 1.2;
}

.brand-text h1 span {
    color: var(--primary);
}

.sub-badge {
    font-size: 0.75rem;
    color: var(--primary);
    background: rgba(6, 182, 212, 0.12);
    padding: 2px 8px;
    border-radius: 20px;
    border: 1px solid rgba(6, 182, 212, 0.2);
    font-weight: 500;
}

.navbar-actions {
    display: flex;
    gap: 12px;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 18px;
    border-radius: var(--radius-sm);
    font-family: var(--font-heading);
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.25s ease;
    border: none;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary), #0891b2);
    color: #fff;
    box-shadow: 0 4px 14px rgba(6, 182, 212, 0.3);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(6, 182, 212, 0.45);
}

.glow-btn {
    position: relative;
    overflow: hidden;
}

.glow-btn::after {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: linear-gradient(60deg, transparent, rgba(255, 255, 255, 0.2), transparent);
    transform: rotate(30deg);
    transition: 0.5s;
}

.glow-btn:hover::after {
    left: 100%;
}

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

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

/* Stats Cards */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 18px;
    margin-bottom: 24px;
}

.stat-card {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 20px;
    transition: transform 0.2s ease;
}

.stat-card:hover {
    transform: translateY(-3px);
}

.stat-card.warning-border {
    border-left: 4px solid var(--warning);
}

.stat-icon {
    width: 50px;
    height: 50px;
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.3rem;
}

.icon-total { background: rgba(99, 102, 241, 0.15); color: var(--accent); }
.icon-scadenza { background: rgba(245, 158, 11, 0.15); color: var(--warning); }
.icon-attivi { background: rgba(16, 185, 129, 0.15); color: var(--success); }
.icon-saved { background: rgba(6, 182, 212, 0.15); color: var(--primary); }

.stat-info {
    display: flex;
    flex-direction: column;
}

.stat-label {
    font-size: 0.8rem;
    color: var(--text-muted);
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.stat-value {
    font-family: var(--font-heading);
    font-size: 1.8rem;
    font-weight: 700;
    color: #fff;
}

.text-warning { color: var(--warning); }
.text-success { color: var(--success); }
.text-accent { color: var(--primary); }

/* Filter Toolbar */
.filter-toolbar {
    padding: 18px 22px;
    margin-bottom: 24px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.search-box {
    position: relative;
    width: 100%;
}

.search-icon {
    position: absolute;
    left: 16px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-dim);
    font-size: 1rem;
}

.search-box input {
    width: 100%;
    padding: 12px 16px 12px 46px;
    background: rgba(15, 23, 42, 0.6);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: #fff;
    font-size: 0.95rem;
    outline: none;
    transition: all 0.2s ease;
}

.search-box input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 12px rgba(6, 182, 212, 0.25);
}

.filters-group {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 14px;
}

.select-wrapper {
    position: relative;
    min-width: 200px;
}

.select-icon {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--primary);
    pointer-events: none;
}

.select-wrapper select {
    width: 100%;
    padding: 10px 14px 10px 38px;
    background: rgba(15, 23, 42, 0.8);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-main);
    font-family: var(--font-body);
    font-size: 0.88rem;
    outline: none;
    cursor: pointer;
}

.status-tabs {
    display: flex;
    background: rgba(15, 23, 42, 0.8);
    padding: 4px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-color);
    gap: 4px;
}

.tab-btn {
    padding: 8px 14px;
    background: transparent;
    border: none;
    border-radius: 6px;
    color: var(--text-muted);
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.tab-btn:hover {
    color: #fff;
}

.tab-btn.active {
    background: var(--accent);
    color: #fff;
    font-weight: 600;
    box-shadow: 0 2px 8px rgba(99, 102, 241, 0.3);
}

.view-switcher {
    display: flex;
    gap: 4px;
    background: rgba(15, 23, 42, 0.8);
    padding: 4px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-color);
}

.view-btn {
    width: 36px;
    height: 34px;
    background: transparent;
    border: none;
    color: var(--text-muted);
    border-radius: 6px;
    cursor: pointer;
}

.view-btn.active {
    background: rgba(255, 255, 255, 0.12);
    color: var(--primary);
}

/* Notice Header */
.notice-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 18px;
    padding: 0 4px;
}

.notice-title {
    display: flex;
    align-items: center;
    gap: 12px;
}

.notice-title h3 {
    font-family: var(--font-heading);
    font-size: 1.25rem;
    color: #fff;
}

.count-badge {
    background: rgba(6, 182, 212, 0.15);
    color: var(--primary);
    padding: 3px 10px;
    border-radius: 12px;
    font-size: 0.8rem;
    font-weight: 600;
}

.sorting-note {
    font-size: 0.85rem;
    color: var(--text-muted);
}

.sorting-note strong {
    color: var(--primary);
}

/* Scraping Banner */
.scraping-banner {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 16px 20px;
    background: rgba(6, 182, 212, 0.12);
    border: 1px solid rgba(6, 182, 212, 0.3);
    border-radius: var(--radius-md);
    margin-bottom: 24px;
    animation: fadeIn 0.3s ease;
}

.banner-spinner {
    width: 24px;
    height: 24px;
    border: 3px solid rgba(6, 182, 212, 0.3);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

.hidden {
    display: none !important;
}

/* Concorsi Grid View */
.concorsi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(360px, 1fr));
    gap: 20px;
}

.concorso-card {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding: 22px;
    transition: all 0.25s ease;
    position: relative;
    overflow: hidden;
}

.concorso-card:hover {
    transform: translateY(-4px);
    border-color: var(--border-glow);
    box-shadow: var(--shadow-glow);
}

.concorso-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 10px;
    margin-bottom: 12px;
}

.category-tag {
    font-size: 0.72rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 4px 10px;
    border-radius: 20px;
    background: rgba(255, 255, 255, 0.06);
    color: var(--primary);
    border: 1px solid rgba(6, 182, 212, 0.2);
}

.bookmark-btn {
    background: transparent;
    border: none;
    color: var(--text-dim);
    font-size: 1.1rem;
    cursor: pointer;
    transition: color 0.2s ease;
}

.bookmark-btn:hover, .bookmark-btn.active {
    color: #f59e0b;
}

.concorso-title {
    font-family: var(--font-heading);
    font-size: 1.1rem;
    font-weight: 600;
    color: #fff;
    line-height: 1.35;
    margin-bottom: 10px;
}

.concorso-ente {
    font-size: 0.85rem;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 14px;
}

.concorso-desc {
    font-size: 0.88rem;
    color: var(--text-muted);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    margin-bottom: 18px;
}

.concorso-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-top: 14px;
    border-top: 1px solid var(--border-color);
}

/* Expiration countdown badge */
.countdown-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 0.82rem;
    font-weight: 600;
    padding: 5px 12px;
    border-radius: 8px;
}

.countdown-badge.danger {
    background: rgba(239, 68, 68, 0.15);
    color: #fca5a5;
    border: 1px solid rgba(239, 68, 68, 0.3);
}

.countdown-badge.warning {
    background: rgba(245, 158, 11, 0.15);
    color: #fde047;
    border: 1px solid rgba(245, 158, 11, 0.3);
}

.countdown-badge.success {
    background: rgba(16, 185, 129, 0.15);
    color: #6ee7b7;
    border: 1px solid rgba(16, 185, 129, 0.3);
}

.countdown-badge.expired {
    background: rgba(107, 114, 128, 0.2);
    color: #9ca3af;
    border: 1px solid rgba(107, 114, 128, 0.3);
}

.link-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: var(--primary);
    font-size: 0.88rem;
    font-weight: 600;
    text-decoration: none;
    transition: transform 0.2s ease;
}

.link-btn:hover {
    color: #fff;
    transform: translateX(3px);
}

/* Table View */
.concorsi-table-wrapper {
    overflow-x: auto;
}

.concorsi-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 10px;
}

.concorsi-table th, .concorsi-table td {
    padding: 14px 16px;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
}

.concorsi-table th {
    background: rgba(15, 23, 42, 0.8);
    color: var(--text-muted);
    font-size: 0.8rem;
    text-transform: uppercase;
}

.concorsi-table td {
    font-size: 0.9rem;
}

/* Modal */
.modal-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.75);
    backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal-box {
    width: 90%;
    max-width: 700px;
    max-height: 85vh;
    overflow-y: auto;
    padding: 24px;
}

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

.modal-header h3 {
    font-family: var(--font-heading);
    font-size: 1.3rem;
}

.modal-close-btn {
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 1.6rem;
    cursor: pointer;
}

.add-site-form {
    margin-bottom: 24px;
    padding: 16px;
    background: rgba(15, 23, 42, 0.6);
    border-radius: var(--radius-sm);
}

.add-site-form h4 {
    font-size: 0.95rem;
    margin-bottom: 12px;
    color: var(--primary);
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1.5fr 1fr auto;
    gap: 10px;
}

.form-row input, .form-row select {
    padding: 8px 12px;
    background: rgba(15, 23, 42, 0.8);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    color: #fff;
    font-size: 0.85rem;
}

.sites-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.site-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    background: rgba(15, 23, 42, 0.5);
    border: 1px solid var(--border-color);
    border-radius: 8px;
}

.site-info strong {
    color: #fff;
    font-size: 0.9rem;
    display: block;
}

.site-info span {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.delete-site-btn {
    background: rgba(239, 68, 68, 0.15);
    color: var(--danger);
    border: 1px solid rgba(239, 68, 68, 0.3);
    padding: 6px 12px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.8rem;
}

.delete-site-btn:hover {
    background: var(--danger);
    color: #fff;
}

@media (max-width: 768px) {
    .navbar {
        flex-direction: column;
        gap: 16px;
    }
    
    .filters-group {
        flex-direction: column;
        align-items: stretch;
    }
    
    .form-row {
        grid-template-columns: 1fr;
    }
}
