/* CSS Variables for Theme Management - Same as radiation converter */
:root {
    --primary: #3b82f6;
    --secondary: #1e40af;
    --bg-body: #f9fafb;
    --bg-card: #ffffff;
    --bg-input: #ffffff;
    --bg-readonly: #f3f4f6;
    --text-main: #111827;
    --text-muted: #4b5563;
    --border-color: #e5e7eb;
    --shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
    --info-bg: #dbeafe;
    --info-border: #3b82f6;
    --info-text: #1e3a8a;
    --warning-bg: #fef3c7;
    --warning-border: #f59e0b;
    --warning-text: #92400e;
    --success-bg: #d1fae5;
    --success-border: #10b981;
    --success-text: #065f46;
    --error-bg: #fee2e2;
    --error-border: #ef4444;
    --error-text: #7f1d1d;
    --def-bg: #f8f9fa;
    --formula-bg: #1e293b;
    --formula-text: #38bdf8;
}
.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;
}
  .input-header {
            display: flex;
            justify-content: space-between;
            align-items: center;
            margin-bottom: 0.5rem;
        }
        
        .input-hint {
            font-size: 0.75rem;
            color: var(--text-muted);
        }
        
        @media (max-width: 768px) {
            .button-group {
                flex-direction: column;
            }
            
            .btn {
                width: 100%;
                justify-content: center;
		}
		}

.dark {
    --bg-body: #111827;
    --bg-card: #1f2937;
    --bg-input: #374151;
    --bg-readonly: #4b5563;
    --text-main: #f3f4f6;
    --text-muted: #9ca3af;
    --border-color: #4b5563;
    --info-bg: #1e3a8a;
    --info-border: #60a5fa;
    --info-text: #dbeafe;
    --warning-bg: #422006;
    --warning-border: #fbbf24;
    --warning-text: #fef3c7;
    --success-bg: #064e3b;
    --success-border: #10b981;
    --success-text: #d1fae5;
    --error-bg: #7f1d1d;
    --error-border: #f87171;
    --error-text: #fee2e2;
    --def-bg: #374151;
}

/* Base Reset */
* { box-sizing: border-box; margin: 0; padding: 0; }
body {
    font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background-color: var(--bg-body);
    color: var(--text-main);
    line-height: 1.5;
    transition: background-color 0.3s, color 0.3s;
}
.container { max-width: 1280px; margin: 0 auto; padding: 0 1rem; }

/* Header */
header {
    background-color: var(--bg-card);
    box-shadow: var(--shadow);
    position: sticky;
    top: 0;
    z-index: 50;
    padding: 1rem 0;
}
.header-flex { display: flex; justify-content: space-between; align-items: center; }
.logo { font-size: 1.5rem; font-weight: bold; color: var(--primary); text-decoration: none; }

.toggle-btn {
    background: var(--bg-body);
    border: 1px solid var(--border-color);
    padding: 0.5rem;
    border-radius: 0.5rem;
    cursor: pointer;
    color: var(--text-main);
    transition: background-color 0.2s, border-color 0.2s;
}
.toggle-btn:hover {
    background: var(--bg-input);
}
.sun-icon { display: none; }
.dark .sun-icon { display: block; }
.dark .moon-icon { display: none; }

/* Layout Grid */
main { padding: 2rem 0; }
.lg-flex { display: flex; flex-direction: column; gap: 2rem; }
@media (min-width: 1024px) {
    .lg-flex { flex-direction: row; }
    .content-area { flex: 1; }
    .sidebar { width: 22rem; }
}

/* Card Styles */
.card {
    background: var(--bg-card);
    border-radius: 0.5rem;
    padding: 2rem;
    box-shadow: var(--shadow);
    margin-bottom: 2rem;
    border: 1px solid var(--border-color);
}
h1 { font-size: 1.875rem; font-weight: 700; margin-bottom: 1rem; color: var(--primary); }
h2 { font-size: 1.5rem; font-weight: 700; margin-bottom: 1.5rem; }
.subtitle { color: var(--text-muted); margin-bottom: 1.5rem; }

/* Alert Boxes */
.warning-box {
    background-color: var(--warning-bg);
    border-left: 4px solid var(--warning-border);
    color: var(--warning-text);
    padding: 1rem;
    border-radius: 0.5rem;
    margin-bottom: 1.5rem;
    font-size: 0.875rem;
}
.formula-display {
    background: var(--formula-bg);
    color: var(--formula-text);
    padding: 1rem;
    border-radius: 0.5rem;
    font-family: monospace;
    text-align: center;
    margin: 1.5rem 0;
    font-size: 1rem;
    display: none;
    border: 1px solid rgba(255,255,255,0.1);
}
.formula-display.show {
    display: block;
    animation: fadeIn 0.3s ease;
}

