/* Component styles - forms, buttons, and interactive elements */
.form-group {
    margin-bottom: 1rem;
}

input {
    width: 100%;
    padding: 12px;
    border: 2px solid #ddd;
    border-radius: 5px;
    font-size: 16px;
    box-sizing: border-box;
}

input:focus {
    border-color: #667eea;
    outline: none;
}

button {
    width: 100%;
    padding: 12px;
    background: #667eea;
    color: white;
    border: none;
    border-radius: 5px;
    font-size: 16px;
    cursor: pointer;
    transition: background 0.3s;
}

button:hover {
    background: #5a6fd8;
}

button:disabled {
    background: #ccc;
    cursor: not-allowed;
}

.logout-btn {
    background: #dc3545;
    margin-top: 1rem;
}

.logout-btn:hover {
    background: #c82333;
}

.dashboard-btn {
    background: #28a745;
}

.dashboard-btn:hover {
    background: #218838;
}

.back-btn {
    background: #6c757d;
    margin-top: 2rem;
}

.back-btn:hover {
    background: #5a6268;
}

.message {
    margin: 1rem 0;
    padding: 10px;
    border-radius: 5px;
    text-align: center;
}

.success {
    background: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}

.error {
    background: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}

/* Revenue section styles */
.revenue-content {
    margin-top: 1rem;
}

.revenue-header {
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 1rem;
}

.revenue-header h4 {
    margin: 0 1rem;
    color: #333;
    font-size: 1.1rem;
    font-weight: bold;
    flex: 1;
    text-align: center;
}

.positive {
    color: #28a745;
}

.negative {
    color: #dc3545;
}

.no-revenue {
    color: #dc3545;
    font-weight: bold;
}

.detail-btn {
    background: #17a2b8;
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    margin-bottom: 1rem;
    transition: background 0.3s;
}

.detail-btn:hover {
    background: #138496;
}

/* Modal styles */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.modal-content {
    background: white;
    border-radius: 8px;
    width: 90%;
    max-width: 800px;
    max-height: 80vh;
    overflow: hidden;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.3);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.5rem;
    border-bottom: 1px solid #ddd;
    background: #f8f9fa;
}

/* Mobile modal header centering */
@media (max-width: 768px) {
    .modal-header {
        position: relative !important;
        display: flex !important;
        align-items: center !important;
        padding: 1rem 3rem !important; /* Override general padding */
        justify-content: center !important;
    }

    .modal-header h2 {
        flex: 1 !important;
        text-align: left !important;
        margin: 0 !important;
        padding-left: 1.5rem !important;
        font-size: 1rem !important;
        line-height: 1.2 !important;
        word-wrap: break-word !important;
        z-index: 1 !important;
    }

    .modal-header .nav-arrow:first-child {
        position: absolute !important;
        left: 0.5rem !important;
        top: 50% !important;
        transform: translateY(-50%) !important;
        z-index: 2 !important;
    }

    .modal-header .nav-arrow:nth-child(3) {
        position: absolute !important;
        right: 3rem !important; /* Position before close button */
        top: 50% !important;
        transform: translateY(-50%) !important;
        z-index: 2 !important;
    }

    .modal-close {
        position: absolute !important;
        right: 0.5rem !important;
        top: 50% !important;
        transform: translateY(-50%) !important;
        z-index: 3 !important;
    }
}

.modal-header h2 {
    margin: 0;
    color: #333;
}

.modal-close {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: #666;
    padding: 0;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-close:hover {
    color: #333;
}

.modal-body {
    padding: 1.5rem;
    overflow-y: auto;
    max-height: calc(80vh - 80px);
}

.detailed-revenue-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 1rem;
}

.detailed-revenue-table th,
.detailed-revenue-table td {
    padding: 8px 12px;
    text-align: left;
    border-bottom: 1px solid #ddd;
}

.detailed-revenue-table th {
    background-color: #f8f9fa;
    font-weight: bold;
    color: #333;
}

.detailed-revenue-table tbody tr:hover {
    background-color: #f5f5f5;
}

.detailed-revenue-table .month-even {
    background-color: #f0f8ff;
}

.detailed-revenue-table .month-odd {
    background-color: #e6f3ff;
}

