/* CSS Custom Properties for Theme Management */
:root {
    /* Light Theme */
    --bg-primary: #f8f9fa;
    --bg-secondary: #ffffff;
    --bg-tertiary: #e9ecef;
    --text-primary: #212529;
    --text-secondary: #6c757d;
    --text-accent: #FF5C33;
    --border-color: #dee2e6;
    --shadow-light: rgba(0, 0, 0, 0.1);
    --shadow-medium: rgba(0, 0, 0, 0.15);
    --shadow-heavy: rgba(0, 0, 0, 0.25);
    
    /* Calculator specific colors */
    --calc-bg: #ffffff;
    --calc-display-bg: #f8f9fa;
    --calc-display-text: #495057;
    --calc-btn-number: #e9ecef;
    --calc-btn-number-text: #212529;
    --calc-btn-operation: #007bff;
    --calc-btn-operation-text: #ffffff;
    --calc-btn-special: #28a745;
    --calc-btn-special-text: #ffffff;
    --calc-btn-clear: #dc3545;
    --calc-btn-clear-text: #ffffff;
}

[data-theme="dark"] {
    /* Dark Theme */
    --bg-primary: #060606;
    --bg-secondary: #111111;
    --bg-tertiary: #1a1a1a;
    --text-primary: #ffffff;
    --text-secondary: #adb5bd;
    --text-accent: #FF5C33;
    --border-color: #343a40;
    --shadow-light: rgba(255, 255, 255, 0.1);
    --shadow-medium: rgba(255, 255, 255, 0.15);
    --shadow-heavy: rgba(255, 255, 255, 0.25);
    
    /* Calculator specific colors - Dark */
    --calc-bg: #000000;
    --calc-display-bg: #111111;
    --calc-display-text: #FFFF66;
    --calc-btn-number: #FFFF66;
    --calc-btn-number-text: #000000;
    --calc-btn-operation: #6666FF;
    --calc-btn-operation-text: #ffffff;
    --calc-btn-special: #66FF66;
    --calc-btn-special-text: #000000;
    --calc-btn-clear: #FF3333;
    --calc-btn-clear-text: #ffffff;
}

/* Font Faces */
@font-face {
    font-family: 'jellyregular';
    src: url('data:font/woff2;base64,') format('woff2');
    font-weight: normal;
    font-style: normal;
    font-display: swap;
}

@font-face {
    font-family: 'kurzetstypekurzetstype';
    src: url('data:font/woff2;base64,') format('woff2');
    font-weight: normal;
    font-style: normal;
    font-display: swap;
}

@font-face {
    font-family: 'arrow_7regular';
    src: url('data:font/woff2;base64,') format('woff2');
    font-weight: normal;
    font-style: normal;
    font-display: swap;
}

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

