:root {
    --primary-color: #4a90e2;
    --secondary-color: #f39c12;
    --bg-color: #f0f2f5;
    --card-bg: rgba(255, 255, 255, 0.8);
    --text-color: #333;
    --danger-color: #e74c3c;
    --success-color: #2ecc71;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: var(--bg-color);
    background-image: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
    min-height: 100vh;
    margin: 0;
    padding: 20px;
    color: var(--text-color);
    display: flex;
    justify-content: center;
}

.container {
    width: 100%;
    max-width: 1600px;
}

h1 {
    text-align: center;
    color: #2c3e50;
    margin-bottom: 30px;
    font-weight: 300;
    letter-spacing: 1px;
}

.card {
    background: var(--card-bg);
    backdrop-filter: blur(10px);
    border-radius: 15px;
    padding: 25px;
    box-shadow: 0 8px 32px 0 rgba(31, 38, 135, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.18);
    margin-bottom: 30px;
}

form {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.form-group {
    display: flex;
    flex-direction: column;
}

label {
    margin-bottom: 5px;
    font-size: 0.9em;
    color: #666;
}

input,
select {
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 8px;
    font-size: 1em;
    outline: none;
    transition: border-color 0.3s;
}

input:focus,
select:focus {
    border-color: var(--primary-color);
}

button {
    padding: 12px;
    background-color: var(--primary-color);
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 1.1em;
    font-weight: bold;
    transition: background-color 0.3s, transform 0.1s;
    margin-top: 10px;
}

button:hover {
    background-color: #357abd;
}

button:active {
    transform: scale(0.98);
}

.grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 20px;
}

.item-card {
    background: white;
    padding: 20px;
    border-radius: 12px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.05);
    position: relative;
    border-top: 5px solid var(--primary-color);
}

.item-card.freezer {
    border-top-color: #3498db;
}

.item-card.dispensa {
    border-top-color: #e67e22;
}

.item-card h3 {
    margin: 0 0 10px 0;
    font-size: 1.2em;
}

.item-card p {
    margin: 5px 0;
    color: #666;
    font-size: 0.9em;
}

.tag {
    display: inline-block;
    padding: 3px 8px;
    border-radius: 4px;
    font-size: 0.75em;
    color: white;
    margin-bottom: 10px;
}

.tag-loc {
    background-color: #3498db;
}

.tag-cat {
    background-color: #9b59b6;
}

.tag-dispensa {
    background-color: #e67e22;
}

.tag-freezer {
    background-color: #3498db;
}

.delete-btn {
    position: absolute;
    top: 15px;
    right: 15px;
    color: var(--danger-color);
    text-decoration: none;
    font-weight: bold;
    font-size: 1.2em;
    opacity: 0.5;
    transition: opacity 0.3s;
}

.delete-btn:hover {
    opacity: 1;
}

.status-expired {
    background-color: #f8d7da !important;
    border-top-color: var(--danger-color) !important;
}

.status-expired .expiry-info {
    color: var(--danger-color) !important;
    font-weight: bold;
}

.status-warning {
    background-color: #fff3cd !important;
    border-top-color: #ffc107 !important;
}

.status-warning .expiry-info {
    color: #856404 !important;
    font-weight: bold;
}

/* Quantity Actions */
.qty-actions {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 15px;
    background: #f1f3f5;
    padding: 5px 10px;
    border-radius: 8px;
    width: fit-content;
}

.qty-btn {
    background: #dee2e6;
    color: #495057;
    border: none;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 1.2em;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    line-height: 0;
}

.qty-btn:hover {
    background: #ced4da;
}

.qty-btn.plus:hover {
    background: var(--success-color);
    color: white;
}

.qty-btn.minus:hover {
    background: var(--danger-color);
    color: white;
}

.qty-val {
    font-weight: bold;
    font-size: 1.1em;
    min-width: 40px;
    text-align: center;
}