/* Inputs & Selects */
.grid-2 { display: grid; grid-template-columns: 1fr; gap: 2rem; margin-bottom: 1.5rem; }
@media (min-width: 768px) { .grid-2 { grid-template-columns: 1fr 1fr; } }

label { display: block; font-size: 0.875rem; font-weight: 600; margin-bottom: 0.5rem; }
.input-group { margin-bottom: 1.5rem; }
input, select {
    width: 100%;
    padding: 0.75rem 1rem;
    border: 1px solid var(--border-color);
    border-radius: 0.5rem;
    background: var(--bg-input);
    color: var(--text-main);
    font-size: 1rem;
    transition: border-color 0.2s, box-shadow 0.2s;
}
input:focus, select:focus { outline: 2px solid var(--primary); outline-offset: -1px; }
input[readonly] { background-color: var(--bg-readonly); cursor: default; }
input.error { border-color: var(--error-border); background-color: var(--error-bg); }
.error-message {
    color: var(--error-text);
    font-size: 0.75rem;
    margin-top: 0.25rem;
    display: none;
}
.error-message.show {
    display: block;
    animation: shake 0.5s ease;
}

/* Button Styles */
.button-group {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
    margin-top: 1.5rem;
}
.btn {
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: 0.5rem;
    font-weight: 600;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    transition: background-color 0.2s, transform 0.1s;
    font-size: 0.875rem;
}
.btn:active { transform: translateY(1px); }
.btn-primary {
    background-color: var(--primary);
    color: white;
}
.btn-primary:hover { background-color: var(--secondary); }
.btn-secondary {
    background-color: var(--bg-input);
    color: var(--text-main);
    border: 1px solid var(--border-color);
}
.btn-secondary:hover { background-color: var(--bg-readonly); }
.btn-outline {
    background-color: transparent;
    color: var(--primary);
    border: 1px solid var(--primary);
}
.btn-outline:hover { background-color: rgba(59, 130, 246, 0.1); }

/* Result container with copy button */
.result-container {
    position: relative;
    margin-bottom: 1.5rem;
}
.copy-btn {
    position: absolute;
    right: 0.5rem;
    top: 0.5rem;
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 0.5rem;
    border-radius: 0.25rem;
    transition: background-color 0.2s, color 0.2s;
}
.copy-btn:hover {
    background-color: var(--bg-readonly);
    color: var(--primary);
}
.copy-success {
    position: absolute;
    right: 3rem;
    top: 0.5rem;
    font-size: 0.75rem;
    color: var(--success-text);
    background: var(--success-bg);
    padding: 0.25rem 0.5rem;
    border-radius: 0.25rem;
    opacity: 0;
    transition: opacity 0.3s;
}
.copy-success.show {
    opacity: 1;
}

/* Educational Section */
.unit-definition {
    background: var(--def-bg);
    border-left: 4px solid var(--primary);
    padding: 1.25rem;
    margin-bottom: 1.25rem;
    border-radius: 0.5rem;
    transition: all 0.3s ease;
}
.unit-definition:hover {
    transform: translateX(4px);
}
.unit-definition h3 { color: var(--primary); font-size: 1.25rem; margin-bottom: 0.5rem; }
.unit-definition p { font-size: 0.9375rem; color: var(--text-muted); margin-bottom: 0.5rem; }
.unit-definition strong { color: var(--text-main); }
.unit-definition code {
    background: rgba(59, 130, 246, 0.1);
    padding: 0.2rem 0.4rem;
    border-radius: 0.25rem;
    font-family: monospace;
    color: var(--primary);
}
.unit-definition ul {
    margin-left: 1.5rem;
    margin-bottom: 1rem;
}
.unit-definition li {
    margin-bottom: 0.5rem;
    font-size: 0.9375rem;
}

/* Table Styles */
.table-container {
    overflow-x: auto;
    margin: 1.5rem 0;
}
.reference-table {
    width: 100%;
    border-collapse: collapse;
    background: var(--def-bg);
    border-radius: 0.5rem;
    overflow: hidden;
}
.reference-table th, .reference-table td {
    padding: 1rem;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
}
.reference-table th {
    color: var(--primary);
    font-weight: 700;
    background: rgba(59, 130, 246, 0.1);
}
.reference-table tr:hover {
    background: rgba(59, 130, 246, 0.05);
}

/* Sidebar Elements */
.sidebar-section h3 { font-size: 1.25rem; font-weight: 600; margin-bottom: 1rem; }
.ref-item { border-bottom: 1px solid var(--border-color); padding: 0.5rem 0; }
.ref-label { font-weight: 600; font-size: 0.875rem; color: var(--text-main); }
.ref-value { font-size: 0.875rem; color: var(--text-muted); }

