:root {
    --bg-color: #0f172a;
    --card-bg: rgba(30, 41, 59, 0.7);
    --card-border: rgba(255, 255, 255, 0.1);
    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    --primary: #3b82f6;
    --primary-hover: #2563eb;
    --accent: #10b981;
    
    --color-a: #fbbf24;
    --color-b: #ec4899;
    --color-res: #34d399;

    --font-main: 'Outfit', sans-serif;
}

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

body {
    font-family: var(--font-main);
    background: radial-gradient(circle at top left, #1e1b4b, var(--bg-color));
    color: var(--text-main);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 2rem;
}

.app-container {
    max-width: 1200px;
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 2rem;
}

header {
    text-align: center;
}

header h1 {
    font-size: 2.5rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
    background: linear-gradient(to right, #38bdf8, #818cf8);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

header p {
    color: var(--text-muted);
    font-size: 1.1rem;
}

main {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 2rem;
    align-items: start;
}

/* Cards */
.complex-card, .operations-card, .result-card, .graph-card {
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: 1rem;
    padding: 1.5rem;
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
    margin-bottom: 1.5rem;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.complex-card:hover, .operations-card:hover, .result-card:hover, .graph-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 15px 35px rgba(0, 0, 0, 0.3);
}

h2 {
    font-size: 1.2rem;
    font-weight: 600;
    margin-bottom: 1rem;
    color: #e2e8f0;
    border-bottom: 1px solid var(--card-border);
    padding-bottom: 0.5rem;
}

/* Inputs */
.input-group-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}

.input-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    flex: 1;
}

.input-group label {
    font-size: 0.85rem;
    color: var(--text-muted);
}

.inputs {
    display: flex;
    align-items: baseline;
    justify-content: center;
    gap: 0.25rem;
    background: rgba(0, 0, 0, 0.2);
    padding: 0.5rem 0.75rem;
    border-radius: 0.5rem;
    border: 1px solid transparent;
    transition: border-color 0.3s;
}

.inputs:focus-within {
    border-color: var(--primary);
}

input[type="number"] {
    background: transparent;
    border: none;
    color: var(--text-main);
    font-family: var(--font-main);
    font-size: 1.1rem;
    width: 70px;
    outline: none;
    text-align: center;
    padding: 0;
}

input[type="number"]::placeholder {
    color: rgba(255, 255, 255, 0.2);
    font-size: 0.95rem;
}

/* Quitar flechas de los input number */
input[type=number]::-webkit-inner-spin-button, 
input[type=number]::-webkit-outer-spin-button { 
  -webkit-appearance: none; 
  margin: 0; 
}
input[type=number] {
    -moz-appearance: textfield;
}

.math-op {
    color: var(--primary);
    font-weight: 600;
    white-space: nowrap;
    display: inline-flex;
    align-items: center;
}

.sign-btn {
    cursor: pointer;
    user-select: none;
    padding: 0 4px;
    border-radius: 4px;
    transition: background 0.2s, color 0.2s;
}

.sign-btn:hover {
    background: rgba(59, 130, 246, 0.2);
    color: #60a5fa;
}

.separator {
    color: var(--text-muted);
    font-size: 0.9rem;
    font-style: italic;
}

/* Buttons */
.button-group {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1rem;
}

.op-btn {
    background: rgba(59, 130, 246, 0.1);
    color: var(--primary);
    border: 1px solid rgba(59, 130, 246, 0.3);
    padding: 0.75rem 0;
    border-radius: 0.5rem;
    font-family: var(--font-main);
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.op-btn:hover, .op-btn.active {
    background: var(--primary);
    color: white;
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.4);
    transform: scale(1.02);
}

.op-btn:active {
    transform: scale(0.98);
}

.reset-btn {
    background: rgba(239, 68, 68, 0.1);
    color: #ef4444;
    border: 1px solid rgba(239, 68, 68, 0.3);
    padding: 0.4rem 0.8rem;
    border-radius: 0.5rem;
    font-family: var(--font-main);
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.reset-btn:hover {
    background: #ef4444;
    color: white;
    box-shadow: 0 4px 12px rgba(239, 68, 68, 0.4);
    transform: scale(1.05);
}

.reset-btn:active {
    transform: scale(0.95);
}

/* Result */
.result-display {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    background: rgba(0, 0, 0, 0.2);
    padding: 1.5rem;
    border-radius: 0.5rem;
}

.res-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.res-label {
    color: var(--text-muted);
}

.res-value {
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--accent);
    letter-spacing: 1px;
}

/* Graph */
.graph-panel {
    display: flex;
    flex-direction: column;
    height: 100%;
}

.graph-card {
    flex: 1;
    display: flex;
    flex-direction: column;
    margin-bottom: 0;
}

.canvas-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    position: relative;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 0.5rem;
    padding: 1rem;
    overflow: hidden;
}

canvas {
    max-width: 100%;
    height: auto;
    border-radius: 4px;
    cursor: crosshair;
}

.graph-legend {
    display: flex;
    gap: 1.5rem;
    margin-top: 1rem;
    font-size: 0.9rem;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.color-box {
    width: 12px;
    height: 12px;
    border-radius: 3px;
    display: inline-block;
}

.a-color { background-color: var(--color-a); }
.b-color { background-color: var(--color-b); }
.res-color { background-color: var(--color-res); }

/* Responsive */
@media (max-width: 900px) {
    main {
        grid-template-columns: 1fr;
    }
    
    .input-group-row {
        flex-direction: column;
        align-items: stretch;
    }
    
    .separator {
        text-align: center;
        margin: -0.5rem 0;
    }
}
