/**
 * CSS Base per Applicativo Ordini B2B
 * Integrazione con Tailwind CSS e stili personalizzati
 */

/* Configurazione base */
:root {
    --primary-color: #3B82F6;
    --primary-dark: #1D4ED8;
    --success-color: #10B981;
    --error-color: #EF4444;
    --warning-color: #F59E0B;
    --gray-50: #F9FAFB;
    --gray-100: #F3F4F6;
    --gray-200: #E5E7EB;
    --gray-500: #6B7280;
    --gray-900: #111827;
}

/* Miglioramenti layout container */
.max-w-7xl {
    max-width: 90rem;
}

.container-wide {
    max-width: 95%;
    margin: 0 auto;
    padding: 0 1rem;
}

@media (min-width: 1024px) {
    .container-wide {
        padding: 0 2rem;
    }
}

/* Reset e base */
* {
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    line-height: 1.6;
    color: var(--gray-900);
    background-color: var(--gray-50);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Utility classes personalizzate */
.btn-primary {
    background-color: var(--primary-color);
    color: white;
    padding: 0.5rem 1rem;
    border-radius: 0.375rem;
    border: none;
    cursor: pointer;
    transition: background-color 0.2s;
    font-weight: 500;
    text-decoration: none;
    display: inline-block;
    text-align: center;
}

.btn-primary:hover {
    background-color: var(--primary-dark);
}

.btn-secondary {
    background-color: var(--gray-200);
    color: var(--gray-900);
    padding: 0.5rem 1rem;
    border-radius: 0.375rem;
    border: none;
    cursor: pointer;
    transition: background-color 0.2s;
    font-weight: 500;
    text-decoration: none;
    display: inline-block;
    text-align: center;
}

.btn-secondary:hover {
    background-color: var(--gray-100);
}

.btn-success {
    background-color: var(--success-color);
    color: white;
    padding: 0.5rem 1rem;
    border-radius: 0.375rem;
    border: none;
    cursor: pointer;
    transition: background-color 0.2s;
    font-weight: 500;
    text-decoration: none;
    display: inline-block;
    text-align: center;
}

.btn-success:hover {
    background-color: #059669;
}

.btn-danger {
    background-color: var(--error-color);
    color: white;
    padding: 0.5rem 1rem;
    border-radius: 0.375rem;
    border: none;
    cursor: pointer;
    transition: background-color 0.2s;
    font-weight: 500;
    text-decoration: none;
    display: inline-block;
    text-align: center;
}

.btn-danger:hover {
    background-color: #DC2626;
}

/* Form styling */
.form-input {
    width: 100%;
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--gray-200);
    border-radius: 0.375rem;
    background-color: white;
    font-size: 0.875rem;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.form-input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.form-select {
    width: 100%;
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--gray-200);
    border-radius: 0.375rem;
    background-color: white;
    font-size: 0.875rem;
    cursor: pointer;
}

.form-textarea {
    width: 100%;
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--gray-200);
    border-radius: 0.375rem;
    background-color: white;
    font-size: 0.875rem;
    resize: vertical;
    min-height: 5rem;
}

/* Table styling */
.table-container {
    overflow-x: auto;
    box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1);
    border-radius: 0.5rem;
}

.table-responsive {
    min-width: 100%;
    background-color: white;
    border-collapse: collapse;
}

.table-responsive th {
    background-color: var(--gray-50);
    padding: 0.75rem 1.5rem;
    text-align: left;
    font-weight: 600;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--gray-500);
    border-bottom: 1px solid var(--gray-200);
}

.table-responsive td {
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--gray-200);
    white-space: nowrap;
}

.table-responsive tr:hover {
    background-color: var(--gray-50);
}

/* Card styling */
.card {
    background-color: white;
    border-radius: 0.75rem;
    box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px 0 rgba(0, 0, 0, 0.06);
    overflow: hidden;
}

.card-header {
    padding: 1.5rem;
    border-bottom: 1px solid var(--gray-200);
    background-color: var(--gray-50);
}

.card-body {
    padding: 2rem;
}

.card-footer {
    padding: 1.5rem;
    border-top: 1px solid var(--gray-200);
    background-color: var(--gray-50);
}