.detailed-revenue-table .month-even:hover {
    background-color: #e0f0ff;
}

.detailed-revenue-table .month-odd:hover {
    background-color: #d9edff;
}

.nav-arrow {
    background: #667eea;
    color: white;
    border: none;
    border-radius: 50%;
    width: 30px;
    height: 30px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    font-weight: bold;
    transition: background 0.3s;
}

.nav-arrow:hover:not(:disabled) {
    background: #5a6fd8;
}

.nav-arrow:disabled {
    background: #ccc;
    cursor: not-allowed;
}

.revenue-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 1rem;
}

.revenue-table th,
.revenue-table td {
    padding: 8px 12px;
    text-align: left;
    border-bottom: 1px solid #ddd;
}

.revenue-table th {
    background-color: #f8f9fa;
    font-weight: bold;
    color: #333;
}

.revenue-table tbody tr:hover {
    background-color: #f5f5f5;
}

.total-row {
    background-color: #e9ecef;
    font-weight: bold;
}

.total-row td {
    border-top: 2px solid #333;
}

/* Form styles for add entry modal */
.form-group {
    margin-bottom: 1.5rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: bold;
    color: #333;
}

.form-group input,
.form-group select {
    width: 100%;
    padding: 10px;
    border: 2px solid #ddd;
    border-radius: 4px;
    font-size: 16px;
    box-sizing: border-box;
}

.form-group input:focus,
.form-group select:focus {
    border-color: #667eea;
    outline: none;
}

.form-actions {
    display: flex;
    gap: 1rem;
    justify-content: flex-end;
    margin-top: 2rem;
}

.submit-btn {
    background: #28a745;
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 16px;
    font-weight: bold;
}

.submit-btn:hover:not(:disabled) {
    background: #218838;
}

.cancel-btn {
    background: #6c757d;
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 16px;
}

.cancel-btn:hover {
    background: #5a6268;
}

.revenue-actions {
    display: flex;
    gap: 1rem;
    margin-bottom: 1rem;
    flex-wrap: wrap;
}

.add-entry-btn {
    background: #17a2b8;
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    transition: background 0.3s;
}

.add-entry-btn:hover {
    background: #138496;
}

/* Add-ons list styles */
.add-ons-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    max-height: 200px;
    overflow-y: auto;
    padding: 0.5rem;
    border: 1px solid #ddd;
    border-radius: 4px;
    background: #f9f9f9;
}

.add-on-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.25rem;
    background: white;
    border-radius: 4px;
    border: 1px solid #e0e0e0;
    transition: background 0.3s;
}

.add-on-item:hover {
    background: #f5f5f5;
}

.add-on-item input[type="checkbox"] {
    width: auto;
    margin: 0;
    cursor: pointer;
}

.add-on-item label {
    cursor: pointer;
    flex: 1;
    margin: 0;
    font-weight: normal;
    font-size: 14px;
    color: #555;
}

.add-on-item input[type="checkbox"]:checked + label {
    color: #28a745;
    font-weight: bold;
}

