/* RESET E STILI BASE */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: var(--background-color);
    color: var(--text-color);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* HEADER */
header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 2rem;
    color: white;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.header-left {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    min-width: 200px;
}

.logo img {
    max-height: 50px;
    width: auto;
}

.logo i {
    font-size: 2rem;
}

.datetime {
    font-size: 0.9rem;
    opacity: 0.9;
}

.header-center {
    text-align: center;
    flex: 1;
}

.header-center h1 {
    font-size: 1.8rem;
    margin-bottom: 0.25rem;
}

.motto {
    font-size: 1rem;
    opacity: 0.9;
}

.header-right {
    min-width: 200px;
    text-align: right;
}

/* DROPDOWN MENU MIGLIORATO */
.dropdown {
    position: relative;
    display: inline-block;
}

.dropbtn {
    background-color: var(--menu-color);
    color: white;
    padding: 0.8rem 1.5rem;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 1rem;
    transition: background-color 0.3s;
}

.dropbtn:hover {
    background-color: var(--button-color);
}

.dropdown-content {
    display: none;
    position: absolute;
    right: 0;
    background-color: white;
    min-width: 320px;
    max-width: 400px;
    box-shadow: 0 8px 16px rgba(0,0,0,0.2);
    z-index: 1000;
    border-radius: 8px;
    overflow: hidden;
    padding: 8px 0;
}

.dropdown:hover .dropdown-content {
    display: block;
}

/* Sezioni del menu */
.menu-section {
    border-bottom: 1px solid #e9ecef;
    padding: 8px 0;
}

.menu-section:last-child {
    border-bottom: none;
}

.menu-section-title {
    padding: 8px 16px;
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #6c757d;
    background-color: #f8f9fa;
}

.dropdown-content a {
    color: #495057;
    padding: 10px 16px;
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 12px;
    transition: all 0.2s;
    border-left: 3px solid transparent;
}

.dropdown-content a i {
    width: 20px;
    text-align: center;
    font-size: 1.1rem;
    color: #6c757d;
    transition: color 0.2s;
}

.dropdown-content a:hover {
    background-color: #f1f3f5;
    border-left-color: var(--button-color);
}

.dropdown-content a:hover i {
    color: var(--button-color);
}

/* Badge per admin */
.admin-badge {
    background-color: var(--button-color);
    color: white;
    font-size: 0.65rem;
    font-weight: 600;
    padding: 2px 6px;
    border-radius: 10px;
    margin-left: 8px;
    text-transform: uppercase;
}

/* MAIN CONTAINER */
.container {
    max-width: 1200px;
    margin: 2rem auto;
    padding: 0 1rem;
    flex: 1;
    width: 100%;
}

/* PAGE HEADER */
.page-header {
    margin-bottom: 30px;
    padding-bottom: 15px;
    border-bottom: 2px solid var(--border-color);
}

.page-header h1 {
    margin: 0 0 10px 0;
    color: var(--text-color);
}

.page-header .page-description {
    margin: 0;
    color: #666;
    font-style: italic;
}

/* BLOCKS */
.block {
    background-color: var(--table-color);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 1.5rem;
    margin-bottom: 2rem;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.block h2 {
    margin-bottom: 1.5rem;
    color: var(--text-color);
    border-bottom: 2px solid var(--border-color);
    padding-bottom: 0.5rem;
}

.block h2 i {
    margin-right: 10px;
    color: var(--button-color);
}

.block h3 {
    margin-bottom: 1rem;
    color: var(--text-color);
}

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

.block-header h2 {
    margin: 0;
}

/* TABLES */
.data-table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 1rem;
}

.data-table th {
    background-color: var(--header-color);
    color: white;
    padding: 0.75rem;
    text-align: left;
    font-weight: 600;
}

.data-table td {
    padding: 0.75rem;
    border-bottom: 1px solid var(--border-color);
    vertical-align: middle;
}

.data-table tr:hover {
    background-color: rgba(0,0,0,0.02);
}

/* FIELD WITH COPY */
.field-with-copy {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background-color: #f8f9fa;
    padding: 0.5rem;
    border-radius: 4px;
    border: 1px solid var(--border-color);
}

.field-value {
    flex: 1;
    word-break: break-all;
    font-family: monospace;
}

.hidden {
    display: none;
}

.copy-btn, .toggle-password {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--button-color);
    font-size: 1.1rem;
    padding: 0.25rem;
    transition: transform 0.2s;
}

