/* 
 * Calculadora Científica Pro - Stylesheet
 * Version: 2.7
 * Última atualização: Densidade ultra alta com 100+ elementos simultâneos
 */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Arial', sans-serif;
    background: linear-gradient(135deg, #1e1e2e 0%, #2e2e4e 100%);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
    transition: background 0.3s ease;
    position: relative;
    overflow: hidden;
}

/* Background animado com elementos matemáticos */
.math-background {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1;
    pointer-events: none;
    overflow: hidden;
}

.math-symbol {
    position: absolute;
    color: #1abc9c;
    font-family: 'Times New Roman', serif;
    font-weight: bold;
    pointer-events: none;
    user-select: none;
    animation: float-drift 8s linear forwards;
    will-change: transform, opacity;
    text-shadow: 
        0 0 10px currentColor,
        0 0 20px currentColor,
        0 0 30px rgba(26, 188, 156, 0.5);
    filter: brightness(1.2);
}

@keyframes float-drift {
    0% {
        opacity: 0;
        transform: translate(0, 0) rotate(0deg) scale(0.7);
        filter: brightness(1) blur(2px);
    }
    5% {
        opacity: 0.18;
        transform: translate(calc(var(--move-x, 20px) * 0.15), calc(var(--move-y, 20px) * 0.15)) rotate(calc(var(--rotation, 30deg) * 0.2)) scale(1);
        filter: brightness(1.3) blur(0px);
    }
    50% {
        opacity: 0.2;
        transform: translate(calc(var(--move-x, 20px) * 0.6), calc(var(--move-y, 20px) * 0.6)) rotate(calc(var(--rotation, 30deg) * 0.7)) scale(1);
        filter: brightness(1.2) blur(0px);
    }
    95% {
        opacity: 0.15;
        transform: translate(var(--move-x, 20px), var(--move-y, 20px)) rotate(var(--rotation, 30deg)) scale(1);
        filter: brightness(1.1) blur(1px);
    }
    100% {
        opacity: 0;
        transform: translate(var(--move-x, 20px), var(--move-y, 20px)) rotate(var(--rotation, 30deg)) scale(0.7);
        filter: brightness(1) blur(3px);
    }
}

/* Variações sutis de duração */
.math-symbol:nth-child(2n) {
    animation-duration: 6s;
}

.math-symbol:nth-child(3n) {
    animation-duration: 9s;
}

.math-symbol:nth-child(4n) {
    animation-duration: 7s;
}

.math-symbol:nth-child(5n) {
    animation-duration: 8s;
}

.math-symbol:nth-child(7n) {
    animation-duration: 10s;
}

/* Tema claro - símbolos mais escuros com brilho ajustado */
body.light-theme .math-symbol {
    color: #2c3e50;
    text-shadow: 
        0 0 8px rgba(44, 62, 80, 0.4),
        0 0 15px rgba(44, 62, 80, 0.3),
        0 0 25px rgba(44, 62, 80, 0.2);
}

/* Garante que o conteúdo fique acima do background */
.main-container {
    position: relative;
    z-index: 10;
}

