/* ===========================================
   Demo-Menu - Admin Styles
   Clean, professional dashboard design
   =========================================== */

/* CSS Variables */
:root {
    --primary: #2d3436;
    --primary-light: #636e72;
    --accent: #0984e3;
    --accent-hover: #0770c2;
    --success: #00b894;
    --warning: #fdcb6e;
    --danger: #d63031;
    --background: #f5f6fa;
    --surface: #ffffff;
    --text: #2d3436;
    --text-light: #636e72;
    --text-muted: #b2bec3;
    --border: #dfe6e9;
    --shadow: 0 2px 12px rgba(0, 0, 0, 0.08);
    --shadow-lg: 0 8px 30px rgba(0, 0, 0, 0.12);
    --radius: 12px;
    --radius-sm: 8px;
    --transition: all 0.3s ease;
    --font: 'Inter', sans-serif;
    --sidebar-width: 260px;
}

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

body {
    font-family: var(--font);
    background: var(--background);
    color: var(--text);
    line-height: 1.6;
    min-height: 100vh;
    overflow-x: hidden;
}

html {
    overflow-x: hidden;
}

/* ===========================================
   Login Page
   =========================================== */
.login-container {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem;
    background: linear-gradient(135deg, var(--primary) 0%, #1e272e 100%);
}

.login-card {
    background: var(--surface);
    border-radius: var(--radius);
    padding: 2.5rem;
    width: 100%;
    max-width: 400px;
    box-shadow: var(--shadow-lg);
}

.login-header {
    text-align: center;
    margin-bottom: 2rem;
}

.login-header h1 {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--primary);
    margin-bottom: 0.25rem;
}

.login-header p {
    color: var(--text-light);
    font-size: 0.95rem;
}

.login-form {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

.login-error {
    color: var(--danger);
    font-size: 0.875rem;
    text-align: center;
    min-height: 1.25rem;
}

.back-link {
    display: block;
    text-align: center;
    margin-top: 1.5rem;
    color: var(--text-light);
    text-decoration: none;
    font-size: 0.9rem;
    transition: var(--transition);
}

.back-link:hover {
    color: var(--accent);
}

/* ===========================================
   Admin Dashboard Layout
   =========================================== */
.admin-container {
    display: flex;
    min-height: 100vh;
}

/* Sidebar */
.sidebar {
    width: var(--sidebar-width);
    background: var(--surface);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    position: fixed;
    height: 100vh;
    z-index: 100;
}

.sidebar-header {
    padding: 1.5rem;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.sidebar-header h2 {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--primary);
}

.badge {
    font-size: 0.7rem;
    padding: 0.25rem 0.5rem;
    background: var(--accent);
    color: white;
    border-radius: 50px;
    font-weight: 600;
    text-transform: uppercase;
}

.sidebar-nav {
    flex: 1;
    padding: 1rem 0;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    width: 100%;
    padding: 0.875rem 1.5rem;
    background: transparent;
    border: none;
    font-family: var(--font);
    font-size: 0.95rem;
    color: var(--text-light);
    cursor: pointer;
    transition: var(--transition);
    text-align: left;
}

.nav-item:hover {
    background: var(--background);
    color: var(--text);
}

.nav-item.active {
    background: rgba(9, 132, 227, 0.1);
    color: var(--accent);
    border-right: 3px solid var(--accent);
}

.nav-icon {
    font-size: 1.25rem;
}

.sidebar-footer {
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.sidebar-link {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--text-light);
    text-decoration: none;
    font-size: 0.9rem;
    padding: 0.5rem 0;
    transition: var(--transition);
}

.sidebar-link:hover {
    color: var(--accent);
}

/* Main Content */
.admin-main {
    flex: 1;
    margin-left: var(--sidebar-width);
    padding: 2rem;
}

.admin-section {
    animation: fadeIn 0.3s ease;
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
    gap: 1rem;
}

.section-header h1 {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--primary);
}

/* Filter Bar */
.filter-bar {
    margin-bottom: 1.5rem;
}

