/* Matador de scrollbars */
* { box-sizing: border-box; }

:root {
    --bg-dark: #0f172a; 
    --panel-bg: #1e293b;
    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    --accent-color: #00ffcc; 
    --akiz-green: #00ffcc;
    --danger: #ef4444;
    --border-color: #334155;
}

body {
    margin: 0;
    background-color: var(--bg-dark);
    color: var(--text-main);
    font-family: 'Inter', sans-serif;
    height: 100vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* --- BARRA SUPERIOR --- */
.top-bar {
    height: 55px;
    background-color: var(--panel-bg);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 20px;
    z-index: 10;
}

.logo-akiz { color: var(--akiz-green); font-weight: 800; font-size: 1.2rem; }
.logo-calc { color: var(--accent-color); font-weight: 800; font-size: 1.2rem; transition: color 0.3s; }

.actions-area { display: flex; gap: 15px; }

.btn-icon { 
    background: transparent; color: var(--text-main); border: 1px solid var(--border-color); 
    padding: 8px 12px; border-radius: 6px; cursor: pointer; font-size: 13px;
}
.btn-icon.primary { background: var(--accent-color); color: #000; border: none; font-weight: bold; }

/* --- LAYOUT GRID --- */
.app-layout {
    display: grid;
    grid-template-columns: 320px 1fr 280px;
    flex: 1;
    overflow: hidden;
}

.panel { background-color: var(--panel-bg); padding: 20px; display: flex; flex-direction: column; gap: 12px; overflow-y: auto; overflow-x: hidden; }
.tools-panel { border-right: 1px solid var(--border-color); }
.theory-panel { border-left: 1px solid var(--border-color); }

h2 { font-size: 0.75rem; text-transform: uppercase; color: var(--text-muted); letter-spacing: 1px; margin: 10px 0 5px; }

.list-header { display: flex; justify-content: space-between; align-items: center; border-bottom: 1px solid var(--border-color); padding-bottom: 10px; margin-bottom: 10px; }
.btn-icon-small { background: transparent; border: 1px solid var(--akiz-green); color: var(--akiz-green); padding: 4px 10px; border-radius: 4px; font-weight: bold; font-size: 11px; cursor: pointer; }

/* --- INPUTS --- */
.input-group { display: flex; flex-direction: column; gap: 10px; }
input[type="text"], input[type="number"], textarea {
    background: var(--bg-dark); border: 1px solid var(--border-color); color: #fff; 
    padding: 12px; border-radius: 6px; width: 100%; font-family: monospace;
}
textarea { flex-grow: 1; resize: none; font-family: 'Inter', sans-serif; }
textarea:disabled { opacity: 0.5; cursor: not-allowed; border-color: transparent;}

.btn-primary { background: var(--accent-color); color: #000; border: none; padding: 12px; border-radius: 6px; font-weight: 600; cursor: pointer; }
.btn-danger { background: transparent; border: 1px solid var(--danger); color: var(--danger); padding: 10px; border-radius: 6px; cursor: pointer; margin-top: auto; }

/* --- CAMADAS (LAYERS) --- */
.layer-item {
    background: var(--bg-dark); padding: 12px; border-radius: 8px; display: flex; flex-direction: column; gap: 10px;
    border-left: 4px solid var(--accent-color); transition: 0.2s; margin-bottom: 8px;
}
.layer-item.ativo { background: #1e293b; border-right: 2px solid var(--accent-color); box-shadow: 0 4px 15px rgba(0,0,0,0.3); }
.layer-header { display: flex; justify-content: space-between; align-items: center; }
.layer-info { flex-grow: 1; cursor: pointer; font-family: monospace; font-size: 14px; font-weight: bold; color: #fff; }
.layer-controls { display: flex; align-items: center; gap: 10px; }

/* --- BOLINHA DE COR --- */
input[type="color"].color-circle {
    -webkit-appearance: none; width: 24px; height: 24px; border: none; background: transparent; cursor: pointer; padding: 0;
}
input[type="color"].color-circle::-webkit-color-swatch-wrapper { padding: 0; }
input[type="color"].color-circle::-webkit-color-swatch { border: 2px solid var(--border-color); border-radius: 50%; }

/* TOGGLE ESTILO iOS */
.switch { position: relative; display: inline-block; width: 40px; height: 22px; }
.switch input { opacity: 0; width: 0; height: 0; }
.slider { position: absolute; cursor: pointer; top: 0; left: 0; right: 0; bottom: 0; background-color: #334155; transition: .4s; border-radius: 22px; }
.slider:before { position: absolute; content: ""; height: 16px; width: 16px; left: 3px; bottom: 3px; background-color: white; transition: .4s; border-radius: 50%; }
input:checked + .slider { background-color: var(--layer-color, var(--accent-color)); }
input:checked + .slider:before { transform: translateX(18px); }

/* --- GRÁFICO --- */
.stage { background-color: var(--bg-dark); padding: 0; display: flex; }
.graph-container { flex: 1; width: 100%; height: 100%; }
.graph-container svg { background-color: var(--bg-dark) !important; }
.graph-container .domain, .graph-container .tick line { stroke: #1e293b !important; }
.graph-container .tick text { fill: #64748b !important; font-family: 'Inter', sans-serif;}
.graph-container .origin { stroke: #475569 !important; stroke-width: 1.5px; }

/* --- TOOLTIPS, INTEGRAL E LIMITES --- */
.header-with-icon { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.info-tooltip { position: relative; cursor: help; }
.info-icon { width: 16px; height: 16px; border-radius: 50%; border: 1px solid var(--text-muted); color: var(--text-muted); display: flex; justify-content: center; align-items: center; font-size: 11px; font-weight: bold; }
.tooltip-text {
    visibility: hidden; opacity: 0; width: 250px; background-color: var(--panel-bg); color: var(--text-main); 
    padding: 12px; border-radius: 6px; position: absolute; z-index: 100; bottom: 150%; left: 50%; margin-left: -125px;
    font-size: 12px; border: 1px solid var(--border-color); transition: 0.3s; box-shadow: 0 5px 15px rgba(0,0,0,0.5); line-height: 1.4;
}
.info-tooltip:hover .tooltip-text { visibility: visible; opacity: 1; }

.tool-card { background: var(--bg-dark); border: 1px solid var(--border-color); padding: 15px; border-radius: 8px; }
.tool-option { display: flex; justify-content: space-between; align-items: center; font-weight: 600; font-size: 13px; }
.tool-card.disabled { opacity: 0.3; pointer-events: none; }

.derivative-def { margin-top: 10px; padding-top: 10px; border-top: 1px dashed var(--border-color); font-family: monospace; font-size: 13px; color: var(--layer-color, var(--accent-color)); display: none; }

.integral-controls { margin-top: 15px; display: none; }
.range-inputs { display: flex; gap: 10px; }
.input-field { display: flex; flex-direction: column; gap: 5px; flex: 1; }
.input-field label { font-size: 10px; text-transform: uppercase; color: var(--text-muted); }
.input-field input { padding: 8px; font-size: 12px; }

.integral-result {
    margin-top: 15px; padding: 12px; background: rgba(0, 0, 0, 0.2); border: 1px solid var(--border-color);
    border-radius: 6px; font-family: monospace; font-size: 15px; font-weight: bold; color: var(--layer-color, var(--accent-color));
    text-align: center; box-shadow: inset 0 2px 4px rgba(0,0,0,0.3);
}

.limit-result {
    margin-top: 15px; padding: 10px; background: rgba(0, 0, 0, 0.2); border: 1px solid var(--border-color);
    border-radius: 6px; font-family: monospace; font-size: 12px; color: var(--text-main);
    line-height: 1.6; box-shadow: inset 0 2px 4px rgba(0,0,0,0.3);
}
.limit-row { display: flex; justify-content: space-between; }
.limit-val { color: var(--layer-color, var(--accent-color)); font-weight: bold; }
.limit-final { margin-top: 8px; padding-top: 8px; border-top: 1px dashed var(--border-color); font-weight: bold; text-align: center; font-size: 13px;}