/* Tema Claro */
body.light-theme {
    background: linear-gradient(135deg, #f5f5f5 0%, #e0e0e0 100%);
}

body.light-theme .calculator,
body.light-theme .history {
    background: #ffffff;
    border-color: #bdc3c7;
}

body.light-theme .title,
body.light-theme .history-title {
    color: #2c3e50;
    text-shadow: none;
}

body.light-theme .display {
    background: #ecf0f1;
    color: #2c3e50;
    border-color: #bdc3c7;
}

body.light-theme .btn-num {
    background: #ecf0f1;
    color: #2c3e50;
}

body.light-theme .btn-num:hover {
    background: #bdc3c7;
}

body.light-theme .btn-op {
    background: #e74c3c;
    color: white;
}

body.light-theme .btn-op:hover {
    background: #c0392b;
}

body.light-theme .btn-special {
    background: #3498db;
}

body.light-theme .btn-special:hover {
    background: #2980b9;
}

body.light-theme .btn-sci {
    background: #27ae60;
}

body.light-theme .btn-sci:hover {
    background: #229954;
}

body.light-theme .btn-equal {
    background: #2ecc71;
    color: white;
}

body.light-theme .btn-equal:hover {
    background: #27ae60;
}

body.light-theme .history-list {
    background: #ecf0f1;
    border-color: #bdc3c7;
}

body.light-theme .history-item {
    background: #ffffff;
    border-left-color: #2c3e50;
    color: #2c3e50;
}

body.light-theme .history-time {
    color: #7f8c8d;
}

body.light-theme .history-calculation {
    color: #34495e;
}

body.light-theme .history-result {
    color: #27ae60;
}

body.light-theme .history-empty {
    color: #95a5a6;
}

body.light-theme .btn-clear-history {
    background: #e74c3c;
}

body.light-theme .btn-clear-history:hover {
    background: #c0392b;
}

body.light-theme .btn-export-history {
    background: #2980b9;
}

body.light-theme .btn-export-history:hover {
    background: #1f618d;
}

body.light-theme .footer {
    color: #7f8c8d;
}

.main-container {
    display: flex;
    gap: 20px;
    width: 100%;
    max-width: 1200px;
    align-items: flex-start;
}

.calculator-container {
    flex: 0 0 auto;
}

.calculator {
    background: #1e1e2e;
    border-radius: 20px;
    padding: 30px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
    border: 2px solid #3e3e5e;
    width: 550px;
}

.title {
    color: #1abc9c;
    text-align: center;
    margin-bottom: 20px;
    font-size: 28px;
    font-weight: bold;
    text-shadow: 0 0 10px rgba(26, 188, 156, 0.5);
}

.display {
    background: #2e2e3e;
    color: #1abc9c;
    font-size: 36px;
    font-weight: bold;
    padding: 30px 20px;
    text-align: right;
    border-radius: 10px;
    margin-bottom: 20px;
    min-height: 80px;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    word-wrap: break-word;
    word-break: break-all;
    border: 3px solid #3e3e5e;
    box-shadow: inset 0 4px 8px rgba(0, 0, 0, 0.3);
}

.buttons {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 10px;
}

.btn {
    padding: 25px;
    font-size: 24px;
    font-weight: bold;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.3);
}

.btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 12px rgba(0, 0, 0, 0.4);
}