body {
    background: var(--bg-primary);
    color: var(--text-primary);
    font-family: 'Roboto', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    line-height: 1.6;
    transition: background-color 0.3s ease, color 0.3s ease;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

input, button {
    outline: none;
    border: none;
}

a {
    text-decoration: none;
    color: inherit;
}

/* Modern Header */
.modern-header {
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
    box-shadow: 0 2px 10px var(--shadow-light);
    padding: 1rem 2rem;
    position: sticky;
    top: 0;
    z-index: 1000;
    transition: all 0.3s ease;
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    max-width: 1200px;
    margin: 0 auto;
}

.logo-section {
    flex: 1;
}

.logo-text {
    font-family: 'Orbitron', 'jellyregular', monospace;
    font-size: 2rem;
    font-weight: 900;
    color: var(--text-primary);
    margin: 0;
    text-shadow: 2px 2px 4px var(--shadow-medium);
}

.pro-text {
    color: var(--text-accent);
    margin-left: 0.5rem;
}

.logo-subtitle {
    font-size: 0.875rem;
    color: var(--text-secondary);
    margin-top: 0.25rem;
    font-weight: 300;
}

.header-controls {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.language-selector {
    background: var(--bg-tertiary);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    padding: 0.5rem 1rem;
    border-radius: 25px;
    font-size: 0.875rem;
    cursor: pointer;
    transition: all 0.3s ease;
}

.language-selector:hover {
    background: var(--bg-primary);
    transform: translateY(-1px);
}

.theme-toggle {
    background: var(--bg-tertiary);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    width: 50px;
    height: 50px;
    border-radius: 50%;
    cursor: pointer;
    position: relative;
    overflow: hidden;
    transition: all 0.3s ease;
}

.theme-toggle:hover {
    background: var(--text-accent);
    color: white;
    transform: scale(1.1);
}

.theme-toggle i {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    transition: all 0.3s ease;
}

.theme-toggle .fa-moon {
    opacity: 0;
    transform: translate(-50%, -50%) rotate(180deg);
}

[data-theme="dark"] .theme-toggle .fa-sun {
    opacity: 0;
    transform: translate(-50%, -50%) rotate(-180deg);
}

[data-theme="dark"] .theme-toggle .fa-moon {
    opacity: 1;
    transform: translate(-50%, -50%) rotate(0deg);
}

/* History Sidebar */
.history-sidebar {
    position: fixed;
    left: -350px;
    top: 0;
    width: 350px;
    height: 100vh;
    background: var(--bg-secondary);
    border-right: 1px solid var(--border-color);
    box-shadow: 2px 0 10px var(--shadow-medium);
    transition: left 0.3s ease;
    z-index: 99999;
    overflow-y: auto;
}

.history-sidebar.open {
    left: 0;
}

.sidebar-header {
    padding: 1.5rem;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--bg-tertiary);
}

.sidebar-header h3 {
    font-family: 'Orbitron', sans-serif;
    font-weight: 700;
    color: var(--text-primary);
    margin: 0;
}

.clear-history-btn {
    background: var(--calc-btn-clear);
    color: var(--calc-btn-clear-text);
    border: none;
    padding: 0.5rem 1rem;
    border-radius: 20px;
    cursor: pointer;
    font-size: 0.875rem;
    transition: all 0.3s ease;
}

.clear-history-btn:hover {
    background: #c82333;
    transform: scale(1.05);
}

.history-list {
    padding: 1rem;
}

.no-history {
    text-align: center;
    color: var(--text-secondary);
    font-style: italic;
    padding: 2rem 1rem;
}

.history-item {
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    padding: 1rem;
    margin-bottom: 0.75rem;
    transition: all 0.3s ease;
}

.history-item:hover {
    background: var(--bg-primary);
    transform: translateX(5px);
}

.history-expression {
    font-family: 'kurzetstypekurzetstype', monospace;
    font-size: 1.1rem;
    color: var(--text-primary);
    margin-bottom: 0.5rem;
}

.history-result {
    font-family: 'kurzetstypekurzetstype', monospace;
    font-size: 1rem;
    color: var(--text-accent);
    margin-bottom: 0.75rem;
}

.history-actions {
    display: flex;
    gap: 0.5rem;
}

.history-btn {
    background: var(--calc-btn-operation);
    color: var(--calc-btn-operation-text);
    border: none;
    padding: 0.25rem 0.75rem;
    border-radius: 15px;
    cursor: pointer;
    font-size: 0.75rem;
    transition: all 0.3s ease;
}

.history-btn:hover {
    background: #0056b3;
    transform: scale(1.05);
}

.sidebar-toggle {
    position: fixed;
    left: 20px;
    top: 300px;
    width: 50px;
    height: 50px;
    background: var(--text-accent);
    color: white;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    z-index: 998;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px var(--shadow-medium);
}

.sidebar-toggle:hover {
    background: #e5531f;
    transform: scale(1.1);
}

.sidebar-toggle.hidden {
    left: 370px;
}

/* Main Content */
.main-content {
    flex: 1;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 2rem;
    transition: margin-left 0.3s ease;
}

.main-content.shifted {
    margin-left: 350px;
}

/* Calculator Styles */
#contenedor {
    position: relative;
    background: var(--calc-bg);
    margin: 0 auto;
    opacity: 1;
    box-sizing: border-box;
    transition: all 0.3s ease;
    border-radius: 20px;
    box-shadow: 0 10px 30px var(--shadow-heavy);
    padding: 2rem;
    max-width: 500px;
    width: 100%;
}

