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

body {
    font-family: 'Montserrat', 'Roboto', Arial, sans-serif;
    background: #181a20;
    min-height: 100vh;
    color: #f5f6fa;
    display: flex;
    justify-content: center;
    align-items: center;
    margin: 0;
    padding: 0;
}

/* Estilo específico para iframe */
body.iframe-mode {
    min-height: auto;
    height: 100vh;
    overflow: hidden;
}

body.iframe-mode .scientific-calculator {
    min-height: auto;
    height: 100vh;
    padding: 10px;
}

body.iframe-mode .calculator-header h1 {
    font-size: 1.2rem;
    margin-bottom: 5px;
}

body.iframe-mode .calculator-header p {
    font-size: 0.7rem;
    margin-bottom: 0;
}

body.iframe-mode .calculator-header {
    margin-bottom: 10px;
}

body.iframe-mode .return-section {
    margin-top: 10px;
}

.scientific-calculator {
    min-height: 100vh;
    width: 100%;
    padding: 20px;
    background: linear-gradient(120deg, #23263a 60%, #353866 100%);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
}

.calculator-header {
    text-align: center;
    margin-bottom: 20px;
}

.calculator-header h1 {
    font-size: 1.8rem;
    font-weight: 700;
    margin-bottom: 8px;
    color: #f5f6fa;
}

.calculator-header h1 span {
    color: #ffb347;
}

.calculator-header p {
    font-size: 0.9rem;
    color: #b2becd;
}

.calculator-container {
    display: flex;
    gap: 20px;
    width: 100%;
    max-width: 800px;
    justify-content: center;
    align-items: flex-start;
    flex-wrap: wrap;
}

.calculator {
    background: #23263a;
    border-radius: 20px;
    padding: 20px;
    border: 2px solid #353866;
    box-shadow: 0 10px 40px rgba(0,0,0,0.3);
    width: 100%;
    max-width: 450px;
    min-width: 320px;
}

.display-section {
    margin-bottom: 25px;
}

.memory-indicator {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
    height: 25px;
}

.memory-active {
    background: #ffb347;
    color: #23263a;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 600;
}

.mode-indicators {
    display: flex;
    gap: 10px;
}

.mode-btn {
    background: transparent;
    color: #b2becd;
    border: 1px solid #353866;
    padding: 4px 12px;
    border-radius: 6px;
    font-size: 12px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.mode-btn.active {
    background: #ffb347;
    color: #23263a;
    border-color: #ffb347;
}

.mode-btn:hover {
    background: #353866;
    color: #ffb347;
}

.display {
    background: #181a20;
    border: 2px solid #353866;
    border-radius: 12px;
    padding: 20px;
    text-align: right;
    font-size: 2.2rem;
    font-weight: 700;
    color: #ffb347;
    min-height: 70px;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    word-break: break-all;
    overflow-wrap: break-word;
}

.operation-display {
    text-align: right;
    color: #b2becd;
    font-size: 14px;
    margin-top: 5px;
    min-height: 20px;
}

.button-grid {
    display: grid;
    gap: 8px;
}

.button-grid.standard {
    grid-template-columns: repeat(4, 1fr);
}

.button-grid.scientific {
    grid-template-columns: repeat(5, 1fr);
}

.btn {
    padding: 18px;
    border: none;
    border-radius: 10px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: 'Montserrat', sans-serif;
    min-height: 55px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(0,0,0,0.2);
}

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

.btn.number {
    background: #353866;
    color: #f5f6fa;
    border: 1px solid #4a4e7c;
}

.btn.number:hover {
    background: #4a4e7c;
    box-shadow: 0 4px 15px rgba(255, 179, 71, 0.2);
}

.btn.operation {
    background: #ffb347;
    color: #23263a;
}

.btn.operation:hover {
    background: #fff;
    box-shadow: 0 4px 15px rgba(255, 179, 71, 0.4);
}

.btn.equals {
    background: #ffb347;
    color: #23263a;
    font-size: 24px;
}

.btn.equals:hover {
    background: #fff;
    box-shadow: 0 4px 15px rgba(255, 179, 71, 0.4);
}

.btn.clear {
    background: #ff6b6b;
    color: white;
}

.btn.clear:hover {
    background: #ff5252;
    box-shadow: 0 4px 15px rgba(255, 107, 107, 0.4);
}

.btn.scientific {
    background: #2c3050;
    color: #b2becd;
    font-size: 14px;
    border: 1px solid #353866;
}

.btn.scientific:hover {
    background: #353866;
    color: #ffb347;
    box-shadow: 0 4px 15px rgba(53, 56, 102, 0.3);
}

.btn.memory {
    background: #4a4e7c;
    color: #f5f6fa;
    font-size: 14px;
}

.btn.memory:hover {
    background: #5a5f8c;
    color: #ffb347;
    box-shadow: 0 4px 15px rgba(74, 78, 124, 0.3);
}

.history-panel {
    background: #23263a;
    border-radius: 12px;
    padding: 15px;
    border: 1px solid #353866;
    box-shadow: 0 8px 32px rgba(0,0,0,0.18);
    width: 200px;
    max-height: 300px;
    overflow-y: auto;
    flex-shrink: 0;
}

.history-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
}

.history-header h3 {
    color: #ffb347;
    font-size: 1.2rem;
}

.clear-history {
    background: transparent;
    color: #b2becd;
    border: 1px solid #353866;
    padding: 5px 10px;
    border-radius: 6px;
    font-size: 12px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.clear-history:hover {
    background: #353866;
    color: #ffb347;
}

.history-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.history-item {
    background: #181a20;
    padding: 10px;
    border-radius: 8px;
    font-size: 12px;
    color: #b2becd;
    border: 1px solid #353866;
    word-break: break-all;
}

.return-section {
    margin-top: 20px;
    text-align: center;
}

.return-btn {
    background: transparent;
    color: #b2becd;
    border: 2px solid #353866;
    padding: 8px 16px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    font-family: 'Montserrat', sans-serif;
}

.return-btn:hover {
    background: #353866;
    color: #ffb347;
    border-color: #ffb347;
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(53, 56, 102, 0.4);
}

.calculator-footer {
  text-align: center;
  color: #b2becd;
  margin-top: 2rem;
}

/* Ensure scrollbars work properly */
::-webkit-scrollbar {
    width: 10px;
}
    
::-webkit-scrollbar-track {
    background: #181a20;
}
    
::-webkit-scrollbar-thumb {
    background: #ffb347;
    border-radius: 4px;
}
    
::-webkit-scrollbar-thumb:hover {
    background: #ff8c42;
}

/* Responsividade */
@media (max-width: 1024px) {
    .calculator-container {
        flex-direction: column;
        align-items: center;
        gap: 15px;
    }
    
    .history-panel {
        width: 100%;
        max-width: 450px;
    }
    
    .scientific-calculator {
        padding: 15px;
    }
    
    .calculator-header {
        margin-bottom: 15px;
    }
}

@media (max-width: 768px) {
    .calculator {
        max-width: 100%;
        padding: 15px;
    }
    
    .button-grid.scientific {
        grid-template-columns: repeat(4, 1fr);
    }
    
    .btn {
        padding: 12px;
        font-size: 12px;
        min-height: 45px;
    }
    
    .display {
        font-size: 1.5rem;
        padding: 12px;
        min-height: 55px;
    }
    
    .calculator-header h1 {
        font-size: 1.5rem;
    }
    
    .calculator-header p {
        font-size: 0.8rem;
    }
    
    .return-section {
        margin-top: 15px;
    }
    
    .return-btn {
        padding: 6px 12px;
        font-size: 12px;
    }
    
    .scientific-calculator {
        padding: 10px;
    }
}

@media (max-width: 480px) {
    .button-grid.scientific {
        grid-template-columns: repeat(3, 1fr);
    }
    
    .btn {
        padding: 12px;
        font-size: 12px;
        min-height: 45px;
    }
    
    .display {
        font-size: 1.5rem;
        padding: 12px;
        min-height: 55px;
    }
    
    .btn.scientific {
        font-size: 11px;
    }
    
    .calculator-header h1 {
        font-size: 1.8rem;
    }
}

/* Animações */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.history-item {
    animation: fadeIn 0.3s ease;
}

/* Scrollbar personalizada */
.history-panel::-webkit-scrollbar {
    width: 6px;
}

.history-panel::-webkit-scrollbar-track {
    background: #181a20;
    border-radius: 3px;
}

.history-panel::-webkit-scrollbar-thumb {
    background: #ffb347;
    border-radius: 3px;
}

.history-panel::-webkit-scrollbar-thumb:hover {
    background: #fff;
}