.nav-link {
    display: block;
    color: var(--primary);
    text-decoration: none;
    font-size: 0.875rem;
    margin-bottom: 0.6rem;
    padding: 0.25rem 0;
    transition: color 0.2s, transform 0.2s;
}
.nav-link:hover { 
    color: var(--secondary); 
    text-decoration: underline;
    transform: translateX(4px);
}

/* Footer */
footer {
    border-top: 1px solid var(--border-color);
    padding: 3rem 0;
    text-align: center;
    color: var(--text-muted);
    background: var(--bg-card);
    margin-top: 4rem;
}

/* Animations */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(-10px); }
    to { opacity: 1; transform: translateY(0); }
}
@keyframes shake {
    0%, 100% { transform: translateX(0); }
    10%, 30%, 50%, 70%, 90% { transform: translateX(-5px); }
    20%, 40%, 60%, 80% { transform: translateX(5px); }
}
@keyframes pulse {
    0% { box-shadow: 0 0 0 0 rgba(59, 130, 246, 0.7); }
    70% { box-shadow: 0 0 0 10px rgba(59, 130, 246, 0); }
    100% { box-shadow: 0 0 0 0 rgba(59, 130, 246, 0); }
}

/* Utility classes */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}
.input-header {
            display: flex;
            justify-content: space-between;
            align-items: center;
            margin-bottom: 0.5rem;
        }
        
        .input-hint {
            font-size: 0.75rem;
            color: var(--text-muted);
        }
        
        /* Ad container styles */
        .ad-container {
            margin: 1.5rem 0;
            text-align: center;
            overflow: hidden;
            border-radius: 0.5rem;
            background: var(--bg-card);
            border: 1px solid var(--border-color);
            padding: 0.5rem;
        }
        
        .ad-leaderboard {
            margin-top: 1rem;
            margin-bottom: 2rem;
        }
        
        .ad-footer-leaderboard {
            margin-top: 2rem;
            margin-bottom: 1rem;
        }
        
        .ad-banner {
            margin: 1.5rem 0;
        }
        
        .ad-bottom-banner {
            margin-top: 2rem;
        }
        
        .ad-rectangle {
            margin: 2rem 0;
        }
        
        .ad-skyscraper {
            margin-bottom: 1.5rem;
            min-height: 600px;
        }
        
        .ad-sidebar-rectangle {
            margin: 1.5rem 0;
        }
        
        .ad-sidebar-bottom {
            margin-top: 1.5rem;
        }
        
        /* Responsive ad adjustments */
        @media (max-width: 768px) {
            .button-group {
                flex-direction: column;
            }
            
            .btn {
                width: 100%;
                justify-content: center;
            }
            
            .ad-skyscraper {
                display: none; /* Hide skyscraper on mobile */
            }
            
            .ad-container {
                margin: 1rem 0;
                padding: 0.25rem;
            }
        }
        
        @media (min-width: 769px) and (max-width: 1024px) {
            .ad-skyscraper {
                min-height: 400px;
            }
        }
		/* Sidebar Styles */
.sidebar {
    width: 280px;
    margin-left: 2rem;
}

.sidebar-section {
    margin-bottom: 1.5rem;
}

.sidebar-section h3 {
    margin-bottom: 1rem;
    color: var(--primary);
    font-size: 1.1rem;
}

.sidebar-links {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.sidebar-link {
    display: block;
    padding: 0.5rem 0.75rem;
    color: var(--text);
    text-decoration: none;
    border-radius: 4px;
    transition: all 0.2s ease;
    border-left: 3px solid transparent;
}

.sidebar-link:hover {
    background-color: rgba(52, 152, 219, 0.1);
    color: var(--primary);
    border-left: 3px solid var(--primary);
    padding-left: 1rem;
}

.ref-item {
    padding: 0.75rem 0;
    border-bottom: 1px solid var(--border);
}

.ref-item:last-child {
    border-bottom: none;
}

.ref-label {
    font-weight: 600;
    color: var(--primary);
    margin-bottom: 0.25rem;
    font-size: 0.9rem;
}

.ref-value {
    color: var(--text-muted);
    font-size: 0.85rem;
    margin-bottom: 0.25rem;
    line-height: 1.4;
}

/* Responsive Sidebar */
@media (max-width: 1024px) {
    .lg-flex {
        flex-direction: column;
    }
    
    .sidebar {
        width: 100%;
        margin-left: 0;
        margin-top: 2rem;
        display: grid;
        grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
        gap: 1.5rem;
    }
    
    .sidebar-section {
        margin-bottom: 0;
    }
}