/* °|° */
* {
    box-sizing: border-box;
}
body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    margin: 0;
    background: #f4f6f8;
    color: #333;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}
header {
    background: #2a3f54;
    color: #fff;
    padding: 1rem 2rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 1rem;
}
.header-left {
    display: flex;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
}
.header-right {
    display: flex;
    align-items: center;
    gap: 1rem;
}
header h1 {
    margin: 0;
    font-weight: 600;
    font-size: 1.5rem;
}
select#warehouse-select {
    font-size: 1rem;
    padding: 0.3rem 0.5rem;
    border-radius: 5px;
    border: none;
    background: #fff;
    color: #2a3f54;
    cursor: pointer;
    box-shadow: 0 0 5px rgba(0,0,0,0.1);
    min-width: 120px;
}
main {
    flex-grow: 1;
    padding: 1rem 2rem 2rem 2rem;
    max-width: 1100px;
    margin: 0 auto;
    width: 100%;
}
section {
    margin-bottom: 2rem;
    background: #fff;
    border-radius: 10px;
    box-shadow: 0 4px 15px rgb(0 0 0 / 0.1);
    padding: 1.5rem 2rem;
}
section h2 {
    margin-top: 0;
    font-weight: 600;
    color: #2a3f54;
}
/* FORM */
label {
    display: block;
    margin-bottom: 0.25rem;
    font-weight: 600;
    color: #455a75;
}
/* Exception for checkbox labels in bulk actions */
label.show-all-label {
    display: flex !important;
}
input[type="text"], input[type="number"], select, textarea {
    width: 100%;
    padding: 0.4rem 0.6rem;
    margin-bottom: 1rem;
    border: 1.8px solid #ccc;
    border-radius: 7px;
    font-size: 1rem;
    transition: border-color 0.3s ease;
}
input[type="text"]:focus,
input[type="number"]:focus,
select:focus,
textarea:focus {
    border-color: #2a9d8f;
    outline: none;
}
button {
    background-color: #2a9d8f;
    border: none;
    color: #fff;
    font-weight: 700;
    padding: 0.6rem 1.5rem;
    border-radius: 7px;
    cursor: pointer;
    font-size: 1rem;
    transition: background-color 0.25s ease;
    user-select: none;
}
button:hover:not(:disabled) {
    background-color: #21867a;
}
button:disabled {
    background-color: #9bd1cb;
    cursor: not-allowed;
}
.btn-secondary {
    background-color: #e76f51;
}
.btn-secondary:hover:not(:disabled) {
    background-color: #c5593f;
}
.btn-search {
    background-color: #264653;
    border: 2px solid #2a9d8f;
    color: #fff;
    font-weight: 700;
    padding: 0.5rem 1rem;
    border-radius: 7px;
    cursor: pointer;
    font-size: 0.9rem;
    transition: all 0.25s ease;
    user-select: none;
}
.btn-search:hover:not(:disabled) {
    background-color: #2a9d8f;
    border-color: #21867a;
}
.btn-search[aria-pressed="true"] {
    background-color: #2a9d8f;
    border-color: #21867a;
}
/* Layout forms */
.form-inline {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem 2rem;
}
.form-inline > div {
    flex: 1 1 200px;
}

/* CAPOSTRONZO */
.form-inline > div:has(textarea) {
    flex: 1 1 100%;
}
/* New layout for add form footer */
#add-object-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
}
#add-object-footer .left {
    flex-grow: 1;
}
#action-buttons {
    display: flex;
    gap: 0.8rem;
}
/* Inventory table */
table {
    border-collapse: collapse;
    width: 100%;
    background: white;
    border-radius: 10px;
    overflow: hidden;
    box-shadow: 0 4px 15px rgb(0 0 0 / 0.15);
}
thead {
    background: #264653;
    color: white;
}
thead tr th {
    padding: 1rem 1rem;
    text-align: left;
    font-weight: 700;
    font-size: 1rem;
    user-select: none;
}
tbody tr {
    border-bottom: 1px solid #ddd;
    cursor: pointer;
    transition: background-color 0.3s ease;
}
tbody tr:nth-child(even) {
    background: #f9fafb;
}
tbody tr:hover {
    background: #d1e6dc;
}
tbody tr.selected {
    background: #a8dadc !important;
}
tbody tr td {
    padding: 0.6rem 1rem;
    vertical-align: middle;
    font-size: 0.9rem;
}
td.checkbox-cell {
    width: 36px;
    text-align: center;
}
input[type="checkbox"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
}
/* BULK BULK */
#bulk-actions, #search-bulk-actions {
    display: flex !important;
    justify-content: flex-start;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1rem;
    flex-wrap: wrap;
    min-height: 40px;
}
#bulk-actions button, #search-bulk-actions button {
    padding: 0.5rem 1.2rem;
    font-weight: 700;
    border-radius: 7px;
    user-select: none;
    margin-left: auto;
}
/* Remove auto margin from first button to keep them together on the right */
#bulk-actions button:first-of-type, #search-bulk-actions button:first-of-type {
    margin-left: auto;
}
#bulk-actions button:last-of-type, #search-bulk-actions button:last-of-type {
    margin-left: 0;
}
.show-all-label {
    display: flex !important;
    align-items: center !important;
    margin: 0 !important;
    padding: 0.5rem 1rem !important;
    font-weight: 600 !important;
    color: #2a3f54 !important;
    cursor: pointer !important;
    user-select: none !important;
    background-color: #e8f4f8 !important;
    border-radius: 6px !important;
    border: 2px solid #2a9d8f !important;
    transition: all 0.2s ease;
}
.show-all-label:hover {
    background-color: #d1e6dc !important;
    border-color: #21867a !important;
}
.show-all-label input[type="checkbox"] {
    width: 20px !important;
    height: 20px !important;
    margin: 0 0.6rem 0 0 !important;
    cursor: pointer !important;
    flex-shrink: 0 !important;
}
.show-all-label span {
    white-space: nowrap !important;
    font-size: 0.95rem !important;
}
/* CONTAINER POP */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.35);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 1rem;
}

