/* ============================================
   CSS Comune - Registro di Cassa Bar dell'Oratorio
   ============================================ */

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

html {
    font-size: 16px;
    -webkit-text-size-adjust: 100%;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background-color: #f5f5f5;
    min-height: 100vh;
    line-height: 1.5;
    color: #333;
}

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

/* ============================================
   HEADER
   ============================================ */
.header {
    background: linear-gradient(135deg, #4a6fa5 0%, #2c4a71 100%);
    color: white;
    padding: 20px 16px;
    text-align: center;
    margin: 0 -16px 20px -16px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.header .logo {
    max-width: 120px;
    height: auto;
    margin-bottom: 8px;
}

.header h1 {
    font-size: 1.5rem;
    font-weight: 600;
    margin-bottom: 4px;
}

.header .subtitle {
    font-size: 0.9rem;
    opacity: 0.9;
}

/* ============================================
   LOGIN PAGE
   ============================================ */
.login-container {
    max-width: 400px;
    margin: 40px auto;
    background: white;
    padding: 32px;
    border-radius: 16px;
    box-shadow: 0 4px 16px rgba(0,0,0,0.1);
}

.login-container .logo-section {
    text-align: center;
    margin-bottom: 24px;
}

.login-container .logo {
    max-width: 100px;
    height: auto;
    margin-bottom: 12px;
}

.login-container h2 {
    color: #4a6fa5;
    margin-bottom: 8px;
}

.login-container p {
    color: #666;
    font-size: 0.9rem;
    margin-bottom: 24px;
}

.login-form .form-group {
    margin-bottom: 20px;
}

.login-form label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: #444;
}

.login-form input[type="text"],
.login-form input[type="password"] {
    width: 100%;
    padding: 14px 12px;
    border: 2px solid #ddd;
    border-radius: 10px;
    font-size: 1rem;
    transition: border-color 0.2s;
}

.login-form input[type="text"]:focus,
.login-form input[type="password"]:focus {
    outline: none;
    border-color: #4CAF50;
}

.login-form button {
    width: 100%;
    padding: 16px;
    background-color: #4CAF50;
    color: white;
    border: none;
    border-radius: 10px;
    font-size: 1.1rem;
    font-weight: bold;
    cursor: pointer;
    transition: background-color 0.2s, transform 0.2s;
}

.login-form button:hover {
    background-color: #45a049;
}

.login-form button:active {
    transform: scale(0.98);
}

.login-form .forgot-password {
    text-align: center;
    margin-top: 16px;
}

.login-form .forgot-password a {
    color: #4a6fa5;
    text-decoration: none;
    font-size: 0.9rem;
}

.login-form .forgot-password a:hover {
    text-decoration: underline;
}

.error-message {
    background-color: #f8d7da;
    color: #721c24;
    padding: 12px;
    border-radius: 8px;
    margin-bottom: 20px;
    text-align: center;
}

/* ============================================
   INFO SECTION (sotto il login)
   ============================================ */
.info-section {
    max-width: 400px;
    margin: 20px auto;
    background: white;
    padding: 20px;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    text-align: center;
}

.info-section h3 {
    color: #4a6fa5;
    margin-bottom: 12px;
    font-size: 1.1rem;
}

.info-section p {
    color: #666;
    font-size: 0.9rem;
    margin-bottom: 8px;
}

.info-section .orari {
    font-size: 0.85rem;
    color: #555;
}

/* ============================================
   NAVIGATION
   ============================================ */
.navbar {
    background: white;
    padding: 12px 16px;
    border-radius: 12px;
    margin-bottom: 20px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.navbar .nav-links {
    display: flex;
    gap: 16px;
    list-style: none;
}

.navbar .nav-links a {
    color: #000103;
    text-decoration: none;
    padding: 8px 12px;
    border-radius: 6px;
    transition: background-color 0.2s;
    font-weight: 500;
}

.navbar .nav-links a:hover {
    background-color: #f0f8ff;
}

.navbar .nav-links a.active {
    background-color: #4a6fa5;
    color: white;
}

.navbar .user-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.navbar .user-name {
    font-weight: 500;
    color: #444;
}

.navbar .logout-btn {
    background: none;
    border: 1px solid #4a6fa5;
    color: #4a6fa5;
    padding: 8px 12px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.9rem;
    transition: all 0.2s;
}

.navbar .logout-btn:hover {
    background-color: #4a6fa5;
    color: white;
}

/* ============================================
   BUTTONS
   ============================================ */
.btn {
    display: inline-block;
    padding: 12px 20px;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    text-decoration: none;
    text-align: center;
}

.btn-primary {
    background-color: #4CAF50;
    color: white;
}

.btn-primary:hover {
    background-color: #45a049;
}

.btn-secondary {
    background-color: #f0f0f0;
    color: #666;
}

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

.btn-danger {
    background-color: #f44336;
    color: white;
}

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

.btn-info {
    background-color: #4a6fa5;
    color: white;
}

.btn-info:hover {
    background-color: #3a5a80;
}

.btn-warning {
    background-color: #ff9800;
    color: white;
}

.btn-warning:hover {
    background-color: #e68a00;
}

.btn-success {
    background-color: #4CAF50;
    color: white;
}

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

.btn-sm {
    padding: 8px 12px;
    font-size: 0.85rem;
}

.btn-lg {
    padding: 18px 24px;
    font-size: 1.1rem;
    border-radius: 12px;
}

.btn-block {
    display: block;
    width: 100%;
}

/* ============================================
   FORMS
   ============================================ */
.form-group {
    margin-bottom: 20px;
}

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

.form-group input[type="text"],
.form-group input[type="password"],
.form-group input[type="number"],
.form-group input[type="date"],
.form-group input[type="email"],
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 12px 14px;
    border: 2px solid #ddd;
    border-radius: 8px;
    font-size: 1rem;
    font-family: inherit;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.form-group input[type="text"]:focus,
.form-group input[type="password"]:focus,
.form-group input[type="number"]:focus,
.form-group input[type="date"]:focus,
.form-group input[type="email"]:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: #4CAF50;
    box-shadow: 0 0 0 3px rgba(76, 175, 80, 0.1);
}

.form-group input[type="number"] {
    -moz-appearance: textfield;
}

.form-group input[type="number"]::-webkit-outer-spin-button,
.form-group input[type="number"]::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.form-group select {
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml;charset=US-ASCII,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20width%3D%22292.4%22%20height%3D%22292.4%22%3E%3Cpath%20fill%3D%22%234a6fa5%22%20d%3D%22M287%2069.4a17.6%2017.6%200%200%200-13-5.4H18.4c-5%200-9.3%201.8-12.9%205.4A17.6%2017.6%200%200%200%200%2082.2c0%205%201.8%209.3%205.4%2012.9l128%20127.9c3.6%203.6%207.8%205.4%2012.8%205.4s9.2-1.8%2012.8-5.4L287%2095c3.5-3.5%205.4-7.8%205.4-12.8%200-4.7-1.7-8.9-5.2-12.4z%22%2F%3E%3C%2Fsvg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    background-size: 12px;
    padding-right: 36px;
}

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

.form-group .help-text {
    font-size: 0.8rem;
    color: #888;
    margin-top: 4px;
    font-style: italic;
}

.form-buttons {
    display: flex;
    gap: 12px;
    margin-top: 10px;
}

.form-buttons button {
    flex: 1;
}

/* Checkbox e Radio */
.checkbox-group,
.radio-group {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 12px;
}

.checkbox-group input,
.radio-group input {
    width: auto;
}

/* ============================================
   TABLES
   ============================================ */
.table-container {
    background-color: white;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    margin-bottom: 20px;
}

.table-header {
    background: linear-gradient(135deg, #4a6fa5 0%, #2c4a71 100%);
    color: white;
    padding: 16px;
    font-weight: 600;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.table-header h3 {
    margin: 0;
    font-size: 1.1rem;
}

.table-actions {
    display: flex;
    gap: 8px;
}

.table-wrapper {
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
}

th, td {
    padding: 12px 16px;
    text-align: left;
    border-bottom: 1px solid #eee;
}

th {
    background-color: #f8f9fa;
    color: #444;
    font-weight: 600;
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    white-space: nowrap;
}

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

tr:hover {
    background-color: #f8f9fa;
}

tr.selected {
    background-color: #e3f2fd;
}

.currency {
    text-align: right;
    font-family: 'Courier New', monospace;
    white-space: nowrap;
}

.date-cell {
    white-space: nowrap;
    font-weight: 500;
}

.status-badge {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 0.8rem;
    font-weight: 600;
    text-transform: uppercase;
}

.status-badge.active {
    background-color: #d4edda;
    color: #155724;
}

.status-badge.inactive {
    background-color: #f8d7da;
    color: #721c24;
}

.status-badge.deleted {
    background-color: #f5f5f5;
    color: #666;
    text-decoration: line-through;
}

.action-btn {
    background: none;
    border: none;
    color: #4a6fa5;
    padding: 8px;
    cursor: pointer;
    font-size: 1.1rem;
    opacity: 0.7;
    transition: opacity 0.2s, color 0.2s;
    border-radius: 4px;
}

.action-btn:hover {
    opacity: 1;
    color: #2c4a71;
    background-color: #f0f8ff;
}

.action-btn.danger:hover {
    color: #f44336;
    background-color: #ffe0e0;
}

.icon-btn {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    transition: background-color 0.2s;
}

.icon-btn:hover {
    background-color: #f0f8ff;
}

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

/* ============================================
   MODAL
   ============================================ */
.modal-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.7);
    z-index: 1000;
    align-items: center;
    justify-content: center;
    padding: 16px;
}

.modal-overlay.active {
    display: flex;
}

.modal {
    background-color: white;
    width: 100%;
    max-width: 500px;
    max-height: 90vh;
    border-radius: 16px;
    padding: 24px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.3);
    animation: slideIn 0.3s ease;
    overflow-y: auto;
}

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

