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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background-color: #f5f7fa;
    color: #2d3748;
    line-height: 1.6;
}

.app-container {
    max-width: 1400px;
    margin: 0 auto;
    background-color: white;
    min-height: 100vh;
    box-shadow: 0 0 20px rgba(0,0,0,0.1);
}

/* Header */
header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 1.5rem 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}

header h1 {
    font-size: 1.8rem;
    font-weight: 600;
}

.header-actions {
    display: flex;
    gap: 0.75rem;
    position: relative;
}

/* Desktop Menu */
.desktop-menu {
    display: flex;
    gap: 0.75rem;
    align-items: center;
}

/* Mobile Menu */
.mobile-menu {
    display: none;
    position: relative;
}

.mobile-dropdown {
    position: absolute;
    top: 100%;
    right: 0;
    background: white;
    border-radius: 8px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.3);
    min-width: 200px;
    z-index: 1000;
    overflow: hidden;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    transition: all 0.3s ease;
}

.mobile-dropdown.active {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.dropdown-item {
    width: 100%;
    padding: 1rem 1.5rem;
    border: none;
    background: none;
    text-align: left;
    color: #374151;
    cursor: pointer;
    transition: background-color 0.2s ease;
    display: flex;
    align-items: center;
    font-size: 0.875rem;
}

.dropdown-item:hover {
    background-color: #f9fafb;
}

.dropdown-item:not(:last-child) {
    border-bottom: 1px solid #f3f4f6;
}

/* Buttons */
.btn {
    padding: 0.5rem 1rem;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 500;
    transition: all 0.2s ease;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.875rem;
}

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

.btn-primary:hover {
    background-color: #4338ca;
    transform: translateY(-1px);
}

.btn-secondary {
    background-color: rgba(255,255,255,0.2);
    color: white;
    border: 1px solid rgba(255,255,255,0.3);
}

.btn-secondary:hover {
    background-color: rgba(255,255,255,0.3);
}

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

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

.btn-small {
    padding: 0.25rem 0.5rem;
    font-size: 0.75rem;
}

.btn-icon {
    padding: 0.5rem;
    background-color: rgba(255,255,255,0.2);
    color: white;
    border: 1px solid rgba(255,255,255,0.3);
}

.btn-icon:hover {
    background-color: rgba(255,255,255,0.3);
}

.btn-icon svg {
    width: 20px;
    height: 20px;
}

/* Main Views */
.main-view, .settings-view {
    display: block;
}

.settings-view {
    height: calc(100vh - 80px);
}

/* Settings Header */
.settings-header {
    background-color: #f8fafc;
    border-bottom: 1px solid #e2e8f0;
    padding: 1.5rem 2rem;
    display: flex;
    align-items: center;
    gap: 1rem;
}

.settings-header h1 {
    font-size: 1.5rem;
    font-weight: 600;
    color: #374151;
}

/* Settings Container */
.settings-container {
    display: flex;
    height: calc(100vh - 140px);
}

/* Settings Sidebar */
.settings-sidebar {
    width: 280px;
    background-color: #f8fafc;
    border-right: 1px solid #e2e8f0;
    padding: 1.5rem 0;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.settings-nav-btn {
    background: none;
    border: none;
    padding: 1rem 1.5rem;
    text-align: left;
    cursor: pointer;
    color: #64748b;
    font-weight: 500;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    border-left: 3px solid transparent;
}

.settings-nav-btn:hover {
    background-color: #f1f5f9;
    color: #4f46e5;
}

.settings-nav-btn.active {
    background-color: white;
    color: #4f46e5;
    border-left-color: #4f46e5;
}

.settings-nav-btn svg {
    width: 20px;
    height: 20px;
    opacity: 0.7;
}

.settings-nav-btn.active svg {
    opacity: 1;
}

/* Settings Content */
.settings-content {
    flex: 1;
    padding: 2rem;
    overflow-y: auto;
}

.settings-tab-content {
    display: none;
}

.settings-tab-content.active {
    display: block;
    animation: fadeIn 0.3s ease;
}

/* Navigation */
.tab-navigation {
    background-color: #f8fafc;
    border-bottom: 1px solid #e2e8f0;
    padding: 0 2rem;
    display: flex;
    overflow-x: auto;
}

.tab-btn {
    background: none;
    border: none;
    padding: 1rem 1.5rem;
    cursor: pointer;
    font-weight: 500;
    color: #64748b;
    border-bottom: 3px solid transparent;
    transition: all 0.2s ease;
    white-space: nowrap;
}

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

.tab-btn.active {
    color: #4f46e5;
    border-bottom-color: #4f46e5;
    background-color: white;
}

/* Content */
.content {
    padding: 2rem;
}

.tab-content {
    display: none;
    animation: fadeIn 0.3s ease;
}

.tab-content.active {
    display: block;
}

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

/* Forms */
.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.form-group {
    display: flex;
    flex-direction: column;
}

.form-group.full-width {
    grid-column: 1 / -1;
}

.form-control {
    padding: 0.75rem;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    font-size: 0.875rem;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.form-control:focus {
    outline: none;
    border-color: #4f46e5;
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

label {
    margin-bottom: 0.5rem;
    font-weight: 500;
    color: #374151;
}

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

small {
    margin-top: 0.25rem;
    color: #6b7280;
    font-size: 0.75rem;
}

/* Cost Summary Cards */
.cost-summary {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.summary-card {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 1.5rem;
    border-radius: 12px;
    text-align: center;
    box-shadow: 0 4px 15px rgba(0,0,0,0.1);
}

.summary-card h3 {
    font-size: 0.875rem;
    font-weight: 500;
    opacity: 0.9;
    margin-bottom: 0.5rem;
}

.cost-amount {
    font-size: 2rem;
    font-weight: 700;
}

/* Tables */
.table-container {
    background: white;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    overflow-x: auto;
}

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

.data-table th {
    background-color: #f8fafc;
    padding: 1rem;
    text-align: left;
    font-weight: 600;
    color: #374151;
    border-bottom: 1px solid #e5e7eb;
    white-space: nowrap;
}

.data-table td {
    padding: 1rem;
    border-bottom: 1px solid #f3f4f6;
}

.data-table tbody tr:hover {
    background-color: #f9fafb;
}

.data-table input {
    width: 100%;
    padding: 0.5rem;
    border: 1px solid #d1d5db;
    border-radius: 4px;
    font-size: 0.875rem;
}

.data-table select {
    width: 100%;
    padding: 0.5rem;
    border: 1px solid #d1d5db;
    border-radius: 4px;
    font-size: 0.875rem;
    background-color: white;
}

/* Section Actions */
.section-actions {
    margin-bottom: 1.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

/* Forecast Section */
.forecast-section {
    margin-top: 2rem;
}

.forecast-section h3 {
    margin-bottom: 1rem;
    color: #374151;
}

/* Risk Summary */
.risk-summary {
    background-color: #f8fafc;
    padding: 1.5rem;
    border-radius: 8px;
    margin-bottom: 2rem;
    display: flex;
    align-items: center;
    gap: 2rem;
}

.cost-display {
    font-size: 1.1rem;
    color: #059669;
}

/* Rate Cards */
.rate-cards-container {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(500px, 1fr));
    gap: 2rem;
}

.rate-card-section {
    background-color: #f8fafc;
    padding: 1.5rem;
    border-radius: 8px;
}

.rate-card-section h3 {
    margin-bottom: 1rem;
    color: #374151;
}

/* Summary */
.summary-overview {
    max-width: 1200px;
    margin: 0 auto;
}

.summary-columns {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 2rem;
    margin-bottom: 2rem;
}

.project-info-summary {
    background: #f8fafc;
    padding: 1.5rem;
    border-radius: 8px;
}

.summary-section {
    background: white;
    border-radius: 12px;
    padding: 2rem;
    box-shadow: 0 4px 15px rgba(0,0,0,0.05);
}

.info-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 0.75rem;
    margin-bottom: 1.5rem;
}

.info-item {
    display: grid;
    grid-template-columns: 140px 1fr;
    align-items: start;
    gap: 1rem;
}

.info-item.full-width {
    grid-column: 1 / -1;
    grid-template-columns: 140px 1fr;
}

.info-label {
    font-weight: 600;
    color: #374151;
}

.info-value {
    color: #6b7280;
}

.scope-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1rem;
}

.scope-item {
    text-align: center;
    padding: 1rem;
    background: white;
    border-radius: 6px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.scope-number {
    display: block;
    font-size: 1.5rem;
    font-weight: 700;
    color: #4f46e5;
}

.scope-label {
    font-size: 0.75rem;
    color: #6b7280;
    text-transform: uppercase;
    font-weight: 500;
}

.cost-breakdown {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.breakdown-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 0;
    border-bottom: 1px solid #f3f4f6;
}

.breakdown-item:last-child {
    border-bottom: none;
}

.breakdown-item.subtotal {
    font-weight: 600;
    border-top: 2px solid #e5e7eb;
    margin-top: 1rem;
    padding-top: 1rem;
}

.breakdown-item.total {
    font-weight: 700;
    font-size: 1.1rem;
    color: #059669;
    border-top: 2px solid #059669;
    margin-top: 1rem;
    padding-top: 1rem;
}

.cost {
    font-weight: 600;
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.5);
    animation: fadeIn 0.3s ease;
}

.modal-content {
    background-color: white;
    margin: 5% auto;
    padding: 2rem;
    border-radius: 12px;
    width: 90%;
    max-width: 600px;
    max-height: 80vh;
    overflow-y: auto;
    position: relative;
    box-shadow: 0 10px 30px rgba(0,0,0,0.3);
}

.close {
    position: absolute;
    top: 1rem;
    right: 1.5rem;
    font-size: 2rem;
    font-weight: bold;
    cursor: pointer;
    color: #6b7280;
}

.close:hover {
    color: #374151;
}

#modalTitle {
    margin-bottom: 1.5rem;
    color: #374151;
}

.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 1rem;
    margin-top: 1.5rem;
    padding-top: 1.5rem;
    border-top: 1px solid #e5e7eb;
}

/* Category badges */
.category-badge {
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
}

.category-internal {
    background-color: #dcfce7;
    color: #166534;
}

.category-external {
    background-color: #dbeafe;
    color: #1e40af;
}

/* Utility Classes */
.text-center { text-align: center; }
.text-right { text-align: right; }
.mb-1 { margin-bottom: 0.25rem; }
.mb-2 { margin-bottom: 0.5rem; }
.mb-3 { margin-bottom: 1rem; }
.mt-1 { margin-top: 0.25rem; }
.mt-2 { margin-top: 0.5rem; }
.mt-3 { margin-top: 1rem; }
.p-1 { padding: 0.25rem; }
.p-2 { padding: 0.5rem; }
.p-3 { padding: 1rem; }

/* Loading and Empty States */
.loading {
    text-align: center;
    padding: 2rem;
    color: #6b7280;
}

.empty-state {
    text-align: center;
    padding: 3rem;
    color: #6b7280;
}

.empty-state h3 {
    margin-bottom: 0.5rem;
    color: #374151;
}

/* Success/Error Messages */
.alert {
    padding: 1rem;
    border-radius: 6px;
    margin-bottom: 1rem;
    font-weight: 500;
}

.alert-success {
    background-color: #d1fae5;
    color: #065f46;
    border: 1px solid #a7f3d0;
}

.alert-error {
    background-color: #fee2e2;
    color: #991b1b;
    border: 1px solid #fca5a5;
}

.alert-info {
    background-color: #dbeafe;
    color: #1e40af;
    border: 1px solid #93c5fd;
}

/* Responsive Design */
@media (max-width: 1024px) {
    .settings-container {
        flex-direction: column;
        height: auto;
    }
    
    .settings-sidebar {
        width: 100%;
        display: flex;
        flex-direction: row;
        overflow-x: auto;
        padding: 1rem 0;
        gap: 0;
    }
    
    .settings-nav-btn {
        padding: 1rem 1.5rem;
        white-space: nowrap;
        border-left: none;
        border-bottom: 3px solid transparent;
    }
    
    .settings-nav-btn.active {
        border-left: none;
        border-bottom-color: #4f46e5;
    }
}

@media (max-width: 768px) {
    /* Hide desktop menu, show mobile menu */
    .desktop-menu {
        display: none;
    }
    
    .mobile-menu {
        display: block;
    }
    
    .app-container {
        margin: 0;
        box-shadow: none;
    }
    
    header {
        padding: 1rem;
    }
    
    header h1 {
        font-size: 1.4rem;
    }
    
    .content {
        padding: 1rem;
    }
    
    .settings-content {
        padding: 1rem;
    }
    
    .form-grid {
        grid-template-columns: 1fr;
    }
    
    .cost-summary {
        grid-template-columns: 1fr;
    }
    
    .rate-cards-container {
        grid-template-columns: 1fr;
    }
    
    .tab-navigation {
        padding: 0 1rem;
    }
    
    .tab-btn {
        padding: 0.75rem 1rem;
    }
    
    .section-actions {
        flex-direction: column;
        align-items: stretch;
        gap: 1rem;
    }
    
    .summary-columns {
        grid-template-columns: 1fr;
    }
    
    .scope-grid {
        grid-template-columns: 1fr;
    }
    
    .info-item {
        grid-template-columns: 1fr;
        gap: 0.25rem;
    }
    
    .info-item.full-width {
        grid-template-columns: 1fr;
    }
    
    .settings-header {
        padding: 1rem;
    }
    
    .settings-header h1 {
        font-size: 1.25rem;
    }
}
