/* CSS Variables */
:root {
    --primary-color: #1E3A5F;
    --primary-dark: #152a45;
    --primary-light: #2d5a8a;
    --accent-color: #2E7D32;
    --accent-light: #4CAF50;
    --text-color: #333333;
    --text-light: #666666;
    --bg-color: #f5f7fa;
    --card-bg: #ffffff;
    --border-color: #e0e0e0;
    --error-color: #d32f2f;
    --success-color: #2E7D32;
    --warning-color: #f57c00;
    --shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 4px 16px rgba(0, 0, 0, 0.15);
    --radius: 8px;
    --radius-lg: 12px;
    --transition: all 0.3s ease;
}

/* Reset & Base */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    font-size: 16px;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-color);
    line-height: 1.6;
    min-height: 100vh;
}

/* RTL Support */
[dir="rtl"] {
    text-align: right;
}

/* Page Visibility */
.page {
    min-height: 100vh;
}

.hidden {
    display: none !important;
}

/* Login Page */
.login-container {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-dark) 100%);
    padding: 20px;
}

.login-card {
    background: var(--card-bg);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    padding: 40px;
    width: 100%;
    max-width: 400px;
}

.login-header {
    text-align: center;
    margin-bottom: 30px;
}

.login-header .logo-icon {
    font-size: 3rem;
    display: block;
    margin-bottom: 15px;
}

.login-header h1 {
    color: var(--primary-color);
    font-size: 1.5rem;
    margin-bottom: 5px;
}

.login-header h2 {
    color: var(--text-light);
    font-size: 1.1rem;
    font-weight: normal;
}

/* Forms */
.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
    color: var(--text-color);
    font-size: 0.9rem;
}

.form-group input,
.form-group select {
    width: 100%;
    padding: 12px 16px;
    border: 2px solid var(--border-color);
    border-radius: var(--radius);
    font-size: 1rem;
    transition: var(--transition);
    background: var(--card-bg);
}

.form-group input:focus,
.form-group select:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(30, 58, 95, 0.1);
}

.form-group input:invalid {
    border-color: var(--error-color);
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 15px;
}

@media (max-width: 600px) {
    .form-grid {
        grid-template-columns: 1fr;
    }
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 12px 24px;
    border: none;
    border-radius: var(--radius);
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    text-decoration: none;
}

.btn-primary {
    background-color: var(--primary-color);
    color: white;
}

.btn-primary:hover {
    background-color: var(--primary-dark);
    transform: translateY(-1px);
}

.btn-primary:active {
    transform: translateY(0);
}

.btn-outline {
    background: transparent;
    border: 2px solid var(--border-color);
    color: var(--text-color);
}

.btn-outline:hover {
    border-color: var(--primary-color);
    color: var(--primary-color);
}

.btn-block {
    width: 100%;
}

/* Error Messages */
.error-message {
    background-color: #ffebee;
    color: var(--error-color);
    padding: 12px;
    border-radius: var(--radius);
    margin-bottom: 15px;
    font-size: 0.9rem;
    text-align: center;
}