/* Login specific styles */
#login-modal {
    display: flex;
}

#login-modal .modal {
    max-width: 400px;
    padding: 2rem;
}

#login-modal h3 {
    text-align: center;
    margin-bottom: 1.5rem;
}

#login-modal .form-group {
    margin-bottom: 1.5rem;
}

#login-modal button[type="submit"] {
    width: 100%;
    padding: 0.8rem;
    font-size: 1.1rem;
}

#user-info {
    font-weight: 500;
}

#btn-logout {
    padding: 0.4rem 1rem;
    font-size: 0.9rem;
}

/* Hide main content when not logged in */
body:not(.logged-in) main,
body:not(.logged-in) header {
    display: none !important;
}
.modal-overlay.active {
    display: flex;
}
.modal {
    background: white;
    border-radius: 10px;
    max-width: 480px;
    width: 100%;
    padding: 1.5rem 2rem;
    box-shadow: 0px 8px 36px rgba(0, 0, 0, 0.2);
    max-height: 90vh;
    overflow-y: auto;
    position: relative;
}
.modal h3 {
    margin-top: 0;
    font-weight: 700;
    color: #264653;
}
.modal .modal-close {
    position: absolute;
    top: 0.5rem;
    right: 1rem;
    font-size: 1.4rem;
    color: #888;
    cursor: pointer;
    user-select: none;
    border: none;
    background: transparent;
}
.modal .modal-close:hover {
    color: #333;
}
.modal form {
    margin-top: 1rem;
}
.modal label {
    font-weight: 600;
    color: #455a75;
}
.modal .form-group {
    margin-bottom: 1rem;
}
.modal select[multiple] {
    height: 120px;
}
/* RICERCA */
.search-controls {
    margin-bottom: 1.5rem;
}
#search-results table {
    margin-top: 1rem;
}

/* CLASS */
.class-cell {
    border-radius: 4px;
    padding: 0.4rem 0.8rem !important;
    font-weight: 600;
    text-shadow: 1px 1px 2px rgba(0,0,0,0.3);
}

/* MAGAZZINO */
.warehouse-management .form-inline {
    align-items: end;
    gap: 0.5rem;
}
.warehouse-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.5rem;
    margin: 0.25rem 0;
    background: #f9fafb;
    border-radius: 5px;
    border: 1px solid #ddd;
}
.warehouse-item button {
    padding: 0.3rem 0.8rem;
    font-size: 0.8rem;
    background-color: #e76f51;
}
.warehouse-item button:hover {
    background-color: #c5593f;
}

/* Notification system */
.notification {
    position: fixed;
    top: 20px;
    right: 20px;
    padding: 1rem 1.5rem;
    border-radius: 8px;
    color: white;
    font-weight: 600;
    z-index: 2000;
    max-width: 400px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    animation: slideIn 0.3s ease-out;
}

.notification.info {
    background-color: #2a9d8f;
}

.notification.success {
    background-color: #52c41a;
}

.notification.error {
    background-color: #e76f51;
}

.notification.warning {
    background-color: #faad14;
}

.notification.fade-out {
    animation: fadeOut 0.3s ease-out forwards;
}

@keyframes slideIn {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

@keyframes fadeOut {
    from {
        opacity: 1;
        transform: translateX(0);
    }
    to {
        opacity: 0;
        transform: translateX(100%);
    }
}

/* Responsive */
@media (max-width: 700px) {
    header {
        flex-direction: column;
        gap: 0.75rem;
    }
    .header-left, .header-right {
        flex-direction: column;
        gap: 0.5rem;
        width: 100%;
        justify-content: center;
    }
    .form-inline {
        flex-direction: column;
    }
    .form-inline > div {
        flex: 1 1 100%;
    }
    #add-object-footer {
        flex-direction: column;
        align-items: stretch;
        gap: 0.8rem;
    }
    #add-object-footer .left, #action-buttons {
        flex-grow: unset;
        display: flex;
        justify-content: center;
    }
}