/* Search Bar */
.search-container {
    margin-bottom: 25px;
}

.search-bar {
    width: 100%;
    padding: 12px 20px;
    border-radius: 25px;
    border: 1px solid #ddd;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.05);
    font-size: 1.1em;
    transition: all 0.3s;
}

.search-bar:focus {
    border-color: var(--primary-color);
    box-shadow: 0 4px 12px rgba(74, 144, 226, 0.2);
}

/* Auth Styles */
.login-body {
    align-items: center;
}

.login-container {
    width: 100%;
    max-width: 400px;
}

.login-card h1 {
    font-size: 1.5em;
    margin-bottom: 20px;
}

.error {
    background: #f8d7da;
    color: #721c24;
    padding: 10px;
    border-radius: 8px;
    margin-bottom: 15px;
    font-size: 0.9em;
    text-align: center;
}

.password-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

.password-wrapper input {
    padding-right: 40px;
    width: 100%;
}

.toggle-password {
    position: absolute;
    right: 10px;
    cursor: pointer;
    user-select: none;
    font-size: 1.2em;
    opacity: 0.6;
}

.toggle-password:hover {
    opacity: 1;
}

/* Navbar/Header styles */
.header-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.user-info {
    font-size: 0.9em;
    color: #666;
}

.logout-link {
    color: var(--danger-color);
    text-decoration: none;
    margin-left: 10px;
}

.logout-link:hover {
    text-decoration: underline;
}

.admin-link {
    color: var(--primary-color);
    text-decoration: none;
    font-weight: bold;
}

/* SHARED NAVIGATION STYLES */
.horizontal-nav {
    background: white;
    border-radius: 12px;
    padding: 15px 20px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.05);
    margin-bottom: 20px;
    position: sticky;
    top: 20px;
    z-index: 100;
}

.nav-menu {
    display: flex;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap;
}

.nav-item {
    display: inline-block;
    padding: 10px 20px;
    border-radius: 8px;
    background: #f8f9fa;
    border: 1px solid #eee;
    text-decoration: none;
    color: var(--text-color);
    font-weight: 600;
    transition: all 0.2s;
    white-space: nowrap;
}

.nav-item.active {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
}

.nav-item:hover:not(.active) {
    background: #e9ecef;
}

.nav-divider {
    flex-grow: 1;
}

.user-pill {
    background: #eee;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 0.85em;
    display: flex;
    align-items: center;
    gap: 8px;
}

.content-area {
    background: white;
    border-radius: 12px;
    padding: 25px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.05);
}

.dashboard-layout {
    margin-top: 20px;
}

/* OTTIMIZZAZIONI PER TABLET ORIZZONTALE */
@media screen and (max-width: 1300px) and (orientation: landscape) {
    body {
        padding: 5px;
    }

    .container {
        width: 100%;
        max-width: 100%;
    }

    .horizontal-nav {
        padding: 5px 15px;
        border-radius: 0 0 8px 8px;
    }

    .nav-item {
        padding: 6px 12px;
        font-size: 0.85em;
    }

    .sticky-content-wrap {
        padding: 10px 15px;
        margin: 5px 5px 0 5px;
    }

    .sticky-content-wrap h2 {
        font-size: 1.2em;
    }

    .filter-bar {
        padding: 8px;
        gap: 10px;
        margin-top: 10px;
    }

    .filter-group label {
        font-size: 0.65em;
    }

    .filter-group select,
    .filter-group input {
        height: 32px;
        padding: 5px;
        font-size: 0.85em;
    }

    .list-row {
        padding: 8px 12px;
    }
}

