/* --- FUNDAÇÃO E IDENTIDADE VISUAL --- */
@import url('../../shared/base.css');

:root {
    --bg: #f0f2f5;
    --surface: #ffffff;
    --text: #212529;
    --text-secondary: #6c757d;
    --border: #dee2e6;
    --shadow: 0 2px 8px rgba(0,0,0,0.07);

    --primary: #2563eb;
    --secondary: #003366;
    --cor-destaque: #ffc107;
    --cor-sucesso: #28a745;
    --cor-erro: #dc3545;
    --accent-light: #fff3cd;

    --radius: 12px;
    --radius-sm: 8px;
    --font: 'Segoe UI', system-ui, -apple-system, sans-serif;
    --transition: 0.3s ease;

    /* Cores específicas do círculo de Ohm */
    --cor-primaria: #2563eb;
    --cor-secundaria: #003366;
}

body.dark-theme {
    --bg: #0a1929;
    --surface: #112233;
    --text: #e9ecef;
    --text-secondary: #8696a7;
    --border: #334b61;
    --shadow: 0 1px 3px rgba(0,0,0,0.4);
    --primary: #3b82f6;
}

/* --- ESTILOS GERAIS E LAYOUT --- */
* { box-sizing: border-box; margin: 0; padding: 0; }
body {
    font-family: var(--font);
    background-color: var(--bg);
    color: var(--text);
    line-height: 1.6;
    transition: background-color var(--transition), color var(--transition);
    overflow-x: hidden;
    -webkit-text-size-adjust: 100%;
}
.app-container {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    width: 100%;
}

/* --- HEADER REFINADO --- */
.app-header {
    background: linear-gradient(145deg, #0f172a 0%, #1e3a5f 50%, #1a365d 100%);
    color: white;
    padding: 0.9rem 1rem;
    box-shadow: var(--shadow);
    z-index: 1000;
    position: sticky;
    top: 0;
}
.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    max-width: 1600px;
    margin: 0 auto;
}
.header-content h1 {
    font-size: 1rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin: 0;
}
.theme-switcher {
    display: flex;
    align-items: center;
    gap: .5rem;
}
.switch { position: relative; display: inline-block; width: 50px; height: 26px; }
.switch input { opacity: 0; width: 0; height: 0; }
.slider { position: absolute; cursor: pointer; top: 0; left: 0; right: 0; bottom: 0; background-color: rgba(255,255,255,0.25); transition: .4s; border-radius: 26px; }
.slider:before { position: absolute; content: ""; height: 20px; width: 20px; left: 3px; bottom: 3px; background-color: white; transition: .4s; border-radius: 50%; }
input:checked + .slider { background-color: var(--cor-destaque); }
input:checked + .slider:before { transform: translateX(24px); }

/* --- LAYOUT PRINCIPAL (GRID) --- */
.app-main {
    flex-grow: 1;
    display: grid;
    grid-template-columns: 1fr;
    gap: 1rem;
    padding: 1rem;
    width: 100%;
}
.app-main > * { min-width: 0; }
#inputs-column, #outputs-column {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

/* --- CARDS E TÍTULOS --- */
.card {
    background-color: var(--surface);
    padding: 1.5rem;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
    transition: all var(--transition);
    display: flex;
    flex-direction: column;
}
.card h2 {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--primary);
    margin: 0 0 1.5rem 0;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 0.75rem;
}
body.dark-theme .card h2 { color: var(--text); }

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border);
    margin: 0 0 1rem 0;
    padding-bottom: 0.75rem;
}
.card-header h2 {
    border: none;
    margin: 0;
    padding: 0;
}

.badge {
    background: var(--primary);
    color: white;
    padding: 0.25rem 0.75rem;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
}
body.dark-theme .badge { background: var(--cor-destaque); color: var(--bg); }

/* --- CÍRCULO DE OHM --- */
.ohm-wheel {
    position: relative;
    width: 100%;
    max-width: 420px;
    aspect-ratio: 1 / 1;
    margin: 0 auto;
    transition: transform 0.5s ease;
}
.quadrant {
    position: absolute;
    width: 50%;
    height: 50%;
    border: 4px solid rgba(255,255,255,0.5);
    transition: transform 0.4s cubic-bezier(0.25, 0.8, 0.25, 1), opacity 0.4s ease, filter 0.4s ease;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    text-align: center;
    color: white;
}
.quadrant:hover {
    transform: scale(1.05);
    z-index: 10;
    border-color: white;
}
.quadrant-p { top: 0; left: 0; border-top-left-radius: 100%; background-color: var(--cor-primaria); }
.quadrant-v { top: 0; right: 0; border-top-right-radius: 100%; background-color: var(--cor-secundaria); }
.quadrant-i { bottom: 0; right: 0; border-bottom-right-radius: 100%; background-color: var(--cor-sucesso); }
.quadrant-r { bottom: 0; left: 0; border-bottom-left-radius: 100%; background-color: var(--cor-destaque); }