/* ===========================================
   Form Elements
   =========================================== */
.form-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.form-group label {
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text);
}

.form-group small {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.form-group input[type="text"],
.form-group input[type="password"],
.form-group input[type="number"],
.form-group input[type="email"],
.form-group textarea,
.form-group select,
.form-select {
    padding: 0.75rem 1rem;
    border: 2px solid var(--border);
    border-radius: var(--radius-sm);
    font-family: var(--font);
    font-size: 0.95rem;
    color: var(--text);
    background: var(--surface);
    transition: var(--transition);
    width: 100%;
}

.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus,
.form-select:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(9, 132, 227, 0.1);
}

.form-row {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1rem;
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    cursor: pointer;
    font-size: 0.95rem;
}

.checkbox-label input[type="checkbox"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
    accent-color: var(--accent);
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: var(--radius-sm);
    font-family: var(--font);
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
    text-decoration: none;
}

.btn-primary {
    background: var(--accent);
    color: white;
}

.btn-primary:hover {
    background: var(--accent-hover);
}

.btn-outline {
    background: transparent;
    border: 2px solid var(--border);
    color: var(--text);
}

.btn-outline:hover {
    border-color: var(--text-light);
    background: var(--background);
}

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

.btn-danger:hover {
    background: #c0392b;
}

.btn-sm {
    padding: 0.5rem 1rem;
    font-size: 0.85rem;
}

.btn-full {
    width: 100%;
}

.btn-icon {
    padding: 0.5rem;
    min-width: 36px;
    height: 36px;
}

/* ===========================================
   Data Table
   =========================================== */
.data-table-container {
    background: var(--surface);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
}

.data-table th,
.data-table td {
    padding: 1rem;
    text-align: left;
    border-bottom: 1px solid var(--border);
}

.data-table th {
    background: var(--background);
    font-weight: 600;
    font-size: 0.85rem;
    color: var(--text-light);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.data-table td {
    font-size: 0.95rem;
    vertical-align: middle;
}

.data-table tbody tr:hover {
    background: var(--background);
}

.data-table tbody tr:last-child td {
    border-bottom: none;
}

.table-image {
    width: 60px;
    height: 60px;
    object-fit: cover;
    border-radius: var(--radius-sm);
    background: var(--border);
}

.table-image-placeholder {
    width: 60px;
    height: 60px;
    border-radius: var(--radius-sm);
    background: var(--border);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    font-size: 1.5rem;
}

.table-actions {
    display: flex;
    gap: 0.5rem;
}

.status-badge {
    display: inline-block;
    padding: 0.25rem 0.75rem;
    border-radius: 50px;
    font-size: 0.8rem;
    font-weight: 500;
}

.status-badge.available {
    background: rgba(0, 184, 148, 0.1);
    color: var(--success);
}

.status-badge.unavailable {
    background: rgba(214, 48, 49, 0.1);
    color: var(--danger);
}

.empty-table {
    padding: 3rem;
    text-align: center;
    color: var(--text-light);
}

/* ===========================================
   Modal
   =========================================== */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: var(--transition);
}

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

.modal-content {
    background: var(--surface);
    border-radius: var(--radius);
    width: 100%;
    max-width: 500px;
    max-height: 90vh;
    overflow-y: auto;
    transform: scale(0.9);
    transition: var(--transition);
}

.modal.active .modal-content {
    transform: scale(1);
}

.modal-lg {
    max-width: 650px;
}

.modal-sm {
    max-width: 400px;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--border);
}

.modal-header h2 {
    font-size: 1.25rem;
    font-weight: 600;
}

.modal-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    color: var(--text-light);
    cursor: pointer;
    padding: 0.25rem;
    line-height: 1;
    transition: var(--transition);
}

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

.modal-body {
    padding: 1.5rem;
}

.modal-form {
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 0.75rem;
    padding-top: 1rem;
    margin-top: 0.5rem;
    border-top: 1px solid var(--border);
}

/* Image Upload */
.image-upload-container {
    display: flex;
    gap: 1.5rem;
    align-items: flex-start;
}