.copy-btn:hover, .toggle-password:hover {
    transform: scale(1.1);
    opacity: 0.8;
}

.copy-btn.copied {
    color: #28a745;
}

/* FORMS */
.insert-form {
    background-color: #f8f9fa;
    padding: 1.5rem;
    border-radius: 8px;
    margin-bottom: 2rem;
    border: 1px solid var(--border-color);
}

.form-row {
    display: flex;
    gap: 20px;
    align-items: flex-end;
    flex-wrap: wrap;
}

.form-group {
    margin-bottom: 1rem;
    flex: 1;
    min-width: 200px;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 600;
    color: var(--text-color);
}

.form-group input[type="text"],
.form-group input[type="password"],
.form-group input[type="email"],
.form-group input[type="url"],
.form-group input[type="number"],
.form-group select,
.form-group textarea,
.form-control {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    font-size: 1rem;
    transition: border-color 0.3s, box-shadow 0.3s;
    font-family: inherit;
}

.form-group textarea {
    resize: vertical;
    min-height: 80px;
}

.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
    outline: none;
    border-color: var(--button-color);
    box-shadow: 0 0 0 3px rgba(41, 128, 185, 0.1);
}

.form-group.checkbox {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    min-width: auto;
    flex: 0 0 auto;
}

.form-group.checkbox input {
    width: auto;
    margin: 0;
}

.form-group.checkbox label {
    margin-bottom: 0;
    cursor: pointer;
}

.form-group small {
    display: block;
    color: #6c757d;
    font-size: 0.85rem;
    margin-top: 5px;
}

.password-input-group {
    display: flex;
    gap: 0.5rem;
}

.password-input-group input {
    flex: 1;
}

/* BUTTONS */
.btn-primary, .btn-secondary, .btn-danger, .btn-info {
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 1rem;
    font-weight: 500;
    transition: all 0.3s;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    text-decoration: none;
}

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

.btn-primary:hover {
    background-color: var(--menu-color);
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.btn-secondary {
    background-color: #6c757d;
    color: white;
}

.btn-secondary:hover {
    background-color: #5a6268;
    transform: translateY(-1px);
}

.btn-danger {
    background-color: #dc3545;
    color: white;
}

.btn-danger:hover {
    background-color: #c82333;
    transform: translateY(-1px);
}

.btn-info {
    background-color: #17a2b8;
    color: white;
}

.btn-info:hover {
    background-color: #138496;
    transform: translateY(-1px);
}

.btn-small {
    padding: 0.375rem 0.75rem;
    font-size: 0.875rem;
    border-radius: 4px;
    border: none;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 5px;
    text-decoration: none;
}

.btn-large {
    padding: 12px 30px;
    font-size: 1.1rem;
}

.btn-link {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 5px 10px;
    background-color: #e9ecef;
    color: #495057;
    text-decoration: none;
    border-radius: 4px;
    font-size: 0.9rem;
}

.btn-link:hover {
    background-color: #dee2e6;
}

/* EXPORT BUTTONS */
.export-buttons {
    display: flex;
    gap: 1rem;
    justify-content: flex-end;
    margin-top: 1rem;
}

/* CONFIGURATION PAGE */
.config-section {
    background: white;
    border-radius: 8px;
    padding: 20px;
    margin-bottom: 30px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.config-section h2 {
    margin-top: 0;
    margin-bottom: 20px;
    padding-bottom: 10px;
    border-bottom: 2px solid #eee;
    color: #333;
}

.config-section h2 i {
    margin-right: 10px;
    color: #3498db;
}

.section-description {
    color: #666;
    margin-bottom: 20px;
    font-style: italic;
}

.color-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 1rem;
    margin-bottom: 1rem;
}

.color-item {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.color-item label {
    font-weight: 600;
    font-size: 0.9rem;
}

.color-item input[type="color"] {
    width: 100%;
    height: 40px;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    cursor: pointer;
    padding: 0;
}

.checkbox-group {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 10px;
    margin-bottom: 20px;
}

.password-preview {
    margin-top: 20px;
    padding: 15px;
    background: #e9ecef;
    border-radius: 6px;
}

.password-preview label {
    display: block;
    margin-bottom: 10px;
    font-weight: bold;
    color: #495057;
}

.preview-box {
    display: flex;
    gap: 10px;
    align-items: center;
    background: white;
    padding: 10px 15px;
    border-radius: 4px;
    border: 1px solid #dee2e6;
}

#password-preview {
    flex: 1;
    font-family: monospace;
    font-size: 1.1rem;
    color: #28a745;
}

.current-logo {
    margin-top: 10px;
    padding: 10px;
    background: #f8f9fa;
    border-radius: 4px;
    display: flex;
    align-items: center;
    gap: 15px;
    flex-wrap: wrap;
}

.current-logo p {
    margin: 0;
    color: #495057;
}

/* SITI MANAGEMENT */
.siti-list {
    margin-bottom: 30px;
}

.sito-card {
    background: white;
    border: 1px solid #dee2e6;
    border-radius: 8px;
    padding: 20px;
    margin-bottom: 20px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
    transition: transform 0.2s, box-shadow 0.2s;
}

.sito-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0,0,0,0.1);
}

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

