/* style.css - Padronizado com o layout do Conversor de Escalas e OEE */
: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;
}

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;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
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;
    gap: 1rem;
    max-width: 1600px;
    margin: 0 auto;
}
.site-title { display: flex; flex-direction: column; }
.site-title h1 {
    font-size: 1rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin: 0;
    color: white;
}
.site-title .subtitle {
    font-size: 0.75rem;
    color: rgba(255,255,255,0.85);
    margin-top: 2px;
}

.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 --- */
.app-main {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    padding: 1rem;
    width: 100%;
    max-width: 900px;
    margin: 0 auto;
}

/* --- CARDS --- */
.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;
}
.section-title {
    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 .section-title { color: var(--text); }

.helper-text { font-size: .85rem; color: var(--text-secondary); margin: 0; }
.helper-text.instruction { text-align: center; margin-top: -.5rem; margin-bottom: 1rem; font-style: italic; }

/* --- FORMULÁRIOS E INPUTS --- */
.input-group { 
    display: flex; 
    gap: 1rem; 
    margin-bottom: 1rem; 
}
.input-group.single { 
    flex-direction: column; 
}
.label-wrapper { 
    display: flex; 
    flex-direction: column; 
    gap: .4rem; 
    flex-basis: 70%; 
}
.label-wrapper label { 
    font-size: .8rem; 
    font-weight: 600; 
    color: var(--text-secondary); 
}
.field-pair { 
    display: flex; 
    gap: .5rem; 
    align-items: center; 
}

input[type="number"], 
input[type="text"],
select {
    width: 100%;
    padding: .7rem .85rem;
    border: 2px solid var(--border);
    border-radius: var(--radius-sm);
    background-color: var(--bg);
    color: var(--text);
    font-size: .9rem;
    text-align: center;
    transition: border-color .2s, box-shadow .2s;
}
input[type="number"]:focus, 
input[type="text"]:focus,
select:focus {
    outline: none;
    border-color: var(--cor-destaque);
    box-shadow: 0 0 0 3px rgba(255, 193, 7, 0.15);
}

/* --- BOTÕES --- */
.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: .5rem;
    width: 100%;
}
.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: .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); }

/* --- RESULTADO --- */
.result-container {
    margin: 1.5rem 0 0;
    padding: 1.5rem;
    background-color: var(--bg);
    border: 2px solid var(--primary);
    border-radius: var(--radius-sm);
    text-align: center;
    position: relative;
    min-height: 100px;
    display: flex;
    align-items: center;
    justify-content: center;
}
#result-text {
    font-size: 1.6rem;
    font-weight: 700;
    color: var(--primary);
    margin: 0;
    line-height: 1.2;
    transition: opacity var(--transition);
}

.icon-button {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: var(--primary);
    cursor: pointer;
    padding: 8px;
    border-radius: 50%;
    transition: background var(--transition);
}
.icon-button:hover { background-color: var(--accent-light); }

/* --- REFERÊNCIA --- */
.reference-container {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(140px, 100%), 1fr));
    gap: 1rem;
}
.reference-item {
    background: var(--surface);
    border: 2px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 1rem;
    text-align: center;
    transition: all var(--transition);
    cursor: pointer;
}
.reference-item:hover {
    border-color: var(--primary);
    box-shadow: var(--shadow);
}
.reference-item .fraction {
    font-size: 1.1rem;
    color: var(--primary);
    font-weight: bold;
    margin-bottom: .2rem;
    display: block;
}
.reference-item .mm { font-size: .85rem; color: var(--text-secondary); }

/* --- TOAST --- */
.toast {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    background: var(--primary);
    color: white;
    padding: 1rem 1.5rem;
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow);
    opacity: 0;
    transition: all 0.35s ease;
    z-index: 2000;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* --- FOOTER --- */
.app-footer {
    text-align: center;
    padding: 1rem;
    font-size: .85rem;
    color: var(--text-secondary);
    border-top: 1px solid var(--border);
    margin-top: auto;
}
.copyright { font-weight: 500; margin: 0; }

/* --- ERRO --- */
.erro-container {
    margin-top: 1rem;
    padding: 1rem;
    border-radius: var(--radius-sm);
    border-left: 4px solid var(--cor-erro);
    background-color: rgba(220, 53, 69, 0.1);
    color: var(--text);
    text-align: center;
    font-size: .9rem;
}
.hidden { display: none; }

/* --- RESPONSIVIDADE --- */
@media (max-width: 600px) {
    .input-group { flex-direction: column; }
    .label-wrapper { width: 100%; flex-basis: auto; }
    .site-title h1 { font-size: .9rem; }
    .site-title .subtitle { font-size: .7rem; }
    .reference-container {
        grid-template-columns: repeat(auto-fit, minmax(min(100px, 100%), 1fr));
    }
    .result-container {
        min-height: 80px;
        padding: 1rem;
    }
    #result-text {
        font-size: 1.3rem;
    }
}

@media (min-width: 1024px) {
    .app-main { 
        padding: 1.5rem; 
        gap: 1.5rem; 
    }
}

@media (max-width: 480px) {
    .app-main { padding: 0.5rem; gap: 0.5rem; }
    .card { padding: 1rem; }
    .section-title { font-size: 0.95rem; margin-bottom: 1rem; }
    .header-content { gap: 0.5rem; }
    .site-title h1 { font-size: 0.8rem; }
    .site-title .subtitle { display: none; }
    .switch { width: 40px; height: 22px; }
    .slider:before { height: 16px; width: 16px; }
    input:checked + .slider:before { transform: translateX(18px); }
}
