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

:root {
    --primary-color: #1e40af;
    --primary-hover: #1e3a8a;
    --primary-light: #dbeafe;
    --secondary-color: #6366f1;
    --success-color: #10b981;
    --success-light: #d1fae5;
    --warning-color: #f59e0b;
    --warning-light: #fef3c7;
    --error-color: #ef4444;
    --error-light: #fee2e2;
    --background-color: #f9fafb;
    --card-background: #ffffff;
    --text-primary: #111827;
    --text-secondary: #6b7280;
    --text-light: #9ca3af;
    --border-color: #e5e7eb;
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
    --radius: 0.5rem;
    --radius-lg: 0.75rem;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background-color: var(--background-color);
    color: var(--text-primary);
    line-height: 1.6;
    font-size: 16px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* Typography */
h1, h2, h3, h4, h5, h6 {
    font-weight: 600;
    line-height: 1.25;
    color: var(--text-primary);
}

h1 { font-size: 2.25rem; }
h2 { font-size: 1.875rem; }
h3 { font-size: 1.5rem; }

/* Utility classes */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.625rem 1.25rem;
    border: none;
    border-radius: var(--radius);
    font-size: 0.875rem;
    font-weight: 500;
    text-decoration: none;
    cursor: pointer;
    transition: all 0.2s ease;
    text-align: center;
    white-space: nowrap;
    user-select: none;
    gap: 0.5rem;
}

.btn:hover {
    transform: translateY(-1px);
    box-shadow: var(--shadow-lg);
}

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

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

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

.btn-secondary {
    background-color: #f3f4f6;
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}

.btn-secondary:hover {
    background-color: #e5e7eb;
}

.btn-upload {
    background-color: var(--secondary-color);
    color: white;
}

.btn-upload:hover {
    background-color: #4f46e5;
}

