/* Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    font-size: 16px;
    line-height: 1.6;
    color: #333;
    background-color: #f5f5f5;
}

/* Layout with Sidebar */
.layout {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: 250px;
    background: #000000;
    color: white;
    display: flex;
    flex-direction: column;
    position: fixed;
    height: 100vh;
    overflow-y: auto;
    box-shadow: 2px 0 5px rgba(0,0,0,0.1);
}

.sidebar-header {
    padding: 0;
    border-bottom: 1px solid rgba(255,255,255,0.1);
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
}

.sidebar-header a {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
}

.sidebar-header img {
    display: block;
    width: 100%;
    height: auto;
    object-fit: contain;
}

.sidebar-header h2 {
    font-size: 1.5rem;
    font-weight: bold;
    color: white;
    margin: 0;
    padding: 20px;
}

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

.nav-item {
    display: flex;
    align-items: center;
    padding: 12px 20px;
    color: rgba(255,255,255,0.8);
    text-decoration: none;
    transition: all 0.3s ease;
}

.nav-item:hover {
    background: rgba(255,255,255,0.1);
    color: white;
}

.nav-item.active {
    background: rgba(255,159,28,0.3);
    color: white;
    border-left: 3px solid #FF9F1C;
}

.nav-icon {
    width: 20px;
    height: 20px;
    margin-right: 12px;
    font-size: 1.2rem;
}

.nav-text {
    font-size: 0.95rem;
}

.sidebar-footer {
    padding: 15px 20px;
    border-top: 1px solid rgba(255,255,255,0.1);
    background: rgba(0,0,0,0.2);
}

.user-profile {
    display: flex;
    gap: 12px;
    align-items: flex-start;
    margin-bottom: 12px;
}

.user-avatar {
    width: 40px;
    height: 40px;
    border-radius: 8px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    font-size: 0.85rem;
    color: white;
    flex-shrink: 0;
}

.user-details {
    flex: 1;
    min-width: 0;
}

