/**
 * Modern Percentage Calculator Styles
 * File: css/calc.css
 */

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    line-height: 1.6;
    min-height: 100vh;
    padding: 20px;
    /* Transition for smooth theme changes */
    transition: background 0.3s ease, color 0.3s ease;
}

/* Base Light Theme (Default) */
body.theme-light {
    color: #333;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.container {
    max-width: 800px;
    margin: 0 auto;
    background: white;
    border-radius: 12px;
    box-shadow: 0 15px 40px rgba(0, 0, 0, 0.25);
    overflow: hidden;
    transition: background 0.3s ease, box-shadow 0.3s ease;
}

/* Header Styles */
.header {
    /* Varm fargepalett: Burnt Orange, Terracotta, Mustard Yellow */
    background-color: #ccc; 
    color: white;
    padding: 30px;
    text-align: center;
    box-shadow: inset 0 -5px 10px rgba(0, 0, 0, 0.1);
}

.header h1 {
    font-size: 2.5rem;
    margin-bottom: 10px;
    text-shadow: 1px 1px 3px rgba(0,0,0,0.2);
}

/* Theme Switcher */
.theme-switcher {
    text-align: right;
    padding: 10px 20px 0;
    background-color: inherit;
    transition: background-color 0.3s ease;
}

.theme-switcher button {
    padding: 8px 15px;
    border: 1px solid #ccc;
    background-color: #eee;
    border-radius: 5px;
    cursor: pointer;
    font-size: 0.9em;
    margin-left: 5px;
    transition: background-color 0.3s, color 0.3s, border-color 0.3s;
}

.theme-switcher button.active {
    background-color: #007bff;
    color: white;
    border-color: #007bff;
}

.theme-switcher button:hover:not(.active) {
    background-color: #ddd;
}


/* Content Area */
.content {
    padding: 30px;
}

/* Calculator Sections */
.calculator-section {
    background: #f8f9fa;
    border-radius: 8px;
    padding: 25px;
    margin-bottom: 30px;
    border-left: 4px solid #4facfe;
    transition: background 0.3s ease, border-color 0.3s ease;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.calculator-section h2 {
    color: #2c3e50;
    margin-bottom: 20px;
    font-size: 1.4rem;
    transition: color 0.3s ease;
}

/* Form Elements */
.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: #555;
    transition: color 0.3s ease;
}

.form-group input {
    width: 100%;
    padding: 12px 16px;
    border: 2px solid #e1e5e9;
    border-radius: 6px;
    font-size: 16px;
    transition: border-color 0.3s ease, background-color 0.3s ease, color 0.3s ease;
}

.form-group input:focus {
    outline: none;
    border-color: #4facfe;
}

/* Button Styles */
.btn {
    background: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);
    color: white;
    border: none;
    padding: 12px 30px;
    border-radius: 6px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.2s ease, background 0.3s ease, color 0.3s ease;
}

.btn:hover {
    transform: translateY(-2px);
}

.btn:active {
    transform: translateY(0);
}

/* Result Display */
.result {
    margin-top: 20px;
    padding: 20px;
    border-radius: 6px;
    font-size: 1.1rem;
    border: 1px solid;
    transition: background 0.3s ease, color 0.3s ease, border-color 0.3s ease;
}

.result strong, .result span {
    transition: color 0.3s ease; /* Ensure text inside result blocks transition */
}

.result.increase {
    background: #d4edda;
    border-color: #c3e6cb;
    color: #155724;
}

.result.decrease {
    background: #f8d7da;
    border-color: #f5c6cb;
    color: #721c24;
}

.result.equal,
.result.no_change {
    background: #cce7ff;
    border-color: #99d6ff;
    color: #004085;
}

/* Error Messages */
.error {
    background: #f8d7da;
    border: 1px solid #f5c6cb;
    color: #721c24;
    padding: 15px;
    border-radius: 6px;
    margin-bottom: 20px;
    transition: background 0.3s ease, color 0.3s ease, border-color 0.3s ease;
}

/* Market Times Section */
.market-times {
    background: #f8f9fa;
    border-radius: 8px;
    padding: 25px;
    border-left: 4px solid #28a745;
    transition: background 0.3s ease, border-color 0.3s ease;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.market-times h2 {
    color: #2c3e50;
    margin-bottom: 20px;
    transition: color 0.3s ease;
}

/* Market Grid Layout */
.market-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 15px;
}

.market-item {
    background: white;
    padding: 15px;
    border-radius: 6px;
    border-left: 3px solid #28a745;
    transition: transform 0.2s ease, box-shadow 0.2s ease, background 0.3s ease, border-color 0.3s ease;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.05);
}

.market-item:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.market-name {
    font-weight: 600;
    color: #2c3e50;
    margin-bottom: 5px;
    transition: color 0.3s ease;
}

.market-hours {
    color: #666;
    font-family: 'Courier New', monospace;
    font-size: 0.95rem;
    transition: color 0.3s ease;
}

/* Hint Box */
.hint {
    background: #fff3cd;
    border: 1px solid #ffeaa7;
    color: #856404;
    padding: 15px;
    border-radius: 6px;
    margin-top: 15px;
    transition: background 0.3s ease, color 0.3s ease, border-color 0.3s ease;
}

.hint strong {
    color: #6c5ce7;
    transition: color 0.3s ease;
}

