/* Layout Styles - Grid and Flexbox Structure */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

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

.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 20px;
}

/* Header Layout */
.app-header {
    background-color: #1e3a8a;
    color: white;
    padding: 2rem 0;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.header-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.app-header h1 {
    font-size: 1.75rem;
    margin: 0;
    font-weight: 600;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.user-name {
    font-size: 0.9rem;
    color: #e0e7ff;
}

.user-role-badge {
    padding: 0.25rem 0.75rem;
    background-color: #059669;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
}

.user-role-badge.admin {
    background-color: #dc2626;
}

.btn-admin {
    padding: 0.5rem 1rem;
    background-color: #f59e0b;
    color: white;
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 6px;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-admin:hover {
    background-color: #d97706;
}

.btn-logout {
    padding: 0.5rem 1rem;
    background-color: rgba(255, 255, 255, 0.1);
    color: white;
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 6px;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-logout:hover {
    background-color: rgba(255, 255, 255, 0.2);
    border-color: rgba(255, 255, 255, 0.5);
}

.header-inputs {
    display: flex;
    gap: 2rem;
    flex-wrap: wrap;
}

.input-group {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.input-group label {
    font-size: 0.9rem;
    font-weight: 500;
}

.input-group input {
    padding: 0.5rem;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 0.9rem;
}

/* Main Calculator Wrapper */
.calculator-wrapper {
    display: grid;
    grid-template-columns: 1fr 350px;
    gap: 2rem;
    margin-top: 2rem;
    margin-bottom: 2rem;
}

/* Calculator Body */
.calculator-body {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

/* Category Sections */
.category-section {
    background-color: white;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    overflow: hidden;
}

.category-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.5rem;
    background-color: #e0e7ff;
    border-bottom: 2px solid #1e3a8a;
    cursor: pointer;
}

.category-header h2 {
    font-size: 1.25rem;
    color: #1e3a8a;
    font-weight: 600;
}

.toggle-btn {
    background: none;
    border: none;
    font-size: 1.5rem;
    color: #1e3a8a;
    cursor: pointer;
    padding: 0;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.category-content {
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.category-content.collapsed {
    display: none;
}

.category-description {
    background-color: #f9fafb;
    padding: 0.75rem 1rem;
    border-left: 3px solid #3b82f6;
    margin-bottom: 0.5rem;
    font-size: 0.9rem;
    color: #4b5563;
    line-height: 1.5;
    border-radius: 4px;
}

/* Line Items */
.line-item {
    display: grid;
    grid-template-columns: 2fr 1fr 1fr 1fr;
    gap: 1rem;
    align-items: center;
    padding: 0.75rem;
    border-bottom: 1px solid #e5e7eb;
}

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

.line-item label {
    font-weight: 500;
    color: #374151;
}

.quantity-input,
.unit-cost {
    padding: 0.5rem;
    border: 1px solid #d1d5db;
    border-radius: 4px;
    font-size: 0.9rem;
}

.unit-cost {
    background-color: #f9fafb;
    text-align: right;
}

.line-total {
    font-weight: 600;
    color: #059669;
    text-align: right;
}

/* Category Subtotal */
.category-subtotal {
    display: flex;
    justify-content: space-between;
    padding: 1rem 1.5rem;
    background-color: #f9fafb;
    border-top: 2px solid #e5e7eb;
    font-weight: 600;
    color: #1e3a8a;
}

/* Summary Panel */
.summary-panel {
    background-color: white;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    padding: 1.5rem;
    height: fit-content;
    position: sticky;
    top: 20px;
}

.summary-panel h3 {
    font-size: 1.25rem;
    color: #1e3a8a;
    margin-bottom: 1rem;
    padding-bottom: 0.75rem;
    border-bottom: 2px solid #e0e7ff;
}

.summary-breakdown {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    margin-bottom: 1.5rem;
}

.summary-line {
    display: flex;
    justify-content: space-between;
    font-size: 0.9rem;
}

.summary-line span:first-child {
    color: #6b7280;
}

.summary-line span:last-child {
    font-weight: 600;
    color: #374151;
}

.grand-total {
    display: flex;
    justify-content: space-between;
    padding: 1rem;
    background-color: #059669;
    color: white;
    border-radius: 6px;
    font-size: 1.25rem;
    font-weight: 700;
    margin-bottom: 1.5rem;
}

/* Action Buttons */
.action-buttons {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.75rem;
}

.btn {
    padding: 0.75rem 1rem;
    border: none;
    border-radius: 6px;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-primary {
    background-color: #1e3a8a;
    color: white;
}

.btn-primary:hover {
    background-color: #1e40af;
}

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

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

/* Responsive Design */
@media (max-width: 1200px) {
    .calculator-wrapper {
        grid-template-columns: 1fr;
    }

    .summary-panel {
        position: static;
    }
}

@media (max-width: 768px) {
    .line-item {
        grid-template-columns: 1fr;
        gap: 0.5rem;
    }

    .line-item label {
        font-size: 0.95rem;
    }

    .action-buttons {
        grid-template-columns: 1fr;
    }

    .header-top {
        flex-direction: column;
        align-items: flex-start;
        gap: 1rem;
    }

    .app-header h1 {
        font-size: 1.25rem;
    }

    .user-info {
        width: 100%;
        justify-content: space-between;
    }

    .user-name {
        font-size: 0.85rem;
    }

    .user-role-badge {
        font-size: 0.7rem;
        padding: 0.2rem 0.6rem;
    }

    .btn-logout {
        padding: 0.4rem 0.8rem;
        font-size: 0.85rem;
    }

    .header-inputs {
        flex-direction: column;
        gap: 1rem;
    }

    .input-group {
        width: 100%;
        justify-content: space-between;
    }

    .input-group input {
        flex: 1;
        max-width: 200px;
    }
}