.user-name {
    font-size: 0.95rem;
    font-weight: 700;
    color: white;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.user-username {
    font-size: 0.8rem;
    color: rgba(255,255,255,0.7);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.user-role {
    font-size: 0.75rem;
    color: rgba(255,255,255,0.6);
    margin-top: 2px;
    display: inline-block;
    background: rgba(255,255,255,0.1);
    padding: 2px 6px;
    border-radius: 3px;
}

.user-last-login {
    font-size: 0.7rem;
    color: rgba(255,255,255,0.5);
    margin-top: 3px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.btn-logout {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    background: rgba(255,255,255,0.08);
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: 6px;
    color: white;
    cursor: pointer;
    font-size: 0.95rem;
    transition: all 0.2s ease;
}

.btn-logout:hover {
    background: rgba(255,59,48,0.2);
    border-color: rgba(255,59,48,0.3);
    color: #ff3b30;
}

.btn-logout .nav-icon {
    font-size: 1.1rem;
}

.btn-logout .nav-text {
    font-size: 0.95rem;
}

.main-content {
    margin-left: 250px;
    flex: 1;
    padding: 0;
    background: #f5f5f5;
    min-height: 100vh;
}

.content-wrapper {
    padding: 20px;
}

/* Container */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
}

/* Navigation */
.navbar {
    background-color: #2c3e50;
    color: white;
    padding: 1rem 0;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.nav-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.nav-brand a {
    color: white;
    text-decoration: none;
    font-size: 1.5rem;
    font-weight: bold;
}

.nav-menu {
    display: flex;
    list-style: none;
    gap: 2rem;
    align-items: center;
}

.nav-menu a {
    color: white;
    text-decoration: none;
    transition: opacity 0.3s;
}

.nav-menu a:hover {
    opacity: 0.8;
}

.nav-user {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.btn-logout {
    background: #e74c3c;
    color: white;
    border: none;
    padding: 0.5rem 1rem;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.9rem;
}

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

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: 6px;
    text-decoration: none;
    cursor: pointer;
    font-size: 1rem;
    font-weight: 500;
    transition: all 0.3s ease;
    white-space: nowrap;
}

/* Primary Button - Arancione Martire */
.btn-primary {
    background-color: #FF9F1C;
    color: white;
    box-shadow: 0 2px 4px rgba(255, 159, 28, 0.2);
}

.btn-primary:hover {
    background-color: #E08A0E;
    box-shadow: 0 4px 8px rgba(255, 159, 28, 0.3);
    transform: translateY(-2px);
}

.btn-primary:active {
    transform: translateY(0);
    box-shadow: 0 1px 2px rgba(255, 159, 28, 0.2);
}

/* Secondary Button - Grigio */
.btn-secondary {
    background-color: #95a5a6;
    color: white;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.btn-secondary:hover {
    background-color: #7f8c8d;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
    transform: translateY(-2px);
}

.btn-secondary:active {
    transform: translateY(0);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

/* Outline Button - Bordo arancione */
.btn-outline {
    background-color: transparent;
    color: #FF9F1C;
    border: 2px solid #FF9F1C;
}

.btn-outline:hover {
    background-color: #FF9F1C;
    color: white;
    transform: translateY(-2px);
}

.btn-outline:active {
    transform: translateY(0);
}

/* Danger Button - Rosso */
.btn-danger {
    background-color: #e74c3c;
    color: white;
    box-shadow: 0 2px 4px rgba(231, 76, 60, 0.2);
}

.btn-danger:hover {
    background-color: #c0392b;
    box-shadow: 0 4px 8px rgba(231, 76, 60, 0.3);
    transform: translateY(-2px);
}

.btn-danger:active {
    transform: translateY(0);
    box-shadow: 0 1px 2px rgba(231, 76, 60, 0.2);
}

/* Success Button - Verde */
.btn-success {
    background-color: #27ae60;
    color: white;
    box-shadow: 0 2px 4px rgba(39, 174, 96, 0.2);
}

.btn-success:hover {
    background-color: #229954;
    box-shadow: 0 4px 8px rgba(39, 174, 96, 0.3);
    transform: translateY(-2px);
}

.btn-success:active {
    transform: translateY(0);
    box-shadow: 0 1px 2px rgba(39, 174, 96, 0.2);
}

/* Small Button */
.btn-sm {
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
}

/* Block Button */
.btn-block {
    display: flex;
    width: 100%;
    justify-content: center;
}

/* Button Group */
.btn-group {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

/* Alerts */
.alert {
    padding: 1rem;
    margin-bottom: 1rem;
    border-radius: 4px;
}

.alert-success {
    background-color: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}

.alert-error {
    background-color: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}

/* Forms */
.form {
    background: white;
    padding: 2rem;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

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

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

.form-group {
    display: flex;
    flex-direction: column;
}

.form-group label {
    margin-bottom: 0.5rem;
    font-weight: 500;
}

.form-group input,
.form-group select,
.form-group textarea {
    padding: 0.75rem;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 1rem;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: #FF9F1C;
}

.form-actions {
    margin-top: 2rem;
    display: flex;
    gap: 1rem;
}

/* Tables */
.table {
    width: 100%;
    background: white;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    margin: 1rem 0;
}

.table thead {
    background-color: #2c3e50;
    color: white;
}

.table th,
.table td {
    padding: 1rem;
    text-align: left;
    border-bottom: 1px solid #e9ecef;
}

.table tbody tr:hover {
    background-color: #f8f9fa;
}

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

.table a {
    color: #FF9F1C;
    text-decoration: none;
    font-weight: 500;
}

.table a:hover {
    color: #E08A0E;
    text-decoration: underline;
}

/* Tables in Cards */
.card table {
    width: 100%;
    border-collapse: collapse;
}

.card table thead {
    background-color: #2c3e50;
    color: white;
}

.card table th {
    padding: 0.875rem 1rem;
    text-align: left;
    font-weight: 600;
    font-size: 0.9rem;
}

.card table td {
    padding: 0.875rem 1rem;
    border-bottom: 1px solid #e9ecef;
}

.card table tbody tr:hover {
    background-color: #f8f9fa;
}

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

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

/* Page Header */
.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
}

.page-header h1 {
    font-size: 1.8rem;
    color: #2c3e50;
}

/* Card */
.card {
    background: white;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    padding: 1.5rem;
    margin-bottom: 1.5rem;
}

/* Filters */
.filters {
    display: flex;
    gap: 1rem;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
}

/* Stats Grid */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
    margin: 2rem 0;
}

/* Stats List */
.stats-list {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.stat-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 0;
    border-bottom: 1px solid #e9ecef;
}

.stat-item:last-child {
    border-bottom: none;
}

.stat-label {
    font-size: 0.9rem;
    color: #7f8c8d;
}

.stat-value {
    font-size: 1.25rem;
    font-weight: bold;
    color: #2c3e50;
}

.stat-card {
    background: white;
    padding: 1.5rem;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    text-align: center;
    display: flex;
    flex-direction: column;
}

.stat-card h3 {
    font-size: 0.9rem;
    color: #666;
    margin-bottom: 0.5rem;
}

.stat-link {
    margin-top: auto;
    color: #FF9F1C;
    font-weight: 600;
    font-size: 0.9rem;
    transition: all 0.2s ease;
}

.stat-link:hover {
    color: #E08A0E;
}

.stat-number {
    font-size: 2rem;
    font-weight: bold;
    color: #2c3e50;
}

/* Dashboard Sections */
.dashboard-sections {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(500px, 1fr));
    gap: 2rem;
    margin-top: 2rem;
}

.dashboard-section {
    background: white;
    padding: 2rem;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.dashboard-section h2 {
    margin-bottom: 1rem;
    color: #2c3e50;
}

/* Dashboard Appointments */
.appointments-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    margin-top: 1rem;
}

/* Appointments - Simile ai pulsanti per coerenza */
.appointment-item {
    display: flex;
    gap: 1rem;
    padding: 1rem;
    background: white;
    border-radius: 6px;
    border-left: 4px solid #FF9F1C;
    text-decoration: none;
    color: inherit;
    transition: all 0.2s ease;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.appointment-item:hover {
    background: #f8f9fa;
    box-shadow: 0 2px 8px rgba(255, 159, 28, 0.2);
    transform: translateX(4px);
}

.appointment-item.appointment-measurement {
    border-left-color: #3498db;
}

.appointment-item.appointment-installation {
    border-left-color: #27ae60;
}

.appointment-item.appointment-meeting {
    border-left-color: #f39c12;
}

.appointment-date {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-width: 50px;
    background: white;
    border-radius: 6px;
    padding: 0.5rem;
}

.apt-day {
    font-size: 1.5rem;
    font-weight: bold;
    color: #2c3e50;
    line-height: 1;
}

.apt-month {
    font-size: 0.75rem;
    text-transform: uppercase;
    color: #7f8c8d;
    margin-top: 0.25rem;
}

.appointment-details {
    flex: 1;
}

.apt-title {
    font-weight: 600;
    color: #2c3e50;
    margin-bottom: 0.25rem;
}

.apt-time {
    font-size: 0.85rem;
    color: #7f8c8d;
}

/* Status Badges */
.status {
    display: inline-block;
    padding: 0.35rem 0.75rem;
    border-radius: 12px;
    font-size: 0.8rem;
    font-weight: 600;
    text-transform: uppercase;
}

.status-draft {
    background-color: #ffeaa7;
    color: #d97706;
}

.status-sent {
    background-color: #dfe6e9;
    color: #2d3436;
}

.status-accepted {
    background-color: #d5f4e6;
    color: #0f9d58;
}

.status-rejected {
    background-color: #fecaca;
    color: #dc2626;
}

.status-pending {
    background-color: #ffeaa7;
    color: #d97706;
}

.status-confirmed {
    background-color: #dfe6e9;
    color: #2d3436;
}

.status-production {
    background-color: #dbeafe;
    color: #1e40af;
}

.status-ready {
    background-color: #d5f4e6;
    color: #0f9d58;
}

.status-shipped {
    background-color: #e0e7ff;
    color: #4f46e5;
}

.status-delivered {
    background-color: #d5f4e6;
    color: #0f9d58;
}

/* Quick Actions - Usiamo la classe .btn per coerenza */
.quick-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
}

.quick-action-btn {
    background: linear-gradient(135deg, #FF9F1C 0%, #E08A0E 100%);
    color: white;
    text-decoration: none;
    border-radius: 8px;
    transition: all 0.3s ease;
    box-shadow: 0 2px 4px rgba(255, 159, 28, 0.2);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem 1.25rem;
    font-weight: 500;
}

.quick-action-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(255, 159, 28, 0.3);
}

.quick-action-btn .action-icon {
    font-size: 1.5rem;
}

.quick-action-btn .action-text {
    font-size: 0.95rem;
}

.action-card {
    background: #f8f9fa;
    padding: 1.5rem;
    border-radius: 8px;
    text-align: center;
    text-decoration: none;
    color: #2c3e50;
    transition: all 0.3s ease;
    border: 2px solid transparent;
}

.action-card:hover {
    background: white;
    border-color: #3498db;
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0,0,0,0.1);
}

.action-card .icon {
    font-size: 2rem;
    margin-bottom: 0.5rem;
}

.action-card span {
    display: block;
    font-weight: 500;
}

/* Auth Page */
.auth-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.auth-container {
    width: 100%;
    max-width: 400px;
    padding: 20px;
}

.auth-card {
    background: white;
    padding: 2rem;
    border-radius: 8px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.1);
}

.auth-card h1 {
    text-align: center;
    color: #2c3e50;
    margin-bottom: 0.5rem;
}

.auth-card h2 {
    text-align: center;
    color: #7f8c8d;
    font-size: 1.2rem;
    font-weight: normal;
    margin-bottom: 2rem;
}

/* Search Box */
.search-box {
    margin: 1rem 0;
}

.search-box form {
    display: flex;
    gap: 0.5rem;
}

.search-box input {
    flex: 1;
    padding: 0.75rem;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 1rem;
}

/* Badge */
.badge {
    display: inline-block;
    padding: 0.25rem 0.75rem;
    border-radius: 12px;
    font-size: 0.875rem;
    font-weight: 500;
}

.badge-draft {
    background-color: #f39c12;
    color: white;
}

.badge-sent {
    background-color: #3498db;
    color: white;
}

.badge-accepted {
    background-color: #27ae60;
    color: white;
}

.badge-rejected {
    background-color: #e74c3c;
    color: white;
}

.badge-pending {
    background-color: #f39c12;
    color: white;
}

.badge-confirmed {
    background-color: #27ae60;
    color: white;
}

/* Error Page */
.error-container {
    text-align: center;
    padding: 4rem 2rem;
}

.error-container h1 {
    font-size: 6rem;
    color: #e74c3c;
    margin-bottom: 1rem;
}

.error-container h2 {
    font-size: 2rem;
    color: #2c3e50;
    margin-bottom: 1rem;
}

.error-container p {
    color: #7f8c8d;
    margin-bottom: 2rem;
}

/* Grid System */
.grid {
    display: grid;
    gap: 1.5rem;
    margin-bottom: 1.5rem;
}

.col-4 { grid-column: span 4; }
.col-6 { grid-column: span 6; }
.col-8 { grid-column: span 8; }
.col-12 { grid-column: span 12; }

@media (min-width: 768px) {
    .grid {
        grid-template-columns: repeat(12, 1fr);
    }
}

/* Info Table */
.info-table {
    width: 100%;
}

.info-table th {
    width: 35%;
    padding: 0.75rem;
    text-align: left;
    font-weight: 600;
    color: #7f8c8d;
    border-bottom: 1px solid #e9ecef;
}

.info-table td {
    padding: 0.75rem;
    border-bottom: 1px solid #e9ecef;
}

.info-table tr:last-child th,
.info-table tr:last-child td {
    border-bottom: none;
}

/* Text Utilities */
.text-right { text-align: right; }
.text-center { text-align: center; }
.text-muted { color: #95a5a6; }
.text-success { color: #27ae60; }
.text-danger { color: #e74c3c; }

/* Badges */
.badge {
    display: inline-block;
    padding: 0.25rem 0.75rem;
    border-radius: 4px;
    font-size: 0.875rem;
    font-weight: 500;
}

.badge-door { background: #dbeafe; color: #1e40af; }
.badge-window { background: #d5f4e6; color: #0f9d58; }
.badge-accessory { background: #fef3c7; color: #d97706; }
.badge-measurement { background: #dbeafe; color: #1e40af; }
.badge-installation { background: #d5f4e6; color: #0f9d58; }
.badge-meeting { background: #fef3c7; color: #d97706; }
.badge-other { background: #f3f4f6; color: #4b5563; }
.badge-company { background: #dbeafe; color: #1e40af; }
.badge-individual { background: #d5f4e6; color: #0f9d58; }
.badge-info { background: #f0f9ff; color: #0284c7; text-decoration: none; }

/* Card Header */
.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    padding-bottom: 1rem;
    border-bottom: 2px solid #e9ecef;
}

.card-header h2 {
    margin: 0;
}

/* Filter Group */
.filter-group {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.filter-group input,
.filter-group select {
    min-width: 200px;
}

/* Form Help Text */
.form-help {
    display: block;
    margin-top: 0.25rem;
    font-size: 0.875rem;
    color: #7f8c8d;
}

/* Button Block */
.btn-block {
    display: block;
    width: 100%;
    text-align: center;
}

/* Global Search Bar - Fixed Top */
.global-search-bar {
    position: fixed;
    top: 0;
    left: 250px;
    right: 0;
    height: 70px;
    background: white;
    border-bottom: 2px solid #FF9F1C;
    padding: 12px 2rem;
    z-index: 999;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
}

.global-search-bar form {
    position: relative;
    height: 100%;
    margin: 0;
}

#global-search-input {
    width: 100%;
    height: 100%;
    padding: 0 1.5rem;
    border: none;
    border-radius: 8px;
    font-size: 18px;
    font-weight: 500;
    background: #f9f9f9;
    color: #333;
    transition: all 0.3s ease;
}

#global-search-input::placeholder {
    color: #999;
    font-weight: 400;
}

#global-search-input:focus {
    outline: none;
    background: #ffffff;
    box-shadow: inset 0 0 0 2px #FF9F1C;
}

.search-results-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: white;
    border: 1px solid #ddd;
    border-top: none;
    border-radius: 0 0 8px 8px;
    max-height: 400px;
    overflow-y: auto;
    z-index: 1000;
    display: none;
    box-shadow: 0 8px 16px rgba(0,0,0,0.12);
    margin-top: 8px;
}

.search-results-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.search-result-item {
    padding: 1rem 1.5rem;
    cursor: pointer;
    border-bottom: 1px solid #f0f0f0;
    transition: background-color 0.2s ease;
}

.search-result-item:hover,
.search-result-item.focused {
    background-color: #f9f9f9;
    border-left: 4px solid #FF9F1C;
    padding-left: calc(1.5rem - 4px);
}

.search-result-name {
    font-weight: 600;
    color: #333;
    margin-bottom: 0.3rem;
    font-size: 15px;
}

.search-result-details {
    font-size: 13px;
    color: #666;
    display: flex;
    gap: 1.5rem;
}

.result-email,
.result-phone {
    display: inline-block;
}

.result-email::before {
    content: '📧 ';
}

.result-phone::before {
    content: '📱 ';
}

.search-no-results {
    padding: 2rem;
    text-align: center;
    color: #999;
    font-size: 15px;
}

/* Adjust main-content for fixed search bar */
.main-content {
    padding-top: 70px;
}

/* Actions Column */
td.actions {
    white-space: nowrap;
}

td.actions form {
    display: inline;
}

/* Responsive */
@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
    }
    
    .sidebar.active {
        transform: translateX(0);
    }
    
    .main-content {
        margin-left: 0;
        padding-top: 70px;
    }
    
    .global-search-bar {
        left: 0;
    }
    
    .form-grid {
        grid-template-columns: 1fr;
    }
    
    .grid {
        grid-template-columns: 1fr !important;
    }
    
    .col-4, .col-6, .col-8, .col-12 {
        grid-column: span 1;
    }
    
    .page-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 1rem;
    }
    
    .filter-group input,
    .filter-group select {
        min-width: 100%;
    }
}

/* ============================================================
   UX POLISH (v2) — grafici, card, bottoni, stati
   ============================================================ */

/* --- Grafici dashboard --- */
.charts-grid {
    display: grid;
    grid-template-columns: 2fr 1fr 1fr;
    gap: 1rem;
    margin: 0 0 2rem;
}
.chart-card { display: flex; flex-direction: column; }
.chart-card-wide { grid-column: span 1; }
.chart-wrap { position: relative; height: 280px; padding-top: 0.5rem; }
.chart-wrap-doughnut { height: 280px; }

@media (max-width: 1100px) {
    .charts-grid { grid-template-columns: 1fr 1fr; }
    .chart-card-wide { grid-column: 1 / -1; }
}
@media (max-width: 700px) {
    .charts-grid { grid-template-columns: 1fr; }
}

/* --- Stat card: accento colorato + sollevamento --- */
.stat-card {
    position: relative;
    overflow: hidden;
    transition: transform 0.18s ease, box-shadow 0.18s ease;
    border-top: 4px solid #FF9F1C;
}
.stat-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 20px rgba(0,0,0,0.12);
}
.stat-card .stat-icon {
    font-size: 2rem;
    line-height: 1;
    margin-bottom: 0.5rem;
}
.stat-card .stat-value {
    font-size: 2rem;
    font-weight: 800;
    color: #1f2937;
}
.stat-card.stat-warning { border-top-color: #f59e0b; }
.stat-card.stat-success { border-top-color: #10b981; }

/* --- Azioni rapide: più grandi e cliccabili --- */
.quick-action-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.25rem;
    background: #fff;
    border: 2px solid #eee;
    border-radius: 12px;
    color: #1f2937;
    text-decoration: none;
    font-weight: 600;
    transition: all 0.18s ease;
    min-height: 110px;
}
.quick-action-btn:hover {
    border-color: #FF9F1C;
    background: #fff8ef;
    transform: translateY(-3px);
    box-shadow: 0 6px 16px rgba(255,159,28,0.18);
}

/* --- Bottoni: target più ampi (touch friendly) --- */
.btn {
    font-size: 1rem;
    padding: 0.65rem 1.15rem;
    border-radius: 8px;
}
.btn:focus-visible { outline: 3px solid rgba(255,159,28,0.5); outline-offset: 2px; }
.btn-sm { padding: 0.4rem 0.7rem; font-size: 0.85rem; }

/* --- Card un filo più morbide --- */
.card {
    border-radius: 12px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.06), 0 6px 16px rgba(0,0,0,0.04);
}

/* --- Empty state con call-to-action --- */
.empty-state {
    text-align: center;
    padding: 2.5rem 1rem;
    color: #6b7280;
}
.empty-state .empty-icon { font-size: 2.5rem; display: block; margin-bottom: 0.5rem; opacity: 0.6; }
.empty-state p { margin-bottom: 1rem; }

/* --- Badge di stato: pill colorate coerenti --- */
.status {
    display: inline-block;
    padding: 0.2rem 0.7rem;
    border-radius: 999px;
    font-size: 0.78rem;
    font-weight: 700;
    line-height: 1.6;
}
.status-draft   { background: #e5e7eb; color: #374151; }
.status-sent    { background: #dbeafe; color: #1e40af; }
.status-pending { background: #fef3c7; color: #92400e; }
.status-confirmed,
.status-accepted{ background: #d1fae5; color: #065f46; }
.status-in_production,
.status-production { background: #fde68a; color: #92400e; }
.status-ready   { background: #cffafe; color: #155e75; }
.status-delivered { background: #dcfce7; color: #166534; }
.status-rejected,
.status-cancelled { background: #fee2e2; color: #991b1b; }
.status-expired { background: #f3e8ff; color: #6b21a8; }

/* --- Toast notifiche (AJAX) --- */
.toast-container {
    position: fixed;
    top: 1rem;
    right: 1rem;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
    max-width: 360px;
}
.toast {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    background: #fff;
    color: #1f2937;
    padding: 0.85rem 1.1rem;
    border-radius: 10px;
    box-shadow: 0 8px 24px rgba(0,0,0,0.18);
    border-left: 5px solid #10b981;
    font-weight: 600;
    opacity: 0;
    transform: translateX(120%);
    transition: opacity .3s ease, transform .3s ease;
}
.toast.show { opacity: 1; transform: translateX(0); }
.toast-error { border-left-color: #ef4444; }
.toast-icon { font-size: 1.1rem; }

@media (max-width: 600px) {
    .toast-container { left: 1rem; right: 1rem; max-width: none; }
}
