* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    padding: 20px;
    color: #333;
}

.container {
    max-width: 1600px;
    margin: 0 auto;
    background: rgba(255, 255, 255, 0.95);
    border-radius: 20px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.1);
    overflow: hidden;
}

.header {
    background: linear-gradient(45deg, #4facfe 0%, #00f2fe 100%);
    color: white;
    padding: 30px;
    text-align: center;
}

.header h1 {
    font-size: 2.5em;
    margin-bottom: 10px;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
}

.backend-status {
    background: rgba(255, 255, 255, 0.1);
    padding: 15px;
    border-radius: 10px;
    margin-top: 15px;
    font-size: 0.9em;
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.status-indicator {
    display: inline-block;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    margin-right: 8px;
    animation: pulse 2s infinite;
}

.status-online { 
    background: #4CAF50; 
    box-shadow: 0 0 10px rgba(76, 175, 80, 0.5);
}

.status-offline { 
    background: #f44336; 
    box-shadow: 0 0 10px rgba(244, 67, 54, 0.5);
}

@keyframes pulse {
    0% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.2); opacity: 0.7; }
    100% { transform: scale(1); opacity: 1; }
}

.main-content {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 20px;
    padding: 30px;
}

.section {
    background: white;
    border-radius: 15px;
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.1);
    padding: 25px;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.section:hover {
    transform: translateY(-5px);
    box-shadow: 0 15px 30px rgba(0, 0, 0, 0.15);
}

.section h2 {
    color: #333;
    margin-bottom: 20px;
    padding-bottom: 10px;
    border-bottom: 2px solid #e9ecef;
    font-size: 1.3em;
}

.calculator-display {
    background: linear-gradient(135deg, #1a1a1a 0%, #2d2d2d 100%);
    color: #00ff00;
    padding: 20px;
    border-radius: 10px;
    margin-bottom: 20px;
    font-family: 'Courier New', monospace;
    font-size: 1.5em;
    text-align: right;
    min-height: 80px;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    border: 2px solid #333;
    box-shadow: inset 0 2px 10px rgba(0, 0, 0, 0.3);
    position: relative;
    overflow: hidden;
}

.calculator-display::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.1), transparent);
    animation: scan 3s infinite;
}

@keyframes scan {
    0% { left: -100%; }
    100% { left: 100%; }
}

.calculator-buttons {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 8px;
}

.calc-btn {
    padding: 12px;
    border: none;
    border-radius: 8px;
    font-size: 1em;
    cursor: pointer;
    transition: all 0.3s ease;
    font-weight: bold;
    position: relative;
    overflow: hidden;
}

.calc-btn::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    background: rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    transition: width 0.6s, height 0.6s;
    transform: translate(-50%, -50%);
}

.calc-btn:active::before {
    width: 300px;
    height: 300px;
}

.calc-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
}