#display {
    box-sizing: border-box;
    background: var(--calc-display-bg);
    color: var(--calc-display-text);
    text-align: right;
    margin: 0 0 1.5rem 0;
    width: 100%;
    padding: 1.5rem;
    font-family: 'kurzetstypekurzetstype', 'Orbitron', monospace;
    overflow: hidden;
    border-radius: 15px;
    border: 2px solid var(--border-color);
    font-size: 2rem;
    min-height: 80px;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    transition: all 0.3s ease;
}

#dondetodosucede {
    position: relative;
    background: transparent;
    margin: 0 auto;
    overflow: hidden;
    border-radius: 15px;
    height: 400px;
}

#teclado {
    position: absolute;
    top: 0;
    background: transparent;
    width: 100%;
    height: 100%;
    transition: top 0.5s ease;
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    grid-template-rows: repeat(5, 1fr);
    gap: 0.5rem;
}

#teclado button {
    border: none;
    border-radius: 12px;
    text-align: center;
    cursor: pointer;
    font-family: 'Orbitron', 'jellyregular', sans-serif;
    font-weight: 600;
    font-size: 1.2rem;
    transition: all 0.2s ease;
    box-shadow: 0 4px 8px var(--shadow-light);
    position: relative;
    overflow: hidden;
}

#teclado button:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 12px var(--shadow-medium);
}

#teclado button:active {
    transform: translateY(0);
    box-shadow: 0 2px 4px var(--shadow-light);
}

#teclado button::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.3), transparent);
    transition: left 0.5s ease;
}

#teclado button:hover::before {
    left: 100%;
}

#teclado button:disabled {
    background: #333 !important;
    color: #555 !important;
    cursor: not-allowed;
    transform: none !important;
    box-shadow: none !important;
}

/* Button specific styles */
#tpan {
    grid-column: span 2;
    background: var(--calc-btn-operation);
    color: var(--calc-btn-operation-text);
    font-size: 0.9rem;
}

#tcal {
    background: var(--calc-btn-special);
    color: var(--calc-btn-special-text);
}

#t1, #t2, #t3, #t4, #t5, #t6, #t7, #t8, #t9, #t0, #tcom {
    background: var(--calc-btn-number);
    color: var(--calc-btn-number-text);
}

#t0 {
    grid-column: span 2;
}

#tmas, #tmen, #tpor, #tdiv, #tdive, #tc, #tdel, #tpri, #trai {
    background: var(--calc-btn-operation);
    color: var(--calc-btn-operation-text);
}

#tc {
    background: var(--calc-btn-clear);
    color: var(--calc-btn-clear-text);
}

/* Output section */
#salida {
    position: absolute;
    top: -100%;
    background: var(--calc-display-bg);
    width: 100%;
    height: 100%;
    transition: top 0.5s ease;
    box-sizing: border-box;
    overflow-y: auto;
    padding: 1rem;
    border-radius: 15px;
    border: 2px solid var(--border-color);
}

#divvolver {
    position: absolute;
    top: -100%;
    background: transparent;
    width: 100%;
    height: 20%;
    transition: top 0.5s ease;
    box-sizing: border-box;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem;
}

#salida p, #salida span {
    color: var(--calc-display-text);
    font-family: 'kurzetstypekurzetstype', monospace;
    font-size: 1.2rem;
    margin-bottom: 0.5rem;
}

#volver {
    display: inline-block;
    font-family: 'arrow_7regular', 'Orbitron', sans-serif;
    box-sizing: border-box;
    border: none;
    color: var(--text-secondary);
    background: rgba(255, 255, 255, 0.1);
    text-align: center;
    cursor: pointer;
    padding: 0.5rem 1rem;
    border-radius: 10px;
    font-size: 1.5rem;
    transition: all 0.3s ease;
}

#volver:hover {
    background: var(--text-accent);
    color: white;
}

