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

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    line-height: 1.6;
    color: #333;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
    background: white;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
    border-radius: 10px;
    margin-top: 20px;
    margin-bottom: 20px;
}

/* Header */
header {
    text-align: center;
    margin-bottom: 40px;
    padding-bottom: 20px;
    border-bottom: 3px solid #667eea;
}

header h1 {
    color: #667eea;
    font-size: 2.5rem;
    margin-bottom: 10px;
    font-weight: 700;
}

header p {
    color: #666;
    font-size: 1.1rem;
}

.settings-bar {
    text-align: center;
    margin-top: 15px;
    padding: 15px;
    background: rgba(255, 255, 255, 0.5);
    border-radius: 8px;
}

.settings-link {
    display: inline-block;
    margin: 0 15px;
    padding: 8px 16px;
    background: #f8f9ff;
    color: #667eea;
    text-decoration: none;
    border-radius: 20px;
    font-size: 0.9rem;
    font-weight: 500;
    transition: all 0.3s ease;
    border: 1px solid #e1e5e9;
}

.settings-link:hover {
    background: #667eea;
    color: white;
    transform: translateY(-1px);
}

/* Form styles */
.invoice-form {
    display: flex;
    flex-direction: column;
    gap: 30px;
}

.section {
    background: #f8f9ff;
    padding: 30px;
    border-radius: 10px;
    border-left: 4px solid #667eea;
}

.section h2 {
    color: #333;
    margin-bottom: 20px;
    font-size: 1.5rem;
    font-weight: 600;
}

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

.form-group {
    display: flex;
    flex-direction: column;
    margin-bottom: 20px;
}

.form-group label {
    font-weight: 600;
    margin-bottom: 8px;
    color: #444;
    font-size: 0.95rem;
}

