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

:root {
    --primary-color: #2563eb;
    --secondary-color: #7c3aed;
    --success-color: #059669;
    --danger-color: #dc2626;
    --light-color: #f8fafc;
    --dark-color: #1e293b;
    --gray-color: #64748b;
    --border-color: #e2e8f0;
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    --radius: 8px;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    line-height: 1.6;
    color: var(--dark-color);
    background-color: #f1f5f9;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 1.5rem;
}

/* Typography */
h1, h2, h3 {
    font-weight: 600;
    line-height: 1.2;
}

h1 { font-size: 2.5rem; }
h2 { font-size: 1.75rem; margin-bottom: 1.5rem; }
h3 { font-size: 1.25rem; }

/* Header */
.header {
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    color: white;
    padding: 2rem 0;
    margin-bottom: 2rem;
}

.logo {
    font-size: 2rem;
    margin-bottom: 0.5rem;
}

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

/* Main Layout */
.app-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 2rem;
    margin-bottom: 3rem;
}

@media (min-width: 768px) {
    .app-grid {
        grid-template-columns: 1fr 1fr;
    }
    
    .explanations-section {
        grid-column: 1 / -1;
    }
}

@media (min-width: 1024px) {
    .app-grid {
        grid-template-columns: 1fr 2fr;
    }
    
    .explanations-section {
        grid-column: 1;
        grid-row: 2;
    }
    
    .results-section {
        grid-column: 2;
        grid-row: 1 / span 2;
    }
}

/* Cards */
.card {
    background: white;
    border-radius: var(--radius);
    padding: 1.5rem;
    box-shadow: var(--shadow);
}

/* Form Styles */
.form-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

@media (min-width: 640px) {
    .form-grid {
        grid-template-columns: 1fr 1fr;
    }
}

.form-group {
    margin-bottom: 1rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
    color: var(--dark-color);
}

.form-group input,
.form-group select {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    font-size: 1rem;
    transition: border-color 0.2s;
}

.form-group input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.method-selection {
    display: grid;
    grid-template-columns: 1fr;
    gap: 0.75rem;
    margin-top: 0.5rem;
}

@media (min-width: 640px) {
    .method-selection {
        grid-template-columns: 1fr 1fr;
    }
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
}

/* Buttons */
.btn {
    display: inline-block;
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: var(--radius);
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    text-align: center;
}

.btn-primary {
    background-color: var(--primary-color);
    color: white;
}

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

.btn-secondary {
    background-color: var(--light-color);
    color: var(--dark-color);
    border: 1px solid var(--border-color);
}

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

/* Table */
.table-container {
    overflow-x: auto;
    margin: 1.5rem 0;
}

.depreciation-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}

.depreciation-table th {
    background-color: var(--light-color);
    padding: 0.75rem;
    text-align: left;
    font-weight: 600;
    border-bottom: 2px solid var(--border-color);
}

.depreciation-table td {
    padding: 0.75rem;
    border-bottom: 1px solid var(--border-color);
}

.depreciation-table tr:hover {
    background-color: #f8fafc;
}

/* Method Explanations */
.method-explanation {
    padding: 1rem;
    margin-bottom: 1rem;
    border-left: 4px solid var(--primary-color);
    background-color: var(--light-color);
    border-radius: 0 var(--radius) var(--radius) 0;
}

.method-explanation code {
    display: block;
    padding: 0.75rem;
    margin: 0.75rem 0;
    background-color: white;
    border-radius: var(--radius);
    font-family: 'Courier New', monospace;
    font-size: 0.9rem;
}

.method-use {
    font-style: italic;
    color: var(--gray-color);
    margin-top: 0.5rem;
}

/* Footer */
.footer {
    background-color: var(--dark-color);
    color: white;
    padding: 2rem 0;
    text-align: center;
}

.footer-links {
    margin-top: 1rem;
}

.footer-links a {
    color: #93c5fd;
    text-decoration: none;
}

.footer-links a:hover {
    text-decoration: underline;
}

/* Visualization */
.visualization-container {
    margin-top: 2rem;
    padding: 1rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
}