.image-preview {
    width: 120px;
    height: 120px;
    border-radius: var(--radius-sm);
    border: 2px dashed var(--border);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    flex-shrink: 0;
    background: var(--background);
}

.image-preview img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.image-preview .placeholder {
    font-size: 0.8rem;
    color: var(--text-muted);
    text-align: center;
    padding: 0.5rem;
}

.image-upload-controls {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.upload-hint {
    font-size: 0.8rem;
    color: var(--text-muted);
}

/* ===========================================
   Toast Notification
   =========================================== */
.toast {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    background: var(--primary);
    color: white;
    padding: 1rem 1.5rem;
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-lg);
    transform: translateY(100px);
    opacity: 0;
    transition: var(--transition);
    z-index: 1001;
}

.toast.active {
    transform: translateY(0);
    opacity: 1;
}

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

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

/* ===========================================
   Loading Overlay
   =========================================== */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.9);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1002;
    opacity: 0;
    visibility: hidden;
    transition: var(--transition);
}

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

.spinner {
    width: 50px;
    height: 50px;
    border: 3px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

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

/* ===========================================
   QR Code Section
   =========================================== */
.qr-grid {
    display: flex;
    justify-content: center;
    align-items: flex-start;
    padding: 2rem 0;
}

.qr-card {
    background: var(--surface);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
    transition: var(--transition);
    max-width: 450px;
}

.qr-card:hover {
    box-shadow: var(--shadow-lg);
}

.qr-card-header {
    padding: 1.5rem;
    border-bottom: 1px solid var(--border);
    background: var(--background);
    text-align: center;
}

.qr-card-header h3 {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--primary);
    margin-bottom: 0.5rem;
}

.qr-card-header p {
    font-size: 0.9rem;
    color: var(--text-muted);
    word-break: break-all;
}

.qr-card-body {
    padding: 2rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1.5rem;
}

.qr-image-container {
    background: white;
    padding: 1.5rem;
    border-radius: var(--radius-sm);
    border: 2px solid var(--border);
}

.qr-image-container img {
    display: block;
    width: 300px;
    height: 300px;
}

.qr-card-actions {
    display: flex;
    gap: 0.75rem;
    width: 100%;
}

.qr-card-actions .btn {
    flex: 1;
}

.qr-empty {
    text-align: center;
    padding: 3rem;
    color: var(--text-light);
    background: var(--surface);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.qr-empty-icon {
    font-size: 3rem;
    margin-bottom: 1rem;
}

/* ===========================================
   Mobile Menu Toggle
   =========================================== */
.mobile-header {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 60px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    padding: 0 1rem;
    align-items: center;
    justify-content: space-between;
    z-index: 1002;
    box-shadow: var(--shadow);
}

.mobile-header h2 {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--primary);
}

.menu-toggle {
    background: none;
    border: none;
    font-size: 1.5rem;
    color: var(--text);
    cursor: pointer;
    padding: 0.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
}

.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1000;
}

.sidebar-overlay.active {
    display: block;
}

/* ===========================================
   Responsive
   =========================================== */
@media (max-width: 1024px) {
    .sidebar {
        width: 220px;
    }

    .admin-main {
        margin-left: 220px;
    }

    /* QR Code responsive */
    .qr-image-container img {
        width: 280px;
        height: 280px;
    }
}

