/* ========================================
   GESTIONE OPERATIVA - AZIENDA AGRICOLA
   ======================================== */

/* Base / Reset */
*,
*::before,
*::after {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background-color: #f5f7f5;
    color: #333;
    font-size: 14px;
    line-height: 1.5;
}

/* ========================================
   LAYOUT
   ======================================== */
.app-container {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: 260px;
    min-width: 260px;
    background-color: #2F5233;
    color: white;
    display: flex;
    flex-direction: column;
    position: fixed;
    height: 100vh;
    overflow-y: auto;
}

.main-content {
    flex: 1;
    margin-left: 260px;
    padding: 24px 32px;
    overflow-y: auto;
}

/* ========================================
   SIDEBAR
   ======================================== */
.sidebar-header {
    padding: 24px 20px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.sidebar-header h1 {
    margin: 0;
    font-size: 18px;
    font-weight: 700;
}

.sidebar-header small {
    display: block;
    opacity: 0.7;
    font-size: 12px;
    margin-top: 4px;
}

.sidebar-nav {
    padding: 12px 0;
    flex: 1;
}

.nav-item {
    display: block;
    padding: 10px 20px;
    color: rgba(255, 255, 255, 0.8);
    text-decoration: none;
    cursor: pointer;
    transition: background 0.2s;
    font-size: 14px;
}

.nav-item:hover {
    background: rgba(255, 255, 255, 0.1);
    color: white;
}

.nav-item.active {
    background: rgba(255, 255, 255, 0.15);
    color: white;
    border-left: 3px solid white;
    font-weight: 600;
}

.nav-group-label {
    padding: 16px 20px 6px;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: rgba(255, 255, 255, 0.4);
    font-weight: 600;
}

/* ========================================
   CONTENT SECTIONS
   ======================================== */
.content-section {
    display: none;
}

.content-section.active {
    display: block;
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.section-header h2 {
    margin: 0;
    font-size: 22px;
    color: #2F5233;
}

.section-header h3 {
    margin: 0;
    font-size: 18px;
}

/* ========================================
   FILTERS
   ======================================== */
.filters-bar {
    display: flex;
    gap: 12px;
    margin-bottom: 16px;
    flex-wrap: wrap;
}

.filters-bar input,
.filters-bar select {
    padding: 8px 12px;
    border: 1px solid #e0e5e0;
    border-radius: 6px;
    font-size: 13px;
    background: white;
    min-width: 140px;
    max-width: 220px;
}

.filters-bar input:focus,
.filters-bar select:focus {
    border-color: #4a7c59;
    outline: none;
}

/* ========================================
   TABLES
   ======================================== */
.table-container {
    overflow-x: auto;
    background: white;
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

.data-table {
    width: 100%;
    border-collapse: collapse;
}

.data-table th {
    background: #f8faf8;
    padding: 12px 14px;
    text-align: left;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #666;
    border-bottom: 2px solid #e0e5e0;
    white-space: nowrap;
}

.data-table td {
    padding: 10px 14px;
    border-bottom: 1px solid #f0f2f0;
    font-size: 13px;
    vertical-align: middle;
}

.data-table tr:hover {
    background: #f8faf8;
}

.actions-cell {
    white-space: nowrap;
    display: flex;
    gap: 6px;
}

/* ========================================
   BUTTONS
   ======================================== */
.btn {
    padding: 8px 16px;
    border-radius: 6px;
    border: none;
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.btn-primary {
    background-color: #2F5233;
    color: white;
}

.btn-primary:hover {
    background-color: #1e3a22;
}

.btn-secondary {
    background-color: #e8ebe8;
    color: #555;
}

.btn-secondary:hover {
    background-color: #d8dbd8;
}

.btn-danger {
    background-color: #c0392b;
    color: white;
}

.btn-danger:hover {
    background-color: #a93226;
}

.btn-warning {
    background-color: #e67e22;
    color: white;
}

.btn-warning:hover {
    background-color: #d35400;
}

.btn-sm {
    padding: 5px 10px;
    font-size: 12px;
}

.btn-icon {
    padding: 6px 8px;
    font-size: 14px;
    border-radius: 4px;
    background: transparent;
    color: #666;
    border: none;
    cursor: pointer;
    transition: background 0.2s;
}

.btn-icon:hover {
    background: #f0f2f0;
}

/* ========================================
   MODALS
   ======================================== */
.modal-overlay {
    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;
    z-index: 1000;
}

.modal {
    background: white;
    border-radius: 12px;
    width: 90%;
    max-width: 680px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.15);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 24px;
    border-bottom: 1px solid #e0e5e0;
}

.modal-header h3 {
    margin: 0;
    font-size: 18px;
    color: #2F5233;
}

.modal-close {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: #999;
    padding: 0;
    line-height: 1;
}

.modal-close:hover {
    color: #333;
}

.modal-body {
    padding: 24px;
}

/* ========================================
   FORMS
   ======================================== */
.form-group {
    margin-bottom: 16px;
}

.form-group label {
    display: block;
    margin-bottom: 6px;
    font-size: 13px;
    font-weight: 500;
    color: #555;
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 9px 12px;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 14px;
    box-sizing: border-box;
    font-family: inherit;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    border-color: #4a7c59;
    outline: none;
    box-shadow: 0 0 0 2px rgba(74, 124, 89, 0.15);
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

.form-group.checkbox-group {
    display: flex;
    align-items: center;
    gap: 8px;
}

.form-group.checkbox-group input[type="checkbox"] {
    width: auto;
}

.form-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 20px;
    padding-top: 16px;
    border-top: 1px solid #eee;
}

/* ========================================
   DASHBOARD
   ======================================== */
.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
    margin-bottom: 20px;
}

.dashboard-grid-2 {
    grid-template-columns: 1fr 1fr;
}

.dash-card {
    background: white;
    border-radius: 10px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
    overflow: hidden;
}

.dash-card-header {
    padding: 14px 18px;
    font-size: 13px;
    font-weight: 600;
    color: #555;
    border-bottom: 1px solid #f0f2f0;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.dash-card-body {
    padding: 18px;
}

.stat-number {
    font-size: 32px;
    font-weight: 700;
    color: #2F5233;
}

.stat-label {
    font-size: 12px;
    color: #999;
    margin-top: 4px;
}

.dash-list {
    max-height: 200px;
    overflow-y: auto;
}

.dash-list-item {
    padding: 8px 0;
    border-bottom: 1px solid #f5f5f5;
    font-size: 13px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.dash-list-item:last-child {
    border-bottom: none;
}

/* ========================================
   STATUS BADGES
   ======================================== */
.status-badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.badge-pianificata {
    background: #eaf2fb;
    color: #2980b9;
}

.badge-in-corso {
    background: #fef3e2;
    color: #e67e22;
}

.badge-completata {
    background: #e8f8ef;
    color: #27ae60;
}

.badge-assegnato {
    background: #eaf2fb;
    color: #2980b9;
}

.badge-warning {
    background: #fef3e2;
    color: #e67e22;
}

.badge-danger {
    background: #fde8e8;
    color: #c0392b;
}

/* ========================================
   NOTIFICATIONS
   ======================================== */
.notification {
    position: fixed;
    top: 20px;
    right: 20px;
    padding: 14px 20px;
    border-radius: 8px;
    color: white;
    font-size: 14px;
    z-index: 2000;
    animation: slideIn 0.3s ease;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    max-width: 400px;
}

.notification-success {
    background: #27ae60;
}

.notification-error {
    background: #c0392b;
}

.notification-warning {
    background: #e67e22;
}

@keyframes slideIn {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

/* ========================================
   SECTION SUMMARY
   ======================================== */
.section-summary {
    margin-top: 16px;
    padding: 16px 20px;
    background: white;
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
    font-size: 14px;
}

.summary-row {
    display: flex;
    justify-content: space-between;
    padding: 6px 0;
    border-bottom: 1px solid #f5f5f5;
}

.summary-row:last-child {
    border-bottom: none;
}

.summary-label {
    color: #777;
}

.summary-value {
    font-weight: 600;
    color: #2F5233;
}

/* ========================================
   UTILITIES
   ======================================== */
.text-muted {
    color: #999;
}

.text-right {
    text-align: right;
}

.empty-state {
    text-align: center;
    padding: 40px;
    color: #999;
    font-size: 14px;
}

.today-date {
    font-size: 14px;
    color: #777;
    font-weight: normal;
}

/* ========================================
   MANUTENZIONI PANEL
   ======================================== */
#manutenzioni-panel {
    margin-top: 20px;
    padding-top: 20px;
    border-top: 2px solid #e0e5e0;
}

#manutenzioni-panel .section-header {
    margin-bottom: 12px;
    gap: 8px;
    display: flex;
    align-items: center;
}

#manutenzioni-panel .section-header h3 {
    font-size: 16px;
}

/* ========================================
   RESPONSIVE
   ======================================== */
@media (max-width: 768px) {
    .sidebar {
        width: 200px;
        min-width: 200px;
    }

    .main-content {
        margin-left: 200px;
        padding: 16px;
    }

    .dashboard-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .dashboard-grid-2 {
        grid-template-columns: 1fr;
    }

    .form-row {
        grid-template-columns: 1fr;
    }
}