/* Asset Summary Styles */
.summary-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
    margin-top: 1rem;
    padding: 1rem;
    background-color: var(--light-color);
    border-radius: var(--radius);
}

.summary-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.5rem 0;
    border-bottom: 1px solid var(--border-color);
}

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

.summary-label {
    font-weight: 500;
    color: var(--gray-color);
}

.summary-value {
    font-weight: 600;
    color: var(--dark-color);
}

/* Loading State */
.loading {
    text-align: center;
    padding: 2rem;
    color: var(--gray-color);
}

/* Error State */
.error {
    background-color: #fee2e2;
    border-left: 4px solid var(--danger-color);
    padding: 1rem;
    margin: 1rem 0;
    border-radius: 0 var(--radius) var(--radius) 0;
}

/* Print Styles */
@media print {
    .header, .footer, .btn {
        display: none;
    }
    
    .card {
        box-shadow: none;
        border: 1px solid #ddd;
    }
}

/* Method Selection Enhancements */
.method-badge {
    font-size: 0.7rem;
    padding: 0.1rem 0.4rem;
    background: #e2e8f0;
    color: #4a5568;
    border-radius: 10px;
    margin-left: 0.5rem;
    font-weight: 600;
}

.method-name {
    font-weight: 500;
}

/* Results Table for Multiple Methods */
.comparison-header {
    background: #4f46e5;
    color: white;
    text-align: center;
    font-weight: 600;
    font-size: 1.1rem;
}

.method-data {
    border-left: 1px solid #e2e8f0;
    vertical-align: top;
}

.method-label {
    font-weight: 600;
    color: #4f46e5;
    margin-bottom: 0.5rem;
    font-size: 0.9rem;
}

.method-data div {
    font-size: 0.85rem;
    margin: 0.1rem 0;
}

/* Highlight accelerated methods */
input[value="straightLine"]:checked ~ .method-name,
input[value="decliningBalance200"]:checked ~ .method-name,
input[value="decliningBalance150"]:checked ~ .method-name,
input[value="sumOfYearsDigits"]:checked ~ .method-name {
    color: #dc2626;
    font-weight: 600;
}

/* ============================================
   MOBILE RESPONSIVENESS FIXES
   ============================================ */

/* 1. PREVENT HORIZONTAL SCROLLING */
html, body {
    max-width: 100vw;
    overflow-x: hidden;
    position: relative;
}

/* 2. FIX HEADER ON MOBILE */
@media (max-width: 768px) {
    .header {
        padding: 1rem 0.5rem !important;
        text-align: center;
        width: 100vw;
        margin-left: -0.5rem;
        margin-right: -0.5rem;
    }
    
    .header .container {
        padding: 0 0.75rem !important;
        max-width: 100% !important;
        width: 100% !important;
    }
    
    .logo {
        font-size: 1.5rem !important;
        line-height: 1.3;
        word-wrap: break-word;
        overflow-wrap: break-word;
        padding: 0 0.5rem;
    }
    
    .subtitle {
        font-size: 0.9rem !important;
        line-height: 1.4;
        padding: 0 0.5rem;
    }
}

/* 3. FIX FOOTER ON MOBILE */
@media (max-width: 768px) {
    .footer {
        padding: 1rem 0.5rem !important;
        width: 100vw;
        margin-left: -0.5rem;
        margin-right: -0.5rem;
        text-align: center;
    }
    
    .footer .container {
        padding: 0 0.75rem !important;
        max-width: 100% !important;
        width: 100% !important;
    }
    
    .footer p {
        font-size: 0.85rem;
        line-height: 1.4;
        margin-bottom: 0.75rem;
        padding: 0 0.25rem;
    }
    
    .footer-links {
        display: flex;
        flex-direction: column;
        gap: 0.5rem;
        align-items: center;
    }
    
    .footer-links a {
        font-size: 0.85rem;
        padding: 0.25rem 0.5rem;
        display: inline-block;
    }
}