/* Statistiche cards miglioramento */
.stats-card {
    background: linear-gradient(135deg, #ffffff 0%, #f8fafc 100%);
    border: 1px solid #e2e8f0;
    transition: all 0.3s ease;
}

.stats-card:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

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

/* Dashboard cards responsive */
.dashboard-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1.5rem;
}

.dashboard-main-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
    gap: 2rem;
}

/* Miglioramento card hover */
.dashboard-card {
    transition: transform 0.2s ease-in-out, box-shadow 0.2s ease-in-out;
}

.dashboard-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
}

/* Responsive breakpoints */
@media (max-width: 1200px) {
    .dashboard-main-cards {
        grid-template-columns: repeat(auto-fit, minmax(350px, 1fr));
    }
}

@media (max-width: 768px) {

    .dashboard-grid,
    .dashboard-stats,
    .dashboard-main-cards {
        grid-template-columns: 1fr;
    }

    .dashboard-main-cards {
        gap: 1.5rem;
    }
}

@media (max-width: 480px) {
    .dashboard-stats {
        grid-template-columns: repeat(2, 1fr);
        gap: 1rem;
    }
}

/* Effetto pulse per CTA principale (es. "Nuovo Ordine") */
.btn-pulse {
    animation: btn-pulse 2s ease-in-out infinite;
}

@keyframes btn-pulse {
    0%, 100% {
        box-shadow: 0 0 0 0 rgba(22, 163, 74, 0.6);
    }
    50% {
        box-shadow: 0 0 0 16px rgba(22, 163, 74, 0);
    }
}

/* Loading spinner */
.spinner {
    display: inline-block;
    width: 1rem;
    height: 1rem;
    border: 2px solid var(--gray-200);
    border-radius: 50%;
    border-top-color: var(--primary-color);
    animation: spin 1s ease-in-out infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* Status badges */
.status-badge {
    display: inline-flex;
    align-items: center;
    padding: 0.25rem 0.5rem;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.025em;
}

.status-success {
    background-color: #D1FAE5;
    color: #065F46;
}

.status-warning {
    background-color: #FEF3C7;
    color: #92400E;
}

.status-error {
    background-color: #FEE2E2;
    color: #991B1B;
}

.status-info {
    background-color: #DBEAFE;
    color: #1E40AF;
}

/* Notification styles */
.notification {
    position: fixed;
    top: 1rem;
    right: 1rem;
    max-width: 24rem;
    background-color: white;
    border-radius: 0.5rem;
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
    border: 1px solid var(--gray-200);
    z-index: 9999;
    transition: all 0.3s ease;
}

.notification.show {
    opacity: 1;
    transform: translateY(0);
}

.notification.hide {
    opacity: 0;
    transform: translateY(-1rem);
}

/* Mobile responsive */
@media (max-width: 640px) {
    .container {
        padding-left: 1rem;
        padding-right: 1rem;
    }

    .table-container {
        font-size: 0.875rem;
    }

    .table-responsive th,
    .table-responsive td {
        padding: 0.5rem;
    }

    .btn-primary,
    .btn-secondary,
    .btn-success,
    .btn-danger {
        padding: 0.75rem 1rem;
        font-size: 0.875rem;
        width: 100%;
        margin-bottom: 0.5rem;
    }
}

/* Print styles */
@media print {
    .no-print {
        display: none !important;
    }

    body {
        background-color: white;
    }

    .card {
        box-shadow: none;
        border: 1px solid var(--gray-200);
    }
}

/* AGGIUNGERE QUESTO CSS AL FILE public/css/app.css O NELLA HEAD DEL TEMPLATE */

/* Stile per le card documenti - identico alle immagini */
.document-card {
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

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

/* Checkbox permessi - mobile friendly */
.permessi-checkbox-all,
.permessi-checkbox {
    width: 16px !important;
    height: 16px !important;
    margin-right: 8px !important;
}

/* Container checkbox permessi */
.distributore-checkbox-label {
    padding: 8px;
    margin: 2px 0;
    border-radius: 4px;
    transition: background-color 0.2s ease;
}

.distributore-checkbox-label:hover {
    background-color: #f3f4f6;
}

/* Checkbox disabilitate quando "Tutti" è selezionato */
.distributore-checkbox-label input:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.distributore-checkbox-label input:disabled+span {
    opacity: 0.5;
    color: #9ca3af;
}

/* Stile per "Tutti" - evidenziato */
label:has(.permessi-checkbox-all) {
    font-weight: 500;
    background-color: #f0fdf4;
    padding: 8px;
    border-radius: 6px;
    border: 1px solid #bbf7d0;
}

label:has(.permessi-checkbox-all:checked) {
    background-color: #dcfce7;
    border-color: #86efac;
}

/* Area scrollabile per distributori - aumentata altezza */
.max-h-48 {
    scrollbar-width: thin;
    scrollbar-color: #d1d5db #f9fafb;
}

.max-h-48::-webkit-scrollbar {
    width: 6px;
}

.max-h-48::-webkit-scrollbar-track {
    background: #f9fafb;
    border-radius: 3px;
}

.max-h-48::-webkit-scrollbar-thumb {
    background: #d1d5db;
    border-radius: 3px;
}

.max-h-48::-webkit-scrollbar-thumb:hover {
    background: #9ca3af;
}

/* Modale permessi */
#permessiModal {
    backdrop-filter: blur(4px);
}

#permessiModal .bg-white {
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
}