@media (max-width: 768px) {
    .mobile-header {
        display: flex;
    }

    .sidebar {
        position: fixed;
        left: -280px;
        width: 260px;
        top: 0;
        bottom: 0;
        height: 100vh;
        transition: var(--transition);
        box-shadow: var(--shadow-lg);
        z-index: 1001;
        overflow-y: auto;
    }

    .sidebar.active {
        left: 0;
    }

    .admin-main {
        margin-left: 0;
        padding: 70px 1rem 1rem;
    }

    .section-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 1rem;
    }

    .section-header h1 {
        font-size: 1.25rem;
    }

    .section-header .btn {
        width: 100%;
    }

    .form-row {
        grid-template-columns: 1fr;
    }

    /* Converti tabelle in card layout su mobile */
    .data-table-container {
        overflow-x: visible;
    }

    .data-table {
        min-width: auto;
        border: none;
        background: transparent;
    }

    .data-table thead {
        display: none;
    }

    .data-table tbody {
        display: block;
    }

    .data-table tr {
        display: block;
        background: var(--surface);
        border-radius: var(--radius);
        margin-bottom: 1rem;
        padding: 1rem;
        box-shadow: var(--shadow);
        border: 1px solid var(--border);
    }

    .data-table td {
        display: block;
        text-align: left;
        padding: 0.5rem 0;
        border: none;
    }

    .data-table td:before {
        content: attr(data-label);
        font-weight: 600;
        color: var(--text-muted);
        display: block;
        margin-bottom: 0.25rem;
        font-size: 0.85rem;
        text-transform: uppercase;
        letter-spacing: 0.5px;
    }

    .data-table td:first-child:before {
        display: none;
    }

    .table-actions {
        justify-content: flex-start;
        margin-top: 0.5rem;
        padding-top: 0.75rem;
        border-top: 1px solid var(--border);
    }

    .table-image,
    .table-image-placeholder {
        width: 80px;
        height: 80px;
        margin-bottom: 0.5rem;
    }

    .image-upload-container {
        flex-direction: column;
    }

    .toast {
        left: 1rem;
        right: 1rem;
        bottom: 1rem;
    }

    /* QR Code section mobile */
    .qr-grid {
        padding: 1rem;
    }

    .qr-card {
        max-width: 100%;
    }

    .qr-image-container {
        padding: 1rem;
    }

    .qr-image-container img {
        width: 250px;
        height: 250px;
    }

    .filter-bar {
        margin-bottom: 1rem;
    }

    .filter-bar select {
        width: 100%;
    }
}

@media (max-width: 576px) {
    .admin-main {
        padding: 70px 0.75rem 1rem;
    }

    .section-header h1 {
        font-size: 1.15rem;
    }

    .btn {
        padding: 0.65rem 1rem;
        font-size: 0.85rem;
    }

    /* Card layout mobile più compatto */
    .data-table tr {
        padding: 0.75rem;
    }

    .data-table td {
        padding: 0.4rem 0;
    }

    .data-table td:before {
        font-size: 0.75rem;
        margin-bottom: 0.2rem;
    }

    .table-actions {
        flex-wrap: wrap;
        gap: 0.5rem;
    }

    .table-actions .btn {
        flex: 1;
        min-width: calc(50% - 0.25rem);
    }

    .modal-content {
        margin: 0.5rem;
        max-height: 95vh;
    }

    .modal-form {
        padding: 1rem;
    }

    .modal-header {
        padding: 1rem;
    }

    .modal-header h2 {
        font-size: 1.1rem;
    }

    /* QR Code section extra small mobile */
    .qr-grid {
        padding: 0.5rem;
    }

    .qr-card-body {
        padding: 1rem;
    }

    .qr-image-container {
        padding: 0.75rem;
    }

    .qr-image-container img {
        width: 200px;
        height: 200px;
    }

    .qr-card-header h3 {
        font-size: 1rem;
    }

    .qr-card-header p {
        font-size: 0.8rem;
    }

    .filter-bar {
        margin-bottom: 1rem;
    }

    .form-select {
        font-size: 0.9rem;
    }
}

@media (max-width: 380px) {
    .mobile-header {
        height: 55px;
        padding: 0 0.75rem;
    }

    .mobile-header h2 {
        font-size: 1rem;
    }

    .admin-main {
        padding: 65px 0.5rem 1rem;
    }

    .section-header {
        gap: 0.75rem;
    }

    .btn-sm {
        padding: 0.4rem 0.75rem;
        font-size: 0.8rem;
    }

    .qr-card-header {
        padding: 1rem;
    }

    .qr-card-actions {
        flex-direction: column;
    }
}