/* 4. FIX MAIN CONTENT AREA */
@media (max-width: 768px) {
    .main-content .container {
        padding: 0 0.75rem !important;
        max-width: 100% !important;
        width: 100% !important;
    }
    
    .app-grid {
        display: flex !important;
        flex-direction: column !important;
        gap: 1.5rem !important;
        padding: 0 0.25rem;
    }
    
    .card {
        padding: 1rem !important;
        margin: 0 -0.25rem;
        width: calc(100% + 0.5rem);
    }
}

/* 5. FIX TABLES ON MOBILE */
@media (max-width: 768px) {
    .table-container {
        margin-left: -0.5rem;
        margin-right: -0.5rem;
        width: calc(100% + 1rem);
    }
    
    .depreciation-table {
        min-width: 600px; /* Allow horizontal scroll for wide tables */
        font-size: 0.8rem;
    }
    
    .depreciation-table th,
    .depreciation-table td {
        padding: 0.5rem 0.25rem !important;
    }
    
    .method-data div {
        font-size: 0.75rem !important;
    }
}

/* 6. FIX FORMS ON MOBILE */
@media (max-width: 768px) {
    .form-grid {
        grid-template-columns: 1fr !important;
        gap: 0.75rem;
    }
    
    .form-group input {
        padding: 0.6rem !important;
        font-size: 0.9rem !important;
    }
    
    .method-selection {
        grid-template-columns: 1fr !important;
    }
    
    .btn {
        width: 100% !important;
        margin-bottom: 0.5rem;
        padding: 0.75rem !important;
    }
    
    #resetBtn {
        margin-top: 0.5rem;
    }
}

/* 7. EXTRA SMALL PHONES (iPhone 5/SE) */
@media (max-width: 375px) {
    .logo {
        font-size: 1.3rem !important;
    }
    
    .subtitle {
        font-size: 0.8rem !important;
    }
    
    .card {
        padding: 0.75rem !important;
    }
    
    h2 {
        font-size: 1.25rem !important;
    }
}

/* Method Explanation Enhancements */
.rate-examples {
    background: #f8fafc;
    border-left: 3px solid #7c3aed;
    padding: 0.75rem;
    margin: 0.75rem 0;
    border-radius: 0 4px 4px 0;
}

.rate-examples p {
    margin: 0.25rem 0;
    font-size: 0.9rem;
}

.method-note {
    background: #fef3c7;
    border-left: 3px solid #d97706;
    padding: 0.75rem;
    margin-top: 0.75rem;
    border-radius: 0 4px 4px 0;
    font-size: 0.85rem;
    color: #92400e;
}

.partial-year::after {
    content: " *";
    color: #dc2626;
    font-size: 0.8em;
}

/* Ensure number inputs show decimals properly */
input[type="number"] {
    font-variant-numeric: tabular-nums;
}

/* Better alignment for decimal numbers in tables */
.method-data div, .summary-value {
    text-align: right;
    font-feature-settings: "tnum";
}

/* Method checkbox styling - Add this to your existing CSS */
.method-checkbox:checked ~ .method-name {
    color: #dc2626;
    font-weight: 600;
    transition: color 0.2s ease;
}

/* Optional: Different colors for different methods */
.method-checkbox[value="straightLine"]:checked ~ .method-name {
    color: #2563eb; /* Blue for Straight-Line */
}

.method-checkbox[value="decliningBalance200"]:checked ~ .method-name,
.method-checkbox[value="decliningBalance150"]:checked ~ .method-name {
    color: #dc2626; /* Red for Declining Balance */
}

.method-checkbox[value="sumOfYearsDigits"]:checked ~ .method-name {
    color: #059669; /* Green for Sum-of-Years */
}

/* Add visual feedback on hover */
.checkbox-label:hover .method-name {
    color: #4f46e5;
}

/* Accessibility focus styles */
.method-checkbox:focus ~ .method-name {
    outline: 2px solid #3b82f6;
    outline-offset: 2px;
    border-radius: 4px;
}

/* Visually hidden class for screen readers */
/* Add to styles.css */
.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.form-label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
    color: var(--dark-color);
}