/* Lista permessi nella modale */
#permessiModalContent ul {
    max-height: 300px;
    overflow-y: auto;
}

#permessiModalContent li {
    border-bottom: 1px solid #f3f4f6;
    padding-bottom: 8px;
    margin-bottom: 8px;
}

#permessiModalContent li:last-child {
    border-bottom: none;
    margin-bottom: 0;
    padding-bottom: 0;
}

/* Responsive grid personalizzato per documenti */
/* Mobile: sempre massimo 2 colonne per leggibilità */
@media (max-width: 768px) {
    #documentsGrid.grid-cols-1 {
        grid-template-columns: repeat(1, 1fr) !important;
    }

    #documentsGrid.grid-cols-2 {
        grid-template-columns: repeat(2, 1fr) !important;
    }

    #documentsGrid[class*="md:grid-cols"] {
        grid-template-columns: repeat(2, 1fr) !important;
    }
}

/* Tablet e Desktop */
@media (min-width: 768px) {
    #documentsGrid.md\\:grid-cols-1 {
        grid-template-columns: repeat(1, 1fr) !important;
    }

    #documentsGrid.md\\:grid-cols-2 {
        grid-template-columns: repeat(2, 1fr) !important;
    }

    #documentsGrid.md\\:grid-cols-3 {
        grid-template-columns: repeat(3, 1fr) !important;
    }

    #documentsGrid.md\\:grid-cols-4 {
        grid-template-columns: repeat(4, 1fr) !important;
    }

    #documentsGrid.md\\:grid-cols-5 {
        grid-template-columns: repeat(5, 1fr) !important;
    }

    #documentsGrid.md\\:grid-cols-6 {
        grid-template-columns: repeat(6, 1fr) !important;
    }
}

/* Hover effects per action buttons */
.document-card .bg-black.bg-opacity-50 {
    backdrop-filter: blur(2px);
}

/* Stile per badge ID */
.document-card .bg-blue-600 {
    background: linear-gradient(45deg, #3b82f6, #1d4ed8);
}

/* Badge permessi multipli */
.bg-blue-100 {
    background-color: #dbeafe;
}

.text-blue-800 {
    color: #1e40af;
}

/* Animazioni per filtri */
.document-card {
    animation: fadeIn 0.3s ease-in-out;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: scale(0.95);
    }

    to {
        opacity: 1;
        transform: scale(1);
    }
}

/* Responsive modale su mobile */
@media (max-width: 640px) {
    #permessiModal .w-96 {
        width: 90% !important;
        max-width: none !important;
    }

    /* Aumenta area cliccabile checkbox su mobile */
    .distributore-checkbox-label {
        padding: 12px;
        margin: 4px 0;
        font-size: 16px;
        /* Previene zoom su iPhone */
    }

    .permessi-checkbox-all,
    .permessi-checkbox {
        width: 20px !important;
        height: 20px !important;
        margin-right: 12px !important;
    }
}