.ohm-wheel.active .quadrant.active {
    transform: scale(1.1);
    z-index: 20;
    border-color: white;
    box-shadow: 0 0 30px rgba(0,0,0,0.3);
    opacity: 1;
    filter: grayscale(0%);
}
.ohm-wheel.active .quadrant:not(.active) {
    transform: scale(0.95);
    opacity: 0.6;
    filter: grayscale(50%);
}
.quadrant-content h2 {
    font-size: clamp(1.2rem, 5vw, 1.8rem);
    font-weight: 800;
    border: none;
    margin: 0;
    padding: 0;
    color: white;
}
body.dark-theme .quadrant-content h2 { color: white; }
.quadrant-content p {
    font-size: clamp(0.7rem, 3vw, 1rem);
    font-weight: 500;
}

/* --- ANIMAÇÕES --- */
@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}
@keyframes popIn {
    0% { opacity: 0; transform: scale(0.8); }
    80% { opacity: 1; transform: scale(1.05); }
    100% { opacity: 1; transform: scale(1); }
}
.animate-fadeInUp { animation: fadeInUp 0.6s ease-out forwards; }
.animate-popIn { animation: popIn 0.4s ease-out forwards; }

/* --- INPUTS E FORMULÁRIOS --- */
.instruction {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
}
.hidden { display: none !important; }

.input-wrapper {
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}
.input-wrapper label {
    font-size: 1rem;
    color: var(--text);
    font-weight: 600;
    margin-bottom: 0.25rem;
    transition: all 0.2s ease;
}
.input-wrapper:focus-within label { color: var(--secondary); }
.input-icon {
    position: absolute;
    left: 1rem;
    bottom: 1rem;
    color: var(--secondary);
    font-style: normal;
    z-index: 1;
    font-size: 1.1rem;
    pointer-events: none;
}
.styled-input {
    width: 100%;
    padding: 1rem 1rem 1rem 3rem;
    background-color: var(--bg);
    border: 2px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 1rem;
    transition: all 0.2s ease;
    color: var(--text);
}
.styled-input:focus {
    background-color: var(--surface);
    box-shadow: 0 0 0 3px rgba(255, 193, 7, 0.15);
    border-color: var(--cor-destaque);
    outline: none;
}
.input-section {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
    margin: 1rem 0;
}

/* --- BOTÕES --- */
.button-group { display: flex; gap: .75rem; margin-top: auto; padding-top: 1rem; }
.main-button, .secondary-button {
    padding: .85rem;
    border: none;
    border-radius: var(--radius-sm);
    font-size: .9rem;
    font-weight: bold;
    cursor: pointer;
    transition: all var(--transition);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    flex: 1;
}
.main-button {
    background-color: var(--primary);
    color: white;
}
.secondary-button {
    background-color: transparent;
    color: var(--primary);
    border: 2px solid var(--border);
}
body.dark-theme .secondary-button { color: var(--text); }
.main-button:hover { opacity: 0.9; }
.secondary-button:hover { background: var(--bg); }
body.dark-theme .secondary-button:hover { background: var(--border); }
.main-button:active, .secondary-button:active { transform: scale(.98); }

/* --- BOTÕES DE FÓRMULA --- */
.formula-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    justify-content: center;
}
.formula-buttons button {
    padding: 0.6rem 1rem;
    background: rgba(37, 99, 235, 0.08);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--primary);
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    flex: 1;
    min-width: 80px;
    font-family: var(--font);
}
.formula-buttons button:hover {
    background: rgba(37, 99, 235, 0.15);
    border-color: var(--primary);
}
body.dark-theme .formula-buttons button {
    background: rgba(59, 130, 246, 0.15);
    color: var(--text);
}
body.dark-theme .formula-buttons button:hover {
    background: rgba(59, 130, 246, 0.25);
}

/* --- RESULTADO --- */
#result {
    font-size: 1.6rem;
    font-weight: 700;
    color: var(--primary);
    min-height: 40px;
    word-break: break-all;
}
#result span { font-size: 1rem; color: var(--text-secondary); }

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

/* --- RESPONSIVIDADE --- */
@media (min-width: 1024px) {
    .app-main {
        grid-template-columns: 1fr 1fr;
        gap: 1.5rem;
        padding: 1.5rem;
        max-width: 1600px;
        margin: 0 auto;
    }
    #inputs-column, #outputs-column {
        gap: 1.5rem;
    }
}

@media (max-width: 768px) {
    .input-section {
        grid-template-columns: 1fr;
    }
    .formula-buttons {
        flex-direction: column;
    }
    .formula-buttons button {
        width: 100%;
    }
    .ohm-wheel {
        max-width: 280px;
    }
}

@media (max-width: 480px) {
    .ohm-wheel {
        max-width: 200px;
    }
    .quadrant-content h2 {
        font-size: 1.2rem;
    }
    .quadrant-content p {
        font-size: 0.6rem;
    }
    .styled-input {
        font-size: 16px;
        padding: 0.7rem 0.7rem 0.7rem 2.2rem;
    }
    .input-icon {
        left: 0.7rem;
        bottom: 0.7rem;
        font-size: 0.9rem;
    }
    #result {
        font-size: 1.2rem;
    }
    .badge {
        font-size: 0.6rem;
        padding: 0.15rem 0.5rem;
    }
}