#botexp, #botnor {
    display: none;
    text-align: center;
    font-family: 'jellyregular', sans-serif;
    box-sizing: border-box;
    border: none;
    color: var(--text-secondary);
    background: rgba(255, 255, 255, 0.1);
    text-align: center;
    cursor: pointer;
    padding: 0.5rem 1rem;
    border-radius: 10px;
    font-size: 0.8rem;
    transition: all 0.3s ease;
}

#botexp:hover, #botnor:hover {
    background: var(--text-accent);
    color: white;
}

.perror {
    text-align: center;
    margin: 2rem 1rem;
    color: var(--calc-btn-clear);
    font-weight: 500;
}

/* Modern Footer */
.modern-footer {
    background: var(--bg-secondary);
    border-top: 1px solid var(--border-color);
    padding: 1.5rem 2rem;
    margin-top: auto;
}

.footer-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    max-width: 1200px;
    margin: 0 auto;
    flex-wrap: wrap;
    gap: 1rem;
}

.footer-left p {
    color: var(--text-secondary);
    font-size: 0.875rem;
    margin: 0;
}

.footer-right {
    display: flex;
    gap: 2rem;
    align-items: center;
}

.footer-link {
    color: var(--text-secondary);
    font-size: 0.875rem;
    transition: color 0.3s ease;
}

.footer-link:hover {
    color: var(--text-accent);
}

/* Responsive Design */
@media (max-width: 768px) {
    .modern-header {
        padding: 1rem;
    }
    
    .header-content {
        flex-direction: column;
        gap: 1rem;
        text-align: center;
    }
    
    .logo-text {
        font-size: 1.5rem;
    }
    
    .history-sidebar {
        width: 300px;
        left: -300px;
    }
    
    .sidebar-toggle.hidden {
        left: 320px;
    }
    
    .main-content.shifted {
        margin-left: 300px;
    }
    
    .main-content {
        padding: 1rem;
    }
    
    #contenedor {
        padding: 1rem;
        margin: 0;
        border-radius: 15px;
    }
    
    #display {
        font-size: 1.5rem;
        padding: 1rem;
        min-height: 60px;
    }
    
    #teclado button {
        font-size: 1rem;
    }
    
    .footer-content {
        flex-direction: column;
        text-align: center;
        gap: 1rem;
    }
    
    .footer-right {
        flex-direction: column;
        gap: 1rem;
    }
}

@media (max-width: 480px) {
    .history-sidebar {
        width: 280px;
        left: -280px;
    }
    
    .sidebar-toggle.hidden {
        left: 300px;
    }
    
    .main-content.shifted {
        margin-left: 280px;
    }
    
    .logo-text {
        font-size: 1.2rem;
    }
    
    .header-controls {
        flex-direction: row;
        gap: 0.5rem;
    }
    
    .sidebar-toggle {
    position: fixed;
    left: 0px;
    top: 300px;
    width: 30px;
    height: 30px;
    background: var(--text-accent);
    color: white;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    z-index: 998;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px var(--shadow-medium);
    }

    #dondetodosucede {
        height: 350px;
    }
    
    #teclado button {
        font-size: 0.9rem;
    }
    
    #display {
        font-size: 1.2rem;
    }
}

/* Animation Classes */
.fade-in {
    animation: fadeIn 0.5s ease-in;
}

.slide-in-left {
    animation: slideInLeft 0.3s ease-out;
}