.btn:active {
    transform: translateY(0);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

/* Botões numéricos */
.btn-num {
    background: #3e3e5e;
    color: white;
}

.btn-num:hover {
    background: #5e5e7e;
}

/* Botões de operação */
.btn-op {
    background: #ff6b35;
    color: white;
}

.btn-op:hover {
    background: #ff8555;
}

/* Botão especial (Clear) */
.btn-special {
    background: #6b5eff;
    color: white;
}

.btn-special:hover {
    background: #8b7eff;
}

/* Botão igual */
.btn-equal {
    grid-column: 1 / 5;
    background: #1abc9c;
    color: #1e1e2e;
    font-size: 28px;
    padding: 20px;
}

.btn-equal:hover {
    background: #16a085;
}

/* Botão Regra de 3 */
.btn-link {
    text-decoration: none;
    display: block;
    margin-top: 10px;
}

.btn-rule {
    width: 100%;
    padding: 12px;
    font-size: 16px;
    font-weight: bold;
    background: #9b59b6;
    color: white;
}

.btn-rule:hover {
    background: #8e44ad;
}

/* Botão de Tema */
.btn-theme {
    width: 100%;
    padding: 12px;
    font-size: 16px;
    font-weight: bold;
    background: #34495e;
    color: white;
    margin-top: 10px;
}

.btn-theme:hover {
    background: #2c3e50;
}

/* Botões científicos */
.sci-buttons {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 8px;
    margin-bottom: 12px;
}

.btn-sci {
    padding: 12px 8px;
    font-size: 16px;
    font-weight: bold;
    background: #2ecc71;
    color: white;
}

.btn-sci:hover {
    background: #27ae60;
}

.footer {
    color: #95a5a6;
    text-align: center;
    margin-top: 20px;
    font-size: 14px;
}

/* Histórico */
.history-container {
    flex: 1;
    min-width: 300px;
}

.history {
    background: #1e1e2e;
    border-radius: 20px;
    padding: 20px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
    border: 2px solid #3e3e5e;
    height: 650px;
    display: flex;
    flex-direction: column;
}

.history-title {
    color: #1abc9c;
    text-align: center;
    margin-bottom: 15px;
    font-size: 20px;
    font-weight: bold;
    text-shadow: 0 0 10px rgba(26, 188, 156, 0.5);
}

.history-list {
    flex: 1;
    background: #2e2e3e;
    border-radius: 10px;
    padding: 15px;
    overflow-y: auto;
    border: 2px solid #3e3e5e;
    margin-bottom: 15px;
}

.history-list::-webkit-scrollbar {
    width: 10px;
}

.history-list::-webkit-scrollbar-track {
    background: #1e1e2e;
    border-radius: 5px;
}

.history-list::-webkit-scrollbar-thumb {
    background: #6b5eff;
    border-radius: 5px;
}

.history-list::-webkit-scrollbar-thumb:hover {
    background: #8b7eff;
}

.history-item {
    background: #1e1e2e;
    padding: 12px;
    margin-bottom: 10px;
    border-radius: 8px;
    border-left: 4px solid #1abc9c;
    animation: slideIn 0.3s ease;
    color: #ecf0f1;
    font-size: 14px;
    font-family: 'Consolas', monospace;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateX(-10px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.history-time {
    color: #95a5a6;
    font-size: 11px;
    margin-bottom: 5px;
}

.history-calculation {
    color: #ecf0f1;
    font-size: 14px;
    font-family: 'Consolas', monospace;
}

.history-result {
    color: #1abc9c;
    font-weight: bold;
    font-size: 16px;
}

.history-empty {
    color: #95a5a6;
    text-align: center;
    margin-top: 50%;
    transform: translateY(-50%);
}

/* Botões do histórico */
.history-buttons {
    display: flex;
    gap: 10px;
}

.btn-clear-history,
.btn-export-history {
    flex: 1;
    padding: 12px;
    font-size: 16px;
    font-weight: bold;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.3);
}

.btn-clear-history {
    background: #ff6b35;
    color: white;
}

.btn-clear-history:hover {
    background: #ff8555;
    transform: translateY(-2px);
    box-shadow: 0 6px 12px rgba(0, 0, 0, 0.4);
}

.btn-export-history {
    background: #3498db;
    color: white;
}

.btn-export-history:hover {
    background: #5dade2;
    transform: translateY(-2px);
    box-shadow: 0 6px 12px rgba(0, 0, 0, 0.4);
}

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

/* Responsividade */
@media (max-width: 1024px) {
    .main-container {
        flex-direction: column;
        align-items: center;
    }
    
    .history-container {
        width: 100%;
        max-width: 500px;
    }
    
    .history {
        height: 400px;
    }
}

@media (max-width: 600px) {
    .calculator {
        padding: 20px;
        width: 100%;
        max-width: 450px;
    }
    
    .title {
        font-size: 20px;
    }
    
    .display {
        font-size: 28px;
        padding: 20px 15px;
        min-height: 70px;
    }
    
    .sci-buttons {
        gap: 5px;
        margin-bottom: 8px;
    }
    
    .btn-sci {
        padding: 10px 6px;
        font-size: 13px;
    }
    
    .btn {
        padding: 20px;
        font-size: 20px;
    }
    
    .btn-equal {
        font-size: 24px;
        padding: 18px;
    }
    
    .history {
        height: 300px;
    }
}

@media (max-width: 400px) {
    .display {
        font-size: 24px;
    }
    
    .btn {
        padding: 15px;
        font-size: 18px;
    }
}
