/* Reset e stili base */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    line-height: 1.6;
    color: #333;
    background-color: #f5f5f5;
    padding: 20px;
}

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

h1, h2, h3 {
    color: #2c3e50;
    margin-bottom: 10px;
}

button, .button {
    background-color: #3498db;
    color: white;
    border: none;
    padding: 8px 15px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    margin-right: 5px;
    display: inline-flex; /* Use flexbox for icon and text alignment */
    align-items: center; /* Vertically align icon and text */
    justify-content: center; /* Center content horizontally */
    text-align: center;
    gap: 5px; /* Space between icon and text */
}

button:hover, .button:hover {
    background-color: #2980b9;
}

/* Specific style for icon-only buttons */
button.icon-only {
    width: 30px; /* Fixed width for square buttons */
    height: 30px; /* Fixed height for square buttons */
    padding: 0; /* Remove padding */
    font-size: 1em; /* Adjust icon size */
    gap: 0; /* No gap for icon-only */
}

/* Form Styles */
.form-section {
    background-color: white;
    padding: 20px;
    margin-bottom: 20px;
    border-radius: 5px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
}

/* Specific internal padding for the "Informazioni sull'App e Guida all'Uso" section */
#info-guide-section {
    padding-left: 40px; /* Aumenta il padding interno a sinistra */
    padding-right: 40px; /* Aumenta il padding interno a destra */
}

.form-row {
    display: flex;
    flex-wrap: wrap;
    margin-bottom: 15px;
    gap: 15px;
}

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

.col-half {
    flex: 0 0 48%;
}

label {
    display: block;
    margin-bottom: 5px;
    font-weight: 500;
}

input, select, textarea {
    width: 100%;
    padding: 8px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 14px;
    margin-bottom: 10px;
}

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

/* Table Styles */
.table-container {
    overflow-x: auto;
    margin-bottom: 15px;
}

table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 15px;
}

th, td {
    padding: 10px;
    text-align: left;
    border-bottom: 1px solid #ddd;
}

th {
    background-color: #f2f2f2;
    font-weight: 600;
}

tr:hover {
    background-color: #f9f9f9;
}

.box-informazioni {
    padding-left: 30px;
    padding-right: 30px;
    padding-top: 15px;
    padding-bottom: 15px;
    margin-bottom: 15px;
    background-color: #e7fdf0;
    border-radius: 5px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
}

/* Actions */
.actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

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

/* Modal */
.modal {
    display: none;
    position: fixed;
    z-index: 1;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: auto;
    background-color: rgba(0,0,0,0.4);
}

.modal-content {
    background-color: #fefefe;
    margin: 5% auto;
    padding: 20px;
    border: 1px solid #888;
    width: 80%;
    max-width: 800px;
    border-radius: 5px;
}

.close {
    color: #aaa;
    float: right;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
}

.close:hover {
    color: black;
}

#pdf-container {
    width: 100%;
    min-height: 500px;
    border: 1px solid #ddd;
    margin: 15px 0;
    padding: 10px;
}

/* Archive List Styles */
#archive-list {
    margin-top: 20px;
    border-top: 1px solid #eee;
    padding-top: 15px;
}

.archive-item {
    background-color: #f9f9f9;
    border: 1px solid #eee;
    padding: 10px 15px;
    margin-bottom: 10px;
    border-radius: 4px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
}

.archive-item:hover {
    background-color: #f0f0f0;
}

.archive-item-info {
    flex: 1;
    min-width: 250px;
}

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

.archive-item-actions button {
    padding: 5px 10px;
    font-size: 12px;
    margin-right: 0; /* Override default button margin */
}

/* Form Feedback */
.form-feedback {
    font-size: 0.9em;
    margin-top: -5px; /* Adjust to sit closer to the input */
    margin-bottom: 10px; /* Space below feedback */
    min-height: 1.2em; /* Reserve space to prevent layout shifts */
}

.form-feedback.error {
    color: #e74c3c; /* Red for errors */
    font-weight: bold;
}

.form-feedback.info {
    color: #2980b9; /* Blue for info/suggestions */
}

.form-feedback button {
    margin-left: 10px;
    padding: 3px 8px;
    font-size: 0.8em;
    background-color: #2ecc71; /* Green for action button */
}

.form-feedback button:hover {
    background-color: #27ae60;
}

/* Footer Styles */
.app-footer {
    background-color: #e9e9e9; /* Lighter background */
    color: #555; /* Softer text color */
    padding: 20px;
    margin-top: 40px; /* More space from main content */
    font-size: 0.85em; /* Smaller font size */
    border-top: 1px solid #ccc; /* Subtle top border */
}

.footer-content-wrapper {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); /* Responsive columns */
    gap: 30px; /* Space between columns */
    max-width: 1200px; /* Max width for the content */
    margin: 0 auto; /* Center the content wrapper */
    padding: 0 15px; /* Add some horizontal padding for smaller screens */
}