.sito-title {
    display: flex;
    align-items: center;
    gap: 15px;
}

.sito-title h2 {
    margin: 0;
    font-size: 1.4rem;
    color: #2c3e50;
}

.sito-actions {
    display: flex;
    gap: 10px;
}

.sito-info {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 15px;
    margin-bottom: 15px;
}

.info-row {
    color: #495057;
}

.info-row strong {
    color: #6c757d;
    font-size: 0.9rem;
    display: block;
    margin-bottom: 3px;
}

.info-row a {
    color: #007bff;
    text-decoration: none;
}

.info-row a:hover {
    text-decoration: underline;
}

.sito-footer {
    text-align: right;
    color: #6c757d;
    font-size: 0.85rem;
    border-top: 1px solid #eee;
    padding-top: 10px;
}

.new-sito {
    text-align: center;
    margin-top: 30px;
}

/* SITI HOME PAGE */
.welcome-block {
    text-align: center;
    padding: 40px 20px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border-radius: 8px;
    margin-bottom: 40px;
}

.welcome-block h1 {
    margin: 0 0 10px 0;
    font-size: 2rem;
}

.welcome-block p {
    margin: 0;
    font-size: 1.2rem;
    opacity: 0.9;
}

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

.sito-card-home {
    background: white;
    border: 1px solid #dee2e6;
    border-radius: 8px;
    padding: 20px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
    transition: transform 0.2s, box-shadow 0.2s;
    display: flex;
    flex-direction: column;
}

.sito-card-home:hover {
    transform: translateY(-5px);
    box-shadow: 0 4px 8px rgba(0,0,0,0.1);
}

.sito-card-home h2 {
    margin: 0 0 10px 0;
    color: #2c3e50;
    font-size: 1.3rem;
}

.sito-card-home p {
    color: #6c757d;
    margin-bottom: 20px;
    line-height: 1.5;
    flex: 1;
}

.sito-card-home .btn-primary {
    align-self: flex-start;
}

.no-siti {
    text-align: center;
    padding: 60px 20px;
    background: #f8f9fa;
    border-radius: 8px;
}

.no-siti p {
    margin-bottom: 20px;
    color: #6c757d;
    font-size: 1.1rem;
}

/* SITO PAGE */
.sito-info-block {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 30px;
    border-radius: 8px;
    margin-bottom: 30px;
}

.sito-info-block .sito-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    border-bottom: none;
    padding-bottom: 0;
}

.sito-info-block h1 {
    margin: 0;
    font-size: 2rem;
}

.btn-sito-link {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    padding: 10px 20px;
    background: rgba(255,255,255,0.2);
    color: white;
    text-decoration: none;
    border-radius: 4px;
    transition: background 0.3s;
}

.btn-sito-link:hover {
    background: rgba(255,255,255,0.3);
}

.sito-descrizione {
    margin: 0;
    font-size: 1.1rem;
    opacity: 0.9;
}

/* CASELLE EMAIL */
.caselle-list {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.casella-card {
    background: white;
    border: 1px solid #dee2e6;
    border-radius: 8px;
    padding: 20px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}

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

.casella-title {
    display: flex;
    align-items: center;
    gap: 10px;
}

.casella-title strong {
    font-size: 1.2rem;
    color: #2c3e50;
}

.casella-actions {
    display: flex;
    gap: 10px;
}

.casella-info {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

/* ALIAS */
.alias-container {
    margin-top: 20px;
    padding-top: 20px;
    border-top: 2px dashed #dee2e6;
}

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

.alias-header h4 {
    margin: 0;
    color: #495057;
}

.alias-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.alias-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px;
    background: #f8f9fa;
    border-radius: 4px;
}

.alias-info {
    display: flex;
    align-items: center;
    gap: 15px;
}

.alias-note {
    color: #6c757d;
    font-style: italic;
}

.alias-actions {
    display: flex;
    gap: 5px;
}

#alias-preview {
    color: #6c757d;
}