.btn-send-all {
    background: linear-gradient(135deg, var(--success-color), #059669);
    color: white;
    padding: 0.875rem 2rem;
    font-size: 1rem;
    box-shadow: var(--shadow);
}

.btn-send-all:hover {
    background: linear-gradient(135deg, #059669, #047857);
}

.btn-logout {
    background-color: transparent;
    color: var(--error-color);
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
    border: 1px solid var(--error-color);
}

.btn-logout:hover {
    background-color: var(--error-color);
    color: white;
}

.btn-download {
    background-color: var(--primary-color);
    color: white;
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
}

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

/* Alert messages */
.alert {
    padding: 1rem 1.5rem;
    border-radius: var(--radius-lg);
    margin-bottom: 1.5rem;
    font-size: 0.875rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    animation: slideDown 0.3s ease-out;
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.alert-error {
    background-color: var(--error-light);
    color: #991b1b;
    border-left: 4px solid var(--error-color);
}

.alert-success {
    background-color: var(--success-light);
    color: #065f46;
    border-left: 4px solid var(--success-color);
}

.alert-warning {
    background-color: var(--warning-light);
    color: #92400e;
    border-left: 4px solid var(--warning-color);
}

/* Login page */
.login-container {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    background: linear-gradient(135deg, #eff6ff 0%, #f3e8ff 100%);
}

.login-box {
    background-color: var(--card-background);
    padding: 3rem 2.5rem;
    border-radius: 1rem;
    box-shadow: var(--shadow-xl);
    width: 100%;
    max-width: 420px;
    animation: fadeInUp 0.5s ease-out;
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.login-box h1 {
    font-size: 2rem;
    font-weight: 700;
    color: var(--primary-color);
    margin-bottom: 0.5rem;
    text-align: center;
}

.login-box h2 {
    font-size: 1rem;
    font-weight: 400;
    color: var(--text-secondary);
    margin-bottom: 2.5rem;
    text-align: center;
}

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

.form-group label {
    display: block;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-primary);
    margin-bottom: 0.5rem;
}

.form-group input {
    width: 100%;
    padding: 0.75rem 1rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    font-size: 1rem;
    transition: all 0.2s;
    background-color: #f9fafb;
}

.form-group input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px var(--primary-light);
    background-color: white;
}

.login-box .btn-primary {
    width: 100%;
    padding: 0.875rem;
    font-size: 1rem;
    margin-top: 0.5rem;
}

/* Admin page */
.admin-container {
    min-height: 100vh;
    background-color: var(--background-color);
}

/* Navbar styles */
.navbar {
    background-color: var(--card-background);
    padding: 1.5rem 2rem;
    box-shadow: var(--shadow-sm);
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border-color);
    gap: 1rem;
}

.navbar-left {
    flex: 1;
}

.navbar-center {
    display: flex;
    justify-content: center;
    align-items: center;
}

.navbar-right {
    flex: 1;
    display: flex;
    justify-content: flex-end;
}

.navbar-btn {
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    color: white;
    padding: 0.75rem 1.5rem;
    font-weight: 600;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    transition: all 0.3s ease;
    min-width: 220px;
}

.navbar-btn:hover {
    background: linear-gradient(135deg, var(--primary-hover), #4f46e5);
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.navbar-btn i {
    font-size: 1.1rem;
}

/* Legacy header styles for backward compatibility */
header {
    background-color: var(--card-background);
    padding: 1.5rem 2rem;
    box-shadow: var(--shadow-sm);
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border-color);
}

header h1 {
    font-size: 1.75rem;
    font-weight: 700;
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 1rem;
    font-size: 0.875rem;
    color: var(--text-secondary);
}

main {
    padding: 2.5rem;
    max-width: 1400px;
    margin: 0 auto;
}

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

.upload-section {
    background-color: var(--card-background);
    padding: 2rem;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    transition: all 0.3s ease;
    border: 2px solid transparent;
}

.upload-section:hover {
    box-shadow: var(--shadow-lg);
    border-color: var(--primary-light);
    transform: translateY(-2px);
}

.upload-section.drag-over {
    border-color: var(--primary-color);
    background-color: var(--primary-light);
    transform: scale(1.02);
}

.upload-section h2 {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 0.5rem;
}

.file-count {
    font-size: 0.875rem;
    color: var(--text-secondary);
    margin-bottom: 1.5rem;
}

.file-count span {
    font-weight: 600;
    color: var(--primary-color);
    font-size: 1.125rem;
}

.upload-form {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.file-input-wrapper {
    position: relative;
}

.file-input {
    position: absolute;
    opacity: 0;
    width: 100%;
    height: 100%;
    cursor: pointer;
}

.file-names {
    display: block;
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin-top: 0.5rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.actions-container {
    text-align: center;
    margin-top: 3rem;
    padding-top: 2rem;
    border-top: 1px solid var(--border-color);
}

/* Documents page */
.documents-container {
    min-height: 100vh;
    background-color: var(--background-color);
}

.no-documents {
    text-align: center;
    padding: 5rem 2rem;
    color: var(--text-secondary);
}

.no-documents p {
    font-size: 1.125rem;
}

.documents-grid {
    display: grid;
    gap: 2rem;
}

.company-section {
    background-color: var(--card-background);
    padding: 2rem;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    animation: fadeIn 0.5s ease-out;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

.company-section h2 {
    font-size: 1.375rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 1.5rem;
    padding-bottom: 1rem;
    border-bottom: 2px solid var(--border-color);
}

.documents-list {
    display: grid;
    gap: 1rem;
}

.document-item {
    display: flex;
    align-items: center;
    gap: 1.25rem;
    padding: 1.25rem;
    background-color: #f9fafb;
    border-radius: var(--radius);
    transition: all 0.2s ease;
    border: 1px solid var(--border-color);
}

.document-item:hover {
    background-color: white;
    box-shadow: var(--shadow);
    transform: translateX(4px);
    border-color: var(--primary-light);
}

.doc-icon {
    font-size: 2.5rem;
    flex-shrink: 0;
    filter: grayscale(0.2);
}

.doc-info {
    flex-grow: 1;
}

.doc-info h3 {
    font-size: 0.9375rem;
    font-weight: 500;
    color: var(--text-primary);
    margin-bottom: 0.375rem;
    word-break: break-word;
}

.doc-date {
    font-size: 0.8125rem;
    color: var(--text-secondary);
}

.doc-actions {
    flex-shrink: 0;
}

/* Notifiche scadenza */
.expiring-alert {
    background: linear-gradient(135deg, var(--warning-light), #fef3c7);
    border: 1px solid var(--warning-color);
    border-radius: var(--radius-lg);
    padding: 2rem;
    margin-bottom: 2rem;
    text-align: center;
    box-shadow: var(--shadow);
    animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.01);
    }
}

.expiring-alert h3 {
    color: #92400e;
    margin-bottom: 0.5rem;
    font-size: 1.25rem;
}

.expiry-warning {
    color: var(--warning-color);
    font-size: 0.8125rem;
    font-weight: 600;
    margin-top: 0.5rem;
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.expiry-warning strong {
    background-color: var(--warning-light);
    padding: 0.125rem 0.5rem;
    border-radius: 9999px;
    font-size: 0.75rem;
}

.expiry-critical {
    color: var(--error-color);
    font-size: 0.8125rem;
    font-weight: 600;
    margin-top: 0.5rem;
}

/* Login temporaneo */
.temp-access-link {
    text-align: center;
    margin-top: 2.5rem;
    padding-top: 2rem;
    border-top: 1px solid var(--border-color);
}

.temp-access-link p {
    color: var(--text-secondary);
    font-size: 0.875rem;
}

.temp-access-link a {
    color: var(--primary-color);
    text-decoration: none;
    font-weight: 500;
    transition: all 0.2s;
}

.temp-access-link a:hover {
    text-decoration: underline;
    color: var(--primary-hover);
}

.form-info {
    background: linear-gradient(135deg, #eff6ff, #f3e8ff);
    padding: 1.25rem;
    border-radius: var(--radius);
    margin-bottom: 2rem;
    font-size: 0.875rem;
    color: var(--text-secondary);
    border-left: 4px solid var(--primary-color);
}

.form-footer {
    text-align: center;
    margin-top: 2rem;
}

.form-footer a {
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 0.875rem;
    transition: all 0.2s;
}

.form-footer a:hover {
    color: var(--primary-color);
}

/* Loading states */
.loading {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid var(--border-color);
    border-radius: 50%;
    border-top-color: var(--primary-color);
    animation: spin 0.8s linear infinite;
}

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

/* Sezione Trattamento Integrativo */
.treatment-section {
    background: var(--card-background);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 2rem;
    margin-bottom: 2rem;
    box-shadow: var(--shadow);
    text-align: center;
}

.treatment-section h2 {
    color: var(--primary-color);
    margin-bottom: 1rem;
    font-size: 1.5rem;
}

.treatment-section p {
    color: var(--text-secondary);
    margin-bottom: 1.5rem;
    font-size: 1rem;
    line-height: 1.6;
}

.treatment-section .btn {
    font-size: 1rem;
    padding: 0.75rem 1.5rem;
    min-width: 200px;
}

.treatment-section .btn i {
    font-size: 1.1rem;
}

/* Responsive */
@media (max-width: 768px) {
    .admin-container header {
        flex-direction: column;
        gap: 1rem;
        text-align: center;
        padding: 1.25rem 1rem;
    }
    
    /* Navbar responsive */
    .navbar {
        flex-direction: column;
        gap: 1rem;
        padding: 1rem;
    }
    
    .navbar-left,
    .navbar-center,
    .navbar-right {
        flex: none;
        width: 100%;
        justify-content: center;
    }
    
    .navbar-btn {
        min-width: 100%;
        padding: 0.875rem 1rem;
    }
    
    header h1 {
        font-size: 1.5rem;
    }
    
    .upload-sections {
        grid-template-columns: 1fr;
        gap: 1rem;
    }
    
    main {
        padding: 1.25rem;
    }
    
    .document-item {
        flex-direction: column;
        text-align: center;
        gap: 1rem;
    }
    
    .login-box {
        padding: 2rem 1.5rem;
    }
    
    .company-section {
        padding: 1.5rem;
    }
}

/* Focus styles for accessibility */
*:focus-visible {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
}

/* Custom scrollbar */
::-webkit-scrollbar {
    width: 10px;
    height: 10px;
}

::-webkit-scrollbar-track {
    background: var(--background-color);
}

::-webkit-scrollbar-thumb {
    background: var(--text-light);
    border-radius: 5px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-secondary);
}

/* Print styles */
@media print {
    header, .btn, .actions-container {
        display: none !important;
    }
    
    .document-item {
        break-inside: avoid;
    }
}