.modal h2 {
    text-align: center;
    color: #333;
    margin-bottom: 24px;
    font-size: 1.4rem;
}

.modal h3 {
    color: #4a6fa5;
    margin-bottom: 16px;
    font-size: 1.1rem;
}

.modal-close {
    position: absolute;
    top: 16px;
    right: 16px;
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: #666;
    opacity: 0.7;
    transition: opacity 0.2s;
}

.modal-close:hover {
    opacity: 1;
    color: #333;
}

.modal-body {
    margin-bottom: 20px;
}

.modal-footer {
    display: flex;
    gap: 12px;
    margin-top: 20px;
}

.modal-footer button {
    flex: 1;
}

/* ============================================
   ALERTS E MESSAGGI
   ============================================ */
.alert {
    padding: 16px;
    border-radius: 8px;
    margin-bottom: 20px;
    text-align: center;
    animation: fadeIn 0.3s ease;
}

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

.alert-success {
    background-color: #d4edda;
    color: #155724;
}

.alert-error {
    background-color: #f8d7da;
    color: #721c24;
}

.alert-info {
    background-color: #d1ecf1;
    color: #0c5460;
}

.alert-warning {
    background-color: #fff3cd;
    color: #856404;
}

/* ============================================
   CARDS
   ============================================ */