.calc-btn.number { 
    background: linear-gradient(135deg, #e3f2fd 0%, #bbdefb 100%); 
    color: #1976d2; 
}

.calc-btn.operator { 
    background: linear-gradient(135deg, #ff9800 0%, #f57c00 100%); 
    color: white; 
}

.calc-btn.function { 
    background: linear-gradient(135deg, #9c27b0 0%, #7b1fa2 100%); 
    color: white; 
}

.calc-btn.special { 
    background: linear-gradient(135deg, #f44336 0%, #d32f2f 100%); 
    color: white; 
}

.tool-tabs {
    display: flex;
    margin-bottom: 20px;
    border-bottom: 2px solid #e9ecef;
    flex-wrap: wrap;
    gap: 5px;
}

.tab-btn {
    padding: 8px 12px;
    border: none;
    background: transparent;
    cursor: pointer;
    font-weight: bold;
    color: #666;
    transition: all 0.3s ease;
    border-bottom: 3px solid transparent;
    font-size: 0.9em;
    border-radius: 5px 5px 0 0;
}

.tab-btn:hover {
    background: rgba(79, 172, 254, 0.1);
    color: #4facfe;
}

.tab-btn.active {
    color: #4facfe;
    border-bottom-color: #4facfe;
    background: rgba(79, 172, 254, 0.05);
}

.tool-content {
    display: none;
    animation: fadeIn 0.3s ease;
}

.tool-content.active {
    display: block;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.input-group {
    margin-bottom: 12px;
}

.input-group label {
    display: block;
    margin-bottom: 5px;
    font-weight: bold;
    color: #555;
    font-size: 0.9em;
}

.input-group input, 
.input-group select, 
.input-group textarea {
    width: 100%;
    padding: 10px;
    border: 2px solid #ddd;
    border-radius: 8px;
    font-size: 0.9em;
    transition: all 0.3s ease;
    background: rgba(255, 255, 255, 0.8);
}

.input-group input:focus, 
.input-group select:focus, 
.input-group textarea:focus {
    outline: none;
    border-color: #4facfe;
    box-shadow: 0 0 0 3px rgba(79, 172, 254, 0.1);
    background: white;
}

.calculate-btn {
    background: linear-gradient(45deg, #4facfe 0%, #00f2fe 100%);
    color: white;
    border: none;
    padding: 12px 20px;
    border-radius: 8px;
    font-size: 1em;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s ease;
    width: 100%;
    margin-top: 10px;
    position: relative;
    overflow: hidden;
}

.calculate-btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
    transition: left 0.5s;
}

.calculate-btn:hover::before {
    left: 100%;
}

.calculate-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(79, 172, 254, 0.3);
}

.result-display {
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    border: 2px solid #e9ecef;
    border-radius: 8px;
    padding: 12px;
    margin-top: 10px;
    font-family: 'Courier New', monospace;
    font-size: 0.9em;
    color: #333;
    min-height: 40px;
    max-height: 200px;
    overflow-y: auto;
    position: relative;
}

.result-display::-webkit-scrollbar {
    width: 6px;
}

.result-display::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 3px;
}

.result-display::-webkit-scrollbar-thumb {
    background: #4facfe;
    border-radius: 3px;
}

.matrix-input {
    display: grid;
    gap: 5px;
    margin-bottom: 10px;
    padding: 10px;
    background: rgba(79, 172, 254, 0.05);
    border-radius: 8px;
    border: 1px solid rgba(79, 172, 254, 0.2);
}

.matrix-row {
    display: flex;
    gap: 5px;
    justify-content: center;
}

.matrix-cell {
    width: 60px;
    padding: 8px;
    text-align: center;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-family: 'Courier New', monospace;
    background: white;
}

.matrix-cell:focus {
    border-color: #4facfe;
    box-shadow: 0 0 0 2px rgba(79, 172, 254, 0.2);
}

.history-item {
    background: linear-gradient(135deg, #f8f9fa 0%, #ffffff 100%);
    border: 1px solid #e9ecef;
    border-radius: 8px;
    padding: 12px;
    margin-bottom: 8px;
    font-size: 0.9em;
    transition: all 0.3s ease;
    border-left: 4px solid #4facfe;
}

.history-item:hover {
    background: linear-gradient(135deg, #e3f2fd 0%, #f8f9fa 100%);
    transform: translateX(5px);
}

.error {
    color: #f44336;
    font-weight: bold;
    background: rgba(244, 67, 54, 0.1);
    padding: 8px;
    border-radius: 4px;
    border-left: 4px solid #f44336;
}

.success {
    color: #4CAF50;
    font-weight: bold;
    background: rgba(76, 175, 80, 0.1);
    padding: 8px;
    border-radius: 4px;
    border-left: 4px solid #4CAF50;
}

.loading {
    opacity: 0.7;
    pointer-events: none;
    position: relative;
}

.loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 20px;
    height: 20px;
    border: 2px solid #4facfe;
    border-top: 2px solid transparent;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    transform: translate(-50%, -50%);
}

@keyframes spin {
    0% { transform: translate(-50%, -50%) rotate(0deg); }
    100% { transform: translate(-50%, -50%) rotate(360deg); }
}

/* Animações de entrada */
.section {
    animation: slideInUp 0.6s ease;
}

.section:nth-child(1) { animation-delay: 0.1s; }
.section:nth-child(2) { animation-delay: 0.2s; }
.section:nth-child(3) { animation-delay: 0.3s; }

@keyframes slideInUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Responsividade */
@media (max-width: 1200px) {
    .main-content {
        grid-template-columns: 1fr 1fr;
    }
    
    .header h1 {
        font-size: 2em;
    }
}

@media (max-width: 768px) {
    body {
        padding: 10px;
    }
    
    .main-content {
        grid-template-columns: 1fr;
        gap: 15px;
        padding: 20px;
    }
    
    .header {
        padding: 20px;
    }
    
    .header h1 {
        font-size: 1.8em;
    }
    
    .calculator-buttons {
        grid-template-columns: repeat(4, 1fr);
    }
    
    .tool-tabs {
        flex-direction: column;
    }
    
    .tab-btn {
        margin-bottom: 5px;
        width: 100%;
    }
    
    .matrix-cell {
        width: 50px;
        padding: 5px;
    }
    
    .section {
        padding: 15px;
    }
}

@media (max-width: 480px) {
    .header h1 {
        font-size: 1.5em;
    }
    
    .calculator-display {
        font-size: 1.2em;
        padding: 15px;
    }
    
    .calc-btn {
        padding: 8px;
        font-size: 0.9em;
    }
    
    .calculate-btn {
        padding: 10px 15px;
        font-size: 0.9em;
    }
}

/* Temas escuros para dispositivos que suportam */
@media (prefers-color-scheme: dark) {
    body {
        background: linear-gradient(135deg, #2c3e50 0%, #34495e 100%);
    }
    
    .container {
        background: rgba(45, 52, 54, 0.95);
        color: #ecf0f1;
    }
    
    .section {
        background: rgba(52, 73, 94, 0.8);
        color: #ecf0f1;
    }
    
    .section h2 {
        color: #ecf0f1;
        border-bottom-color: #5a6c7d;
    }
    
    .input-group input,
    .input-group select,
    .input-group textarea {
        background: rgba(44, 62, 80, 0.8);
        color: #ecf0f1;
        border-color: #5a6c7d;
    }
    
    .result-display {
        background: rgba(44, 62, 80, 0.6);
        color: #ecf0f1;
        border-color: #5a6c7d;
    }
    
    .history-item {
        background: rgba(52, 73, 94, 0.6);
        color: #ecf0f1;
        border-color: #5a6c7d;
    }
}