.form-group input,
.form-group select,
.form-group textarea {
    padding: 12px 15px;
    border: 2px solid #e1e5e9;
    border-radius: 8px;
    font-size: 1rem;
    transition: all 0.3s ease;
    background: white;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.form-group textarea {
    min-height: 100px;
    resize: vertical;
    font-family: inherit;
}

/* Required field indicators */
.form-group label[for*="Name"]::after,
.form-group label[for*="FiscalCode"]::after,
.form-group label[for*="Address"]::after,
.form-group label[for*="City"]::after,
.form-group label[for*="Zip"]::after,
.form-group label[for*="Province"]::after,
.form-group label[for*="serviceDescription"]::after,
.form-group label[for*="serviceAmount"]::after,
.form-group label[for*="invoiceDate"]::after {
    content: " *";
    color: #e74c3c;
    font-weight: bold;
}

/* Buttons */
.form-actions {
    display: flex;
    gap: 15px;
    justify-content: center;
    flex-wrap: wrap;
    margin-top: 30px;
}

.btn {
    padding: 15px 30px;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    text-decoration: none;
    display: inline-block;
    text-align: center;
    min-width: 150px;
}

.btn-primary {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(102, 126, 234, 0.3);
}

.btn-primary:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

.btn-secondary {
    background: #6c757d;
    color: white;
}

.btn-secondary:hover {
    background: #5a6268;
    transform: translateY(-2px);
}

/* Authentication section */
.auth-section {
    background: #fff3cd;
    border: 1px solid #ffeaa7;
    padding: 30px;
    border-radius: 10px;
    margin-bottom: 30px;
    text-align: center;
}

.auth-section h2 {
    color: #856404;
    margin-bottom: 15px;
}

.auth-section p {
    color: #856404;
    margin-bottom: 20px;
}

.auth-section small a {
    color: #667eea;
    text-decoration: none;
}

.auth-section small a:hover {
    text-decoration: underline;
}

/* Preview section */
.preview-section,
.result-section {
    background: #f8f9ff;
    padding: 30px;
    border-radius: 10px;
    margin-top: 30px;
    border-left: 4px solid #28a745;
}

.preview-section h2,
.result-section h2 {
    color: #28a745;
    margin-bottom: 20px;
    font-size: 1.5rem;
}

.invoice-preview {
    background: white;
    padding: 30px;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

.invoice-preview h3 {
    color: #333;
    text-align: center;
    margin-bottom: 30px;
    font-size: 1.8rem;
    border-bottom: 2px solid #667eea;
    padding-bottom: 10px;
}

.invoice-preview .preview-section {
    background: #f8f9ff;
    margin: 20px 0;
    padding: 20px;
    border-radius: 5px;
    border-left: 3px solid #667eea;
}

.invoice-preview h4 {
    color: #667eea;
    margin-bottom: 15px;
    font-size: 1.2rem;
}

.amounts {
    background: white;
    padding: 15px;
    border-radius: 5px;
    margin-top: 15px;
}

.amounts p:last-child {
    font-size: 1.2rem;
    color: #28a745;
    border-top: 2px solid #e1e5e9;
    padding-top: 10px;
    margin-top: 10px;
}

/* Success and error messages */
.success-message {
    background: #d4edda;
    border: 1px solid #c3e6cb;
    color: #155724;
    padding: 30px;
    border-radius: 10px;
    text-align: center;
}

.success-message h3 {
    font-size: 1.5rem;
    margin-bottom: 20px;
}

.success-message a {
    color: #667eea;
    text-decoration: none;
    font-weight: 600;
}

.success-message a:hover {
    text-decoration: underline;
}

.email-info {
    background: #cce5ff;
    padding: 10px;
    border-radius: 5px;
    color: #0056b3;
    font-weight: 500;
    margin: 15px 0;
}

/* GDPR Banner */
.gdpr-banner {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 20px;
    border-radius: 10px;
    margin: 20px 0;
    border: 2px solid #fff;
}

.gdpr-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 20px;
}

.gdpr-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.gdpr-actions .btn {
    min-width: auto;
    padding: 10px 20px;
    font-size: 0.9rem;
}

@media (max-width: 768px) {
    .gdpr-content {
        flex-direction: column;
        text-align: center;
        gap: 15px;
    }
    
    .gdpr-actions {
        justify-content: center;
    }
}

/* OAuth Setup Styles */
.highlight-box {
    background: #e8f4fd;
    padding: 20px;
    border-radius: 8px;
    border: 1px solid #b6d7ff;
    margin: 20px 0;
}

.highlight-box h3 {
    color: #1976d2;
    margin-bottom: 15px;
}

.highlight-box ul {
    margin: 15px 0;
    padding-left: 20px;
}

.highlight-box li {
    margin: 8px 0;
}

.info-message {
    background: #e3f2fd;
    border: 1px solid #2196f3;
    color: #1565c0;
    padding: 15px;
    border-radius: 8px;
    margin: 15px 0;
}

.error-message {
    background: #f8d7da;
    border: 1px solid #f5c6cb;
    color: #721c24;
    padding: 30px;
    border-radius: 10px;
    text-align: center;
}

.error-message h3 {
    font-size: 1.5rem;
    margin-bottom: 20px;
}

.error-message pre {
    background: #fff;
    padding: 15px;
    border-radius: 5px;
    margin: 15px 0;
    text-align: left;
    overflow-x: auto;
    font-size: 0.9rem;
}

/* Responsive design */
@media (max-width: 768px) {
    .container {
        margin: 10px;
        padding: 15px;
    }

    header h1 {
        font-size: 2rem;
    }

    .section {
        padding: 20px;
    }

    .form-row {
        grid-template-columns: 1fr;
        gap: 15px;
    }

    .form-actions {
        flex-direction: column;
        align-items: stretch;
    }

    .btn {
        padding: 12px 20px;
        min-width: auto;
    }

    .invoice-preview {
        padding: 20px;
    }

    .invoice-preview h3 {
        font-size: 1.5rem;
    }
}

@media (max-width: 480px) {
    .container {
        margin: 5px;
        padding: 10px;
    }

    header h1 {
        font-size: 1.8rem;
    }

    .section {
        padding: 15px;
    }

    .form-group input,
    .form-group select,
    .form-group textarea {
        padding: 10px;
    }

    .btn {
        padding: 10px 15px;
        font-size: 0.9rem;
    }

    .invoice-preview {
        padding: 15px;
    }

    .invoice-preview .preview-section {
        padding: 15px;
        margin: 15px 0;
    }
}

/* Loading states */
.loading {
    opacity: 0.6;
    pointer-events: none;
}

.loading::after {
    content: "";
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid #f3f3f3;
    border-top: 3px solid #667eea;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-left: 10px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Print styles */
@media print {
    body {
        background: white;
    }
    
    .container {
        box-shadow: none;
        margin: 0;
        padding: 0;
    }
    
    .form-actions,
    .auth-section,
    .btn {
        display: none;
    }
    
    .invoice-preview {
        box-shadow: none;
    }
}