.card {
    background: white;
    border-radius: 12px;
    padding: 20px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    margin-bottom: 20px;
}

.card h3 {
    color: #4a6fa5;
    margin-bottom: 16px;
    font-size: 1.1rem;
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 1px solid #eee;
}

.card-header h3 {
    margin: 0;
}

.card-body {
    padding: 16px 0;
}

.card-footer {
    padding-top: 12px;
    border-top: 1px solid #eee;
}

/* ============================================
   SECTIONS
   ============================================ */
.section {
    margin-bottom: 32px;
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}

.section-header h2 {
    color: #4a6fa5;
    font-size: 1.3rem;
}

.section-actions {
    display: flex;
    gap: 8px;
}

/* ============================================
   STATS CARDS
   ============================================ */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.stat-card {
    background: white;
    border-radius: 12px;
    padding: 20px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    text-align: center;
}

.stat-card .stat-label {
    color: #666;
    font-size: 0.9rem;
    margin-bottom: 8px;
}

.stat-card .stat-value {
    color: #4a6fa5;
    font-size: 1.8rem;
    font-weight: bold;
}

.stat-card .stat-currency {
    font-size: 1.5rem;
}

/* ============================================
   MAIN ADD BUTTON (per mobile)
   ============================================ */
.add-button-container {
    margin: 20px 0;
}

.add-button {
    width: 100%;
    padding: 24px 16px;
    background-color: #4CAF50;
    color: white;
    border: none;
    border-radius: 12px;
    font-size: 1.3rem;
    font-weight: bold;
    cursor: pointer;
    box-shadow: 0 4px 8px rgba(0,0,0,0.2);
    transition: transform 0.2s, background-color 0.2s;
}

.add-button:hover {
    background-color: #45a049;
}

.add-button:active {
    transform: scale(0.98);
}

/* ============================================
   FILTERS
   ============================================ */
.filters {
    background: white;
    padding: 16px;
    border-radius: 12px;
    margin-bottom: 20px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    align-items: center;
}

.filters .filter-group {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.filters .filter-group label {
    font-size: 0.85rem;
    font-weight: 500;
    color: #555;
}

.filters .filter-group select,
.filters .filter-group input {
    padding: 10px 12px;
    border: 2px solid #ddd;
    border-radius: 8px;
    font-size: 0.95rem;
}

/* ============================================
   PAGINATION
   ============================================ */
.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
    margin-top: 20px;
}

.pagination button,
.pagination a {
    min-width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid #ddd;
    background: white;
    color: #4a6fa5;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
    text-decoration: none;
    font-weight: 500;
}

.pagination button:hover,
.pagination a:hover {
    background-color: #4a6fa5;
    color: white;
    border-color: #4a6fa5;
}

.pagination button.active,
.pagination a.active {
    background-color: #4a6fa5;
    color: white;
    border-color: #4a6fa5;
}

.pagination button:disabled,
.pagination a.disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* ============================================
   EMPTY STATE
   ============================================ */
.empty-state {
    text-align: center;
    padding: 40px 20px;
    color: #888;
}