.footer-column {
    padding: 10px; /* Some padding inside each column */
    text-align: left; /* Align text left within columns */
}

.app-footer h3 {
    color: #444; /* Slightly darker heading for readability */
    margin-bottom: 10px;
    font-size: 1.1em; /* Slightly smaller heading size */
    text-align: center; /* Center headings within columns */
}

.app-footer p, .app-footer ul {
    margin-bottom: 10px;
}

.app-footer ul {
    list-style-type: disc;
    padding-left: 20px;
}

.app-footer ul li {
    margin-bottom: 5px;
}

.app-footer a {
    color: #3498db;
    text-decoration: none;
}

.app-footer a:hover {
    text-decoration: underline;
}


/* Responsive */
@media (max-width: 768px) {
    .form-group, .col-half {
        flex: 0 0 100%;
    }
    
    .actions, .form-actions {
        flex-direction: column;
    }
    
    button, .button {
        width: 100%;
        margin-bottom: 5px;
    }

    .archive-item {
        flex-direction: column;
        align-items: flex-start;
    }

    .archive-item-actions {
        width: 100%;
        justify-content: flex-end;
    }

    .app-footer {
        padding: 15px;
        font-size: 0.8em;
    }
    /* On smaller screens, headings within columns should align left */
    .footer-column h3 {
        text-align: left;
    }

    /* Adjust padding for info guide section on smaller screens */
    #info-guide-section {
        padding-left: 20px; /* Reduce padding on small screens */
        padding-right: 20px; /* Reduce padding on small screens */
    }
}

/* Info Icon and Popup */
.info-icon-container {
    position: relative; /* To position the popup relative to this container */
    display: inline-block; /* To keep it next to the button */
    margin-left: 5px; /* Small space from the button */
    vertical-align: middle; /* Align with button text */
}

.info-icon {
    color: #3498db; /* Blue color for info icon */
    cursor: pointer;
    font-size: 1.2em; /* Slightly larger icon */
}

.info-icon:hover {
    color: #2980b9;
}

.info-popup {
    display: none; /* Hidden by default */
    position: absolute;
    top: 100%; /* Position below the icon */
    left: 0;
    width: 300px; /* Fixed width for the popup */
    background-color: #fff;
    border: 1px solid #ddd;
    box-shadow: 0 4px 8px rgba(0,0,0,0.2);
    padding: 15px;
    border-radius: 5px;
    z-index: 10; /* Ensure it's above other content */
    font-size: 0.9em;
    line-height: 1.4;
    text-align: left; /* Ensure text aligns left within popup */
}

.info-popup h3 {
    margin-top: 0;
    margin-bottom: 10px;
    font-size: 1.1em;
    color: #2c3e50;
}

.info-popup p, .info-popup ul, .info-popup ol {
    margin-bottom: 10px;
}

.info-popup ul, .info-popup ol {
    padding-left: 20px;
}

.info-popup li {
    margin-bottom: 5px;
}

.info-popup code {
    background-color: #f0f0f0;
    padding: 2px 4px;
    border-radius: 3px;
    font-family: monospace;
}

.info-popup pre {
    background-color: #f8f8f8;
    border: 1px solid #eee;
    padding: 10px;
    border-radius: 4px;
    overflow-x: auto;
    white-space: pre-wrap; /* Allow long lines to wrap */
    word-wrap: break-word; /* Break long words */
}

/* Print Styles */
@media print {
    /* Hide everything that is not part of the PDF preview when in print mode */
    body.print-mode > *:not(#pdf-preview) {
        display: none !important;
    }

    /* Make the PDF preview modal visible and full screen for printing */
    body.print-mode #pdf-preview {
        display: block !important;
        position: static !important; /* Use static for print flow */
        top: 0 !important;
        left: 0 !important;
        width: 100% !important;
        height: auto !important; /* Allow height to adjust to content */
        background-color: transparent !important; /* Remove modal overlay background */
        overflow: visible !important; /* Ensure content is not clipped */
        z-index: 9999 !important; /* Ensure it's on top */
    }

    /* Style the modal content for printing */
    body.print-mode .modal-content {
        width: 100% !important;
        max-width: none !important; /* Remove max-width constraint */
        margin: 0 !important;
        padding: 0 !important;
        border: none !important;
        box-shadow: none !important;
        background-color: transparent !important;
    }

    /* Hide modal specific elements like close button, title, and print button */
    body.print-mode .modal-content h2,
    body.print-mode .close,
    body.print-mode #print-pdf {
        display: none !important;
    }

    /* Ensure the PDF container itself is styled for A4 print */
    body.print-mode #pdf-container {
        width: 210mm !important; /* A4 width */
        min-height: 297mm !important; /* A4 height */
        margin: 0 auto !important; /* Center on the page */
        border: none !important; /* Remove border */
        padding: 0 !important; /* Remove padding */
        box-shadow: none !important;
        background-color: white !important; /* Ensure white background */
    }

    /* Hide info icon and popup in print mode */
    .info-icon-container {
        display: none !important;
    }
}