.market-extended-hours {
    margin-top: 20px;
    color: #666;
    font-size: 0.9em;
    transition: color 0.3s ease;
}

/* --- Dark Theme Styles --- */
body.theme-dark {
    background: linear-gradient(135deg, #1a1a1a 0%, #2d2d2d 100%);
    color: #e0e0e0;
}

body.theme-dark .container {
    background: #1e1e1e;
    box-shadow: 0 15px 40px rgba(0, 0, 0, 0.5);
}

/* Dark Theme Header Styles */
body.theme-dark .header {
    /* Kontrastfylt palett: Deep Teal, Ruby Red, Forest Green */
    background-color: #004D61; /* Deep Teal */
    color: #f0f0f0; /* Off-White */
    box-shadow: inset 0 -5px 10px rgba(0, 0, 0, 0.3);
}

body.theme-dark .theme-switcher button {
    background-color: #444;
    border-color: #666;
    color: #e0e0e0;
}

body.theme-dark .theme-switcher button.active {
    background-color: #61dafb;
    color: #333;
    border-color: #61dafb;
}
body.theme-dark .theme-switcher button:hover:not(.active) {
    background-color: #555;
}

body.theme-dark .calculator-section,
body.theme-dark .market-times {
    background: #2a2a2a;
    border-left-color: #61dafb;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

body.theme-dark .calculator-section h2,
body.theme-dark .market-times h2 {
    color: #ffffff;
}

body.theme-dark .market-item {
    background: #1e1e1e;
    border-left-color: #50fa7b;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.1);
}

body.theme-dark .market-name {
    color: #ffffff;
}

body.theme-dark .market-hours {
    color: #cccccc;
}

body.theme-dark .form-group label {
    color: #c0c0c0;
}

body.theme-dark .form-group input {
    background-color: #555c66;
    border-color: #666;
    color: #e0e0e0;
}

body.theme-dark .form-group input:focus {
    border-color: #61dafb;
    background: #404040;
}

body.theme-dark .btn {
    background: linear-gradient(135deg, #61dafb 0%, #21a1f1 100%);
    color: #333;
}

body.theme-dark .btn:hover {
    background: linear-gradient(135deg, #21a1f1 0%, #007bff 100%);
}

/* Dark theme results/alerts */
body.theme-dark .result.increase {
    background: #2f5f3e;
    border-color: #4CAF50;
    color: #a9ffb6;
}

body.theme-dark .result.decrease {
    background: #6b2e2e;
    border-color: #DC3545;
    color: #ffb3b3;
}

body.theme-dark .result.equal,
body.theme.dark .result.no_change {
    background: #2e4a6b;
    border-color: #17A2B8;
    color: #a9d9ff;
}

body.theme-dark .error {
    background: #6b2e2e;
    border-color: #DC3545;
    color: #ffb3b3;
}

body.theme-dark .hint {
    background: #5a5a2a;
    border-color: #FFC107;
    color: #ffeb3b;
}

body.theme-dark .hint strong {
    color: inherit; /* Make hint strong text inherit hint block color */
}

body.theme-dark .market-extended-hours {
    color: #c0c0c0; /* Lighter grey for dark mode extended hours */
}

/* Utility Classes */
.text-center { text-align: center; }
.mt-1 { margin-top: 10px; } .mt-2 { margin-top: 20px; }
.mb-1 { margin-bottom: 10px; } .mb-2 { margin-bottom: 20px; }

/* Animations */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}
.result { animation: fadeIn 0.5s ease-out; }
.error { animation: fadeIn 0.3s ease-out; }

/* Focus Styles for Accessibility */
.btn:focus,
.form-group input:focus,
.theme-switcher button:focus {
    box-shadow: 0 0 0 3px rgba(79, 172, 254, 0.3);
    outline: none; /* Remove default outline */
}

/* Loading States */
.loading { opacity: 0.6; pointer-events: none; }
.loading .btn { background: #ccc; cursor: not-allowed; }

/* Responsive Design */
@media (max-width: 768px) {
    body { padding: 10px; }
    .header { padding: 20px; }
    .header h1 { font-size: 2rem; }
    .content { padding: 20px; }
    .calculator-section { padding: 20px; }
    .market-grid { grid-template-columns: 1fr; }
    .form-group input { font-size: 16px; /* Prevents zoom on iOS */ }
}

@media (max-width: 480px) {
    .header h1 { font-size: 1.8rem; }
    .calculator-section { padding: 15px; margin-bottom: 20px; }
    .content { padding: 15px; }
    .btn { width: 100%; padding: 15px; }
}

/* Print Styles */
@media print {
    body { background: white; color: black; }
    .container { box-shadow: none; border: 1px solid #ccc; }
    .header { background: white; color: black; border-bottom: 2px solid #ccc; }
    .btn, .theme-switcher { display: none; } /* Hide buttons and switcher on print */
    .market-item:hover { transform: none; box-shadow: none; }
}

/* High Contrast Mode */
@media (prefers-contrast: high) {
    .container { border: 2px solid #000; }
    .btn { background: #000; border: 2px solid #000; }
    .btn:hover { background: #333; }
    .form-group input { border: 2px solid #000; }
}

/* Reduced Motion */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
    .btn:hover, .market-item:hover { transform: none; }
}