.empty-state i {
    font-size: 3rem;
    margin-bottom: 12px;
    opacity: 0.5;
}

.empty-state h3 {
    color: #666;
    margin-bottom: 8px;
}

.empty-state p {
    font-size: 0.9rem;
}

/* ============================================
   LOADING
   ============================================ */
.loading {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid rgba(74, 111, 165, 0.2);
    border-radius: 50%;
    border-top-color: #4a6fa5;
    animation: spin 1s ease-in-out infinite;
}

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

.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(255, 255, 255, 0.9);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 2000;
}

/* ============================================
   TOOLTIPS
   ============================================ */
[data-tooltip] {
    position: relative;
}

[data-tooltip]:hover::after {
    content: attr(data-tooltip);
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    background-color: #333;
    color: white;
    padding: 6px 10px;
    border-radius: 4px;
    font-size: 0.8rem;
    white-space: nowrap;
    z-index: 100;
    margin-top: 8px;
}

[data-tooltip]:hover::before {
    content: '';
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    border: 6px solid transparent;
    border-top-color: #333;
    margin-top: 0px;
}

/* ============================================
   RESPONSIVE
   ============================================ */
@media (max-width: 768px) {
    .container {
        padding: 12px;
    }

    .header {
        padding: 16px 12px;
        margin: 0 -12px 16px -12px;
    }

    .header h1 {
        font-size: 1.3rem;
    }

    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .modal {
        max-height: 95vh;
        padding: 20px;
    }

    .modal h2 {
        font-size: 1.3rem;
    }

    .navbar {
        flex-direction: column;
        gap: 12px;
        padding: 16px;
    }

    .navbar .nav-links {
        flex-direction: column;
        gap: 8px;
    }

    .navbar .user-info {
        flex-direction: column;
        gap: 8px;
    }

    .form-buttons {
        flex-direction: column;
    }

    .section-header {
        flex-direction: column;
        gap: 12px;
        align-items: flex-start;
    }

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

    th, td {
        padding: 10px 8px;
        font-size: 0.9rem;
    }

    .stat-card .stat-value {
        font-size: 1.5rem;
    }
    
    /* Gestione tabs */
    .tabs {
        overflow-x: auto;
    }
    
    .tabs a {
        padding: 10px 14px;
        font-size: 0.9rem;
    }
    
    .hamburger-btn {
        display: block !important;
    }
}

@media (max-width: 480px) {
    .stats-grid {
        grid-template-columns: 1fr;
    }

    .add-button {
        padding: 20px 12px;
        font-size: 1.2rem;
    }

    .table-container {
        border-radius: 8px;
    }

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

    .login-container {
        margin: 20px 12px;
        padding: 24px 16px;
    }

    .info-section {
        margin: 16px 12px;
        padding: 16px;
    }
}

/* ============================================
   PRINT
   ============================================ */
@media print {
    body {
        background: white;
    }

    .container {
        max-width: none;
        padding: 0;
    }

    .header,
    .navbar,
    .add-button-container,
    .modal-overlay,
    .filters,
    .pagination {
        display: none !important;
    }

    .table-container,
    .card,
    .stat-card {
        box-shadow: none;
        border: 1px solid #ddd;
    }

    .btn {
        display: none;
    }
}

/* ============================================
   Touch Feedback
   ============================================ */
.touch-highlight {
    -webkit-tap-highlight-color: transparent;
}

button:focus,
input:focus,
select:focus,
textarea:focus {
    outline: 2px solid #4CAF50;
    outline-offset: 2px;
}

/* ============================================
   Utility Classes
   ============================================ */
.text-center {
    text-align: center;
}

.text-right {
    text-align: right;
}

.text-left {
    text-align: left;
}

.mt-1 { margin-top: 8px; }
.mt-2 { margin-top: 16px; }
.mt-3 { margin-top: 24px; }
.mt-4 { margin-top: 32px; }

.mb-1 { margin-bottom: 8px; }
.mb-2 { margin-bottom: 16px; }
.mb-3 { margin-bottom: 24px; }
.mb-4 { margin-bottom: 32px; }

.p-1 { padding: 8px; }
.p-2 { padding: 16px; }
.p-3 { padding: 24px; }

.flex {
    display: flex;
}

.flex-wrap {
    flex-wrap: wrap;
}

.justify-between {
    justify-content: space-between;
}

.justify-center {
    justify-content: center;
}

.align-center {
    align-items: center;
}

.gap-1 { gap: 8px; }
.gap-2 { gap: 12px; }
.gap-3 { gap: 16px; }

.bold {
    font-weight: bold;
}

.muted {
    color: #888;
}

.success {
    color: #4CAF50;
}

.danger {
    color: #f44336;
}

.warning {
    color: #ff9800;
}

.info {
    color: #4a6fa5;
}

.hidden {
    display: none !important;
}

.visible {
    display: block !important;
}