#dominio-preview {
    color: #28a745;
    font-weight: bold;
}

/* SLUG INPUT GROUP */
.slug-input-group {
    display: flex;
    gap: 10px;
}

.slug-input-group input {
    flex: 1;
}

.slug-preview {
    display: block;
    margin-top: 5px;
    color: #6c757d;
    font-size: 0.9rem;
    font-family: monospace;
}

.slug-preview span {
    color: #28a745;
    font-weight: bold;
}

/* BADGES */
.badge {
    display: inline-block;
    padding: 3px 8px;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
}

.badge-success {
    background-color: #28a745;
    color: white;
}

.badge-warning {
    background-color: #ffc107;
    color: #212529;
}

.badge-info {
    background-color: #17a2b8;
    color: white;
}

/* MODAL */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.5);
    animation: fadeIn 0.3s;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.modal-content {
    background-color: white;
    margin: 50px auto;
    padding: 30px;
    border-radius: 8px;
    width: 90%;
    max-width: 600px;
    max-height: 80vh;
    overflow-y: auto;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
    animation: slideIn 0.3s;
}

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

.modal-content h3 {
    margin-top: 0;
    margin-bottom: 20px;
    padding-bottom: 10px;
    border-bottom: 2px solid #eee;
    color: #333;
}

.form-actions {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    margin-top: 20px;
}

/* NO DATA MESSAGE */
.no-data {
    text-align: center;
    padding: 40px;
    color: #999;
    font-style: italic;
    background: #f8f9fa;
    border-radius: 4px;
}

/* FOOTER */
footer {
    background-color: var(--footer-color);
    color: white;
    padding: 1rem 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: auto;
    box-shadow: 0 -2px 4px rgba(0,0,0,0.1);
}

/* UTILITY CLASSES */
.text-center {
    text-align: center;
}

.text-right {
    text-align: right;
}

.mt-20 {
    margin-top: 20px;
}

.mb-20 {
    margin-bottom: 20px;
}

/* RESPONSIVE */
@media (max-width: 768px) {
    header {
        flex-direction: column;
        gap: 1rem;
        text-align: center;
        padding: 1rem;
    }
    
    .header-left, .header-right {
        width: 100%;
        text-align: center;
    }
    
    .dropdown-content {
        left: 50%;
        transform: translateX(-50%);
        min-width: 90vw;
        max-width: 90vw;
    }
    
    .form-row {
        flex-direction: column;
        gap: 0;
        align-items: stretch;
    }
    
    .form-group {
        min-width: 100%;
    }
    
    .data-table {
        display: block;
        overflow-x: auto;
        white-space: nowrap;
    }
    
    .export-buttons {
        flex-direction: column;
    }
    
    .export-buttons a {
        text-align: center;
    }
    
    .sito-header {
        flex-direction: column;
        gap: 10px;
        align-items: flex-start;
    }
    
    .sito-actions {
        flex-wrap: wrap;
    }
    
    .sito-info {
        grid-template-columns: 1fr;
    }
    
    .sito-title {
        flex-direction: column;
        align-items: flex-start;
    }
    
    .casella-header {
        flex-direction: column;
        gap: 10px;
        align-items: flex-start;
    }
    
    .casella-actions {
        flex-wrap: wrap;
    }
    
    .alias-item {
        flex-direction: column;
        gap: 10px;
        align-items: flex-start;
    }
    
    .modal-content {
        margin: 20px;
        padding: 20px;
        width: auto;
    }
    
    .color-grid {
        grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    }
    
    .checkbox-group {
        grid-template-columns: 1fr;
    }
}

/* STAMPA */
@media print {
    header, footer, .dropdown, .btn-primary, .btn-secondary, 
    .btn-danger, .btn-info, .export-buttons, .insert-form, 
    .modal, .sito-actions, .casella-actions, .alias-actions {
        display: none !important;
    }
    
    .container {
        margin: 0;
        padding: 0;
    }
    
    .block {
        box-shadow: none;
        border: 1px solid #000;
        page-break-inside: avoid;
    }
    
    .sito-info-block {
        background: #f8f9fa;
        color: #000;
        border: 1px solid #000;
    }
    
    .btn-sito-link {
        display: none;
    }
}