/* App Header */
.app-header {
    background: var(--primary-color);
    color: white;
    padding: 15px 0;
    box-shadow: var(--shadow);
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-content {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.brand {
    display: flex;
    align-items: center;
    gap: 12px;
}

.brand .logo-icon {
    font-size: 2rem;
}

.brand-text h1 {
    font-size: 1.25rem;
    margin: 0;
}

.brand-text .subtitle {
    font-size: 0.85rem;
    opacity: 0.9;
}

.app-header .btn-outline {
    color: white;
    border-color: rgba(255, 255, 255, 0.5);
    padding: 8px 16px;
}

.app-header .btn-outline:hover {
    border-color: white;
    background: rgba(255, 255, 255, 0.1);
    color: white;
}

/* Main Content */
.main-content {
    max-width: 1200px;
    margin: 0 auto;
    padding: 30px 20px;
}

/* Tabs */
.tabs {
    display: flex;
    gap: 10px;
    margin-bottom: 25px;
    background: var(--card-bg);
    padding: 8px;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
}

.tab {
    flex: 1;
    padding: 15px 20px;
    border: none;
    background: transparent;
    border-radius: var(--radius);
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    color: var(--text-light);
}

.tab:hover {
    background: var(--bg-color);
    color: var(--text-color);
}

.tab.active {
    background: var(--primary-color);
    color: white;
}

/* Calculator Panels */
.calculator-panel {
    display: none;
}

.calculator-panel.active {
    display: block;
}

.calculator-grid {
    display: grid;
    grid-template-columns: 1fr 1.5fr;
    gap: 25px;
}

@media (max-width: 900px) {
    .calculator-grid {
        grid-template-columns: 1fr;
    }
}

/* Cards */
.card {
    background: var(--card-bg);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    padding: 25px;
}

.card-title {
    color: var(--primary-color);
    font-size: 1.2rem;
    margin-bottom: 20px;
    padding-bottom: 10px;
    border-bottom: 2px solid var(--bg-color);
}

/* Constants Section */
.constants-section {
    background: var(--bg-color);
    border-radius: var(--radius);
    padding: 15px;
    margin: 20px 0;
}

.constants-section h4 {
    color: var(--text-light);
    font-size: 0.9rem;
    margin-bottom: 10px;
}

.constants-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 15px;
}

.constants-grid span {
    background: var(--card-bg);
    padding: 5px 12px;
    border-radius: var(--radius);
    font-size: 0.85rem;
    font-family: 'Courier New', monospace;
}

/* Results */
.results-container {
    min-height: 300px;
}

.results-placeholder {
    display: flex;
    justify-content: center;
    align-items: center;
    height: 300px;
    color: var(--text-light);
    font-size: 1rem;
    text-align: center;
    border: 2px dashed var(--border-color);
    border-radius: var(--radius);
}

/* Results Display */
.results-section {
    margin-bottom: 25px;
}

.results-section h4 {
    color: var(--primary-color);
    font-size: 1rem;
    margin-bottom: 15px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.results-section h4::before {
    content: '';
    display: block;
    width: 4px;
    height: 20px;
    background: var(--accent-color);
    border-radius: 2px;
}

.result-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 15px;
    background: var(--bg-color);
    border-radius: var(--radius);
    margin-bottom: 8px;
}

.result-item:hover {
    background: #eef2f7;
}

.result-label {
    color: var(--text-color);
    font-size: 0.95rem;
}

.result-value {
    font-weight: 600;
    color: var(--primary-color);
    font-family: 'Courier New', monospace;
    font-size: 1rem;
}

.result-value.highlight {
    color: var(--accent-color);
    font-size: 1.1rem;
}

/* Note Box */
.note-box {
    background: #fff3e0;
    border-right: 4px solid var(--warning-color);
    padding: 12px 15px;
    border-radius: var(--radius);
    margin-bottom: 20px;
    font-size: 0.9rem;
    color: #e65100;
}

.note-box.success {
    background: #e8f5e9;
    border-right-color: var(--success-color);
    color: #1b5e20;
}

/* Tables */
.slope-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 15px;
    font-size: 0.9rem;
}

.slope-table th,
.slope-table td {
    padding: 12px 15px;
    text-align: center;
    border: 1px solid var(--border-color);
}

.slope-table th {
    background: var(--primary-color);
    color: white;
    font-weight: 600;
}

.slope-table tr:nth-child(even) {
    background: var(--bg-color);
}

.slope-table tr:hover {
    background: #e3f2fd;
}

.slope-table .highlight-row {
    background: #e8f5e9 !important;
    font-weight: 600;
}

/* Summary Box */
.summary-box {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-light) 100%);
    color: white;
    padding: 20px;
    border-radius: var(--radius-lg);
    margin-bottom: 25px;
}

.summary-box h4 {
    margin-bottom: 15px;
    font-size: 1.1rem;
}

.summary-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 15px;
}

@media (max-width: 600px) {
    .summary-grid {
        grid-template-columns: 1fr;
    }
}

.summary-item {
    text-align: center;
    background: rgba(255, 255, 255, 0.1);
    padding: 15px;
    border-radius: var(--radius);
}

.summary-item .label {
    font-size: 0.85rem;
    opacity: 0.9;
    margin-bottom: 5px;
}

.summary-item .value {
    font-size: 1.5rem;
    font-weight: 700;
}

/* Footer */
.app-footer {
    background: var(--primary-dark);
    color: rgba(255, 255, 255, 0.8);
    text-align: center;
    padding: 20px;
    margin-top: 40px;
}

.app-footer p {
    font-size: 0.9rem;
}

/* Responsive Adjustments */
@media (max-width: 480px) {
    .login-card {
        padding: 30px 20px;
    }

    .header-content {
        flex-direction: column;
        gap: 15px;
        text-align: center;
    }

    .brand {
        flex-direction: column;
        text-align: center;
    }

    .tabs {
        flex-direction: column;
    }

    .card {
        padding: 20px 15px;
    }

    .slope-table {
        font-size: 0.8rem;
    }

    .slope-table th,
    .slope-table td {
        padding: 8px;
    }
}

/* Print Styles */
@media print {
    .app-header,
    .app-footer,
    .input-card,
    .tabs,
    #logout-btn {
        display: none;
    }

    .calculator-grid {
        grid-template-columns: 1fr;
    }

    .results-card {
        box-shadow: none;
    }
}