/* OTTIMIZZAZIONI PER CELLULARI (SAMSUNG / LISTA SPESA) */
@media screen and (max-width: 600px) {
    .container {
        padding: 5px;
    }

    .horizontal-nav {
        padding: 8px;
        border-radius: 0 0 10px 10px;
    }

    .nav-item {
        padding: 8px;
        font-size: 0.8em;
    }

    /* Lista della spesa più compatta e leggibile su cellulare */
    .list-row {
        padding: 12px 10px;
        border-radius: 10px;
        margin-bottom: 8px;
    }

    .list-row .list-cell h3 {
        font-size: 1em;
    }

    .qty-controls {
        gap: 15px;
    }

    .qty-btn {
        width: 35px;
        height: 35px;
        /* Bottoni più grandi per facilitare il tocco su cellulare */
        font-size: 1.4em;
    }
}

.filter-group.select-wrap {
    width: 140px;
}

.list-header {
    margin: 10px -15px -10px -15px;
    padding: 8px 10px;
    font-size: 0.75em;
}

.list-row {
    padding: 6px 10px;
    font-size: 0.85em;
}

.row-code {
    font-size: 1.1em;
}

.row-name div:first-child {
    font-size: 1em !important;
}

.qty-input-manual {
    font-size: 1em;
    width: 50px;
}

.qty-mini-btn {
    width: 24px;
    height: 24px;
    font-size: 1em;
}

/* Fullscreen Button Style */
.fullscreen-btn {
    background: #34495e !important;
    color: #ecf0f1 !important;
    border: 1px solid #2c3e50 !important;
}

.fullscreen-btn:hover {
    background: #2c3e50 !important;
}

/* Admin Brands Management */
.brand-list {
    margin-top: 5px;
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
}

.brand-chip {
    background: #f1f3f5;
    border: 1px solid #dee2e6;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 0.8em;
    display: flex;
    align-items: center;
    gap: 5px;
    color: #444;
}

.brand-chip .remove-brand {
    color: var(--danger-color);
    text-decoration: none;
    font-weight: bold;
    cursor: pointer;
    font-size: 1.1em;
}

.brand-chip .remove-brand:hover {
    color: #c0392b;
}

.add-brand-inline {
    display: inline-block;
    margin-top: 10px;
    font-size: 0.85em;
    color: var(--primary-color);
    cursor: pointer;
    text-decoration: underline;
    font-weight: bold;
}

.marche-management-area {
    background: #f8f9fa;
    padding: 15px;
    border-radius: 8px;
    margin-top: 15px;
    border: 1px dashed #ccc;
}

.brand-edit-row {
    display: flex;
    gap: 10px;
    margin-bottom: 8px;
    align-items: center;
    background: white;
    padding: 8px;
    border-radius: 6px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.02);
}

.brand-edit-row input {
    padding: 6px 10px;
    font-size: 0.9em;
    border: 1px solid #ddd;
    border-radius: 4px;
}

/* Modal Styles */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 2000;
    backdrop-filter: blur(4px);
}

.modal-content {
    background: white;
    padding: 25px;
    border-radius: 12px;
    width: 95%;
    max-width: 600px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.1);
    position: relative;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    border-bottom: 1px solid #eee;
    padding-bottom: 10px;
}

.modal-header h2 {
    margin: 0;
    font-size: 1.4em;
    color: var(--primary-color);
}

.close-modal {
    background: none !important;
    border: none !important;
    font-size: 1.5em !important;
    cursor: pointer;
    color: #999;
    padding: 0 !important;
    margin: 0 !important;
    width: auto !important;
    height: auto !important;
}

.close-modal:hover {
    color: var(--danger-color) !important;
}

.btn-brands-count {
    background: #e9ecef !important;
    color: #495057 !important;
    border: 1px solid #ced4da !important;
    padding: 6px 12px !important;
    border-radius: 6px !important;
    font-size: 0.85em !important;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: all 0.2s;
    width: fit-content;
    margin: 5px 0 !important;
}

.btn-brands-count:hover {
    background: #dee2e6 !important;
    border-color: #adb5bd !important;
}

.brands-badge {
    background: var(--primary-color);
    color: white;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 0.9em;
    font-weight: bold;
}