.bounce {
    animation: bounce 0.6s ease;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes slideInLeft {
    from { transform: translateX(-100%); }
    to { transform: translateX(0); }
}

@keyframes bounce {
    0%, 20%, 60%, 100% { transform: translateY(0); }
    40% { transform: translateY(-10px); }
    80% { transform: translateY(-5px); }
}

/* Accessibility */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* Focus styles for accessibility */
button:focus-visible, select:focus-visible {
    outline: 3px solid var(--text-accent);
    outline-offset: 2px;
}

/* Visual Algorithm Display Elements */
.caja, .caja2, .caja3, .caja4 {
    position: absolute;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    color: var(--calc-display-text);
    font-family: 'kurzetstypekurzetstype', monospace;
    font-weight: bold;
    text-align: center;
    box-sizing: border-box;
}

.caja {
    color: #999;
}

.caja2 {
    color: var(--text-accent);
    background: rgba(255, 255, 255, 0.05);
}

.caja3 {
    color: var(--calc-display-text);
}

.caja4 {
    color: var(--calc-display-text);
    background: rgba(255, 255, 255, 0.03);
}
/* ---------------------------------------------------------------------
 * Hero Section Styles
 * The hero area introduces the calculator with a bold heading and
 * supporting text.  We improve readability on both light and dark
 * themes by using a subtle gradient and clear typography.
 * ------------------------------------------------------------------- */
.hero-section {
    background: linear-gradient(180deg, #000000 0%, #060606 100%);
    color: #f5f5f5;
    padding: 4rem 2rem;
    text-align: center;
    font-family: 'Segoe UI', sans-serif;
    border-bottom: 1px solid #222;
}

.hero-section h1 {
    font-size: 2.5rem;
    margin-bottom: 1rem;
    color: #fdf94f;
    line-height: 1.2;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.4);
}

.hero-section p {
    font-size: 1.125rem;
    max-width: 800px;
    margin: 0 auto 2rem auto;
    line-height: 1.7;
    color: #cccccc;
}

/* ---------------------------------------------------------------------
 * Feature Grid and Cards
 * A responsive grid showcasing key calculator features.  Each card
 * incorporates an icon wrapped in a coloured circle, a heading and
 * explanatory text.  Subtle shadows and hover lifts add depth.
 * ------------------------------------------------------------------- */
.feature-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 2rem;
    margin-top: 3rem;
}

.feature-box {
    background: #111111;
    border: 1px solid #222;
    border-radius: 15px;
    padding: 2rem;
    text-align: left;
    color: #e5e5e5;
    box-shadow: 0 4px 8px rgba(0,0,0,0.2);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
}

.feature-box:hover {
    transform: translateY(-6px);
    box-shadow: 0 8px 16px rgba(0,0,0,0.4);
}

.feature-icon {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background: #fdf94f;
    color: #060606;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.8rem;
    margin-bottom: 1rem;
}

.feature-box h2 {
    font-size: 1.25rem;
    margin-bottom: 0.5rem;
    color: #fdf94f;
    font-weight: 600;
}

.feature-box p {
    font-size: 1rem;
    line-height: 1.6;
    color: #cccccc;
    margin: 0;
}

/* ---------------------------------------------------------------------
 * How-To and FAQ Sections
 * Provide guidance and answers with spacious layouts.  Ordered lists
 * display numbers inside accent-coloured circles for improved legibility.
 * ------------------------------------------------------------------- */
.how-to-section,
.faq-section {
    background: #050505;
    color: #eaeaea;
    padding: 4rem 2rem;
    font-family: 'Segoe UI', sans-serif;
    max-width: 1000px;
    margin: 0 auto;
    line-height: 1.8;
    border-top: 1px solid #222;
}

.how-to-section h2,
.faq-section h2 {
    font-size: 2rem;
    color: #fdf94f;
    margin-bottom: 2rem;
    text-align: center;
}

.how-to-section ol {
    counter-reset: step;
    list-style: none;
    padding-left: 0;
    font-size: 1.1rem;
}

.how-to-section ol li {
    position: relative;
    padding-left: 3rem;
    margin-bottom: 1rem;
    color: #cccccc;
}

.how-to-section ol li::before {
    content: counter(step);
    counter-increment: step;
    position: absolute;
    left: 0;
    top: 0.1rem;
    width: 2rem;
    height: 2rem;
    line-height: 2rem;
    background: #fdf94f;
    color: #060606;
    border-radius: 50%;
    font-weight: bold;
    text-align: center;
}

.faq h3 {
    font-size: 1.2rem;
    color: #fdf94f;
    margin-top: 1.5rem;
    margin-bottom: 0.5rem;
}

.faq p {
    font-size: 0.95rem;
    color: #cccccc;
    margin-bottom: 1.5rem;
    line-height: 1.6;
}