/* Action buttons for edit/delete */
.action-btn {
    width: 36px;
    height: 36px;
    padding: 0;
    margin: 0 2px;
    border: 1px solid rgba(0,0,0,0.1);
    border-radius: 6px;
    cursor: pointer;
    font-size: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s;
    box-sizing: border-box;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.edit-btn {
    background: #ffc107;
    color: #212529;
}

.edit-btn:hover {
    background: #e0a800;
}

.delete-btn {
    background: #dc3545;
    color: white;
}

.delete-btn:hover {
    background: #c82333;
}

/* Year navigation for mobile */
.year-input-container {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.year-nav {
    background: #667eea;
    color: white;
    border: 2px solid #667eea;
    border-radius: 50%;
    width: 42px;
    height: 42px;
    min-width: 42px;
    min-height: 42px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    font-weight: bold;
    transition: all 0.3s;
    flex-shrink: 0;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    box-sizing: border-box;
}

.year-nav:hover:not(:disabled) {
    background: #5a6fd8;
    border-color: #5a6fd8;
    transform: scale(1.05);
    box-shadow: 0 4px 8px rgba(0,0,0,0.15);
}

.year-nav:active:not(:disabled) {
    transform: scale(0.95);
}

.year-nav:disabled {
    background: #ccc;
    border-color: #ccc;
    cursor: not-allowed;
    box-shadow: none;
}

.year-input-container input {
    flex: 1;
    text-align: center;
    font-size: 16px;
    font-weight: bold;
    border-radius: 4px;
}

/* Toggle switch styles */
.toggle-group {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-top: 0.5rem;
}

.toggle-switch {
    position: relative;
    display: inline-block;
    width: 60px;
    height: 34px;
}

.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #ccc;
    transition: .4s;
    border-radius: 34px;
}

.slider:before {
    position: absolute;
    content: "";
    height: 26px;
    width: 26px;
    left: 4px;
    bottom: 4px;
    background-color: white;
    transition: .4s;
    border-radius: 50%;
}

input:checked + .slider {
    background-color: #667eea;
}

input:checked + .slider:before {
    transform: translateX(26px);
}

/* Hide year navigation on desktop, show on mobile */
@media (min-width: 769px) {
    .year-nav {
        display: none;
    }

    .year-input-container {
        justify-content: center;
    }

    .year-input-container input {
        text-align: left;
    }
}

/* Responsive design */
@media (max-width: 768px) {
    .container {
        width: 95%;
        padding: 1rem;
    }

    .dashboard-grid {
        grid-template-columns: 1fr;
        gap: 1rem;
    }

    .dashboard-card {
        padding: 1rem;
    }

    .revenue-header {
        flex-direction: row;
        gap: 0.5rem;
        flex-wrap: wrap;
        justify-content: center;
    }

    .revenue-header h4 {
        margin: 0;
        font-size: 1rem;
    }

    .nav-arrow {
        width: 35px;
        height: 35px;
        font-size: 20px;
    }

    .modal-content {
        width: 95%;
        margin: 1rem;
        max-height: 90vh;
    }

    .modal-body {
        padding: 1rem;
    }

    /* Optimize tables for mobile without horizontal scrolling */
    .revenue-table,
    .detailed-revenue-table {
        font-size: 13px;
        width: 100%;
        table-layout: fixed;
    }

    .revenue-table th,
    .revenue-table td,
    .detailed-revenue-table th,
    .detailed-revenue-table td {
        padding: 4px 6px;
        word-wrap: break-word;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    /* Specific column widths for main revenue table */
    .revenue-table th:nth-child(1),
    .revenue-table td:nth-child(1) {
        width: 25%;
    }

    .revenue-table th:nth-child(2),
    .revenue-table td:nth-child(2) {
        width: 40%;
    }

    .revenue-table th:nth-child(3),
    .revenue-table td:nth-child(3) {
        width: 35%;
    }

    /* Specific column widths for detailed revenue table */
    .detailed-revenue-table th:nth-child(1),
    .detailed-revenue-table td:nth-child(1) {
        width: 18%;
        white-space: nowrap;
        overflow: visible;
    }

    .detailed-revenue-table th:nth-child(2),
    .detailed-revenue-table td:nth-child(2) {
        width: 42%;
    }

    .detailed-revenue-table th:nth-child(3),
    .detailed-revenue-table td:nth-child(3) {
        width: 25%;
    }

    .detailed-revenue-table th:nth-child(4),
    .detailed-revenue-table td:nth-child(4) {
        width: 15%;
        text-align: center;
    }

    .detail-btn {
        width: 100%;
        padding: 12px;
        font-size: 16px; /* Prevent zoom on iOS */
    }

    .nav-arrow {
        min-width: 44px; /* iOS touch target minimum */
        min-height: 44px;
    }

    button {
        min-height: 44px; /* Ensure touch targets are large enough */
        font-size: 16px;
    }
}

@media (max-width: 480px) {
    .container {
        width: 100%;
        padding: 0.5rem;
    }

    .modal-content {
        width: 100%;
        margin: 0.5rem;
        max-height: 95vh;
    }

    .modal-header h2 {
        font-size: 1.2rem;
    }

    .revenue-table th,
    .revenue-table td,
    .detailed-revenue-table th,
    .detailed-revenue-table td {
        padding: 4px 6px;
        font-size: 12px;
    }
}
