@import url('../../shared/base.css');

:root {
    --bg: #f1f5f9;
    --surface: #ffffff;
    --text: #0f172a;
    --text-secondary: #64748b;
    --border: #e2e8f0;
    --shadow: 0 1px 3px rgba(0,0,0,.06);
    --shadow-lg: 0 10px 25px rgba(0,0,0,.1);
    --primary: #2563eb;
    --secondary: #003366;
    --accent: #3b82f6;
    --cor-destaque: #f59e0b;
    --cor-sucesso: #28a745;
    --cor-erro: #dc3545;
    --radius: 16px;
    --radius-sm: 10px;
    --font: 'Inter',-apple-system,BlinkMacSystemFont,sans-serif;
    --transition: .3s ease;
    --touch-target: 48px;
}

body.dark-theme {
    --bg: #0a1929;
    --surface: #112233;
    --text: #e9ecef;
    --text-secondary: #8696a7;
    --border: #334b61;
    --shadow: 0 1px 3px rgba(0,0,0,.4);
    --shadow-lg: 0 10px 25px rgba(0,0,0,.3);
    --primary: #3b82f6;
    --accent: #60a5fa;
    --cor-destaque: #fbbf24;
}

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

body {
    font-family: var(--font); background: 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 { max-width: 1100px; margin: 0 auto; padding: 0 1rem 2rem; }

.app-header {
    background: linear-gradient(145deg,#0f172a 0%,#1e3a5f 50%,#1a365d 100%);
    color: #fff; padding: .9rem 1.25rem; border-radius: 0 0 var(--radius) var(--radius);
    margin: 0 -1rem 1rem; display: flex; align-items: center; justify-content: space-between;
    gap: 1rem; position: sticky; top: 0; z-index: 50;
}

.header-content { display: flex; justify-content: space-between; align-items: center; width: 100%; }
.header-content h1 { font-size: 1rem; font-weight: 600; display: flex; align-items: center; gap: .75rem; margin: 0; }

.theme-switcher { display: flex; align-items: center; gap: .5rem; }
.theme-switcher i { font-size: .85rem; color: rgba(255,255,255,.7); }
.switch { position: relative; display: inline-block; width: 50px; height: 26px; flex-shrink: 0; }
.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,.25); transition: .4s; border-radius: 26px;
}
.slider:before {
    content: ""; position: absolute; height: 20px; width: 20px;
    left: 3px; bottom: 3px; background-color: #fff; transition: .4s; border-radius: 50%;
}
input:checked + .slider { background-color: var(--accent); }
input:checked + .slider:before { transform: translateX(24px); }

.card {
    background: var(--surface); padding: 1.25rem;
    border-radius: var(--radius-sm); border: 1px solid var(--border);
    box-shadow: var(--shadow); transition: all var(--transition);
}
.card h2 {
    font-size: 1.05rem; font-weight: 700; color: var(--text);
    margin: 0 0 1rem 0; padding-bottom: .5rem;
    border-bottom: 2px solid var(--border);
    display: flex; align-items: center; gap: .65rem;
}
.card h2 i { color: var(--primary); font-size: 1rem; width: 1.2rem; text-align: center; }

.input-grid { display: grid; grid-template-columns: 1fr 1fr; gap: .65rem; }

.input-group { margin-bottom: .75rem; }
.input-group label {
    display: block; font-size: .72rem; font-weight: 600;
    color: var(--text-secondary); margin-bottom: .25rem;
    text-transform: uppercase; letter-spacing: .04em;
}
.input-group select,
.input-group input {
    width: 100%; padding: .7rem .75rem;
    border: 2px solid var(--border); border-radius: var(--radius-sm);
    font-size: .9rem; font-family: var(--font); font-weight: 500;
    background: var(--bg); color: var(--text);
    transition: border-color .2s, box-shadow .2s;
    min-height: var(--touch-target); -webkit-appearance: none; appearance: none;
}
.input-group select:focus,
.input-group input:focus {
    outline: none; border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37,99,235,.12);
}

.button-group { display: flex; gap: .65rem; margin-top: .5rem; flex-wrap: wrap; }

.main-button {
    flex: 1; min-width: 120px; min-height: var(--touch-target);
    padding: .8rem 1rem; border: none; border-radius: var(--radius-sm);
    font-size: .88rem; font-weight: 700; font-family: var(--font);
    cursor: pointer; transition: opacity .2s, transform .15s;
    display: inline-flex; align-items: center; justify-content: center; gap: .5rem;
    background: linear-gradient(135deg, var(--primary), var(--accent)); color: #fff;
}
.main-button:active { transform: scale(.97); }
.main-button:hover { opacity: .92; }

.secondary-button {
    flex: 1; min-width: 120px; min-height: var(--touch-target);
    padding: .8rem 1rem; border: 2px solid var(--border); border-radius: var(--radius-sm);
    font-size: .88rem; font-weight: 600; font-family: var(--font);
    cursor: pointer; transition: all .15s;
    display: inline-flex; align-items: center; justify-content: center; gap: .5rem;
    background: var(--bg); color: var(--text);
}
.secondary-button:active { transform: scale(.97); }
.secondary-button:hover { border-color: var(--primary); color: var(--primary); }

.fault-result {
    display: none;
    margin-top: 1rem;
}

.fault-result.visible { display: block; }

.fault-header {
    background: linear-gradient(135deg, var(--primary), var(--accent));
    color: #fff; padding: 1rem 1.25rem; border-radius: var(--radius-sm) var(--radius-sm) 0 0;
    display: flex; align-items: center; gap: 1rem; flex-wrap: wrap;
}
.fault-header .fault-code {
    font-size: 1.4rem; font-weight: 800; letter-spacing: .02em;
}
.fault-header .fault-brand {
    font-size: .82rem; opacity: .85; font-weight: 500;
}
.fault-header .fault-model {
    font-size: .82rem; opacity: .85; font-weight: 500; margin-left: auto;
}

.fault-body {
    border: 1px solid var(--border); border-top: none;
    border-radius: 0 0 var(--radius-sm) var(--radius-sm);
    padding: 1.25rem;
    background: var(--surface);
}

.fault-section { margin-bottom: 1.25rem; }
.fault-section:last-child { margin-bottom: 0; }

.fault-section h3 {
    font-size: .85rem; font-weight: 700; text-transform: uppercase;
    letter-spacing: .04em; color: var(--primary); margin-bottom: .5rem;
    display: flex; align-items: center; gap: .5rem;
}
.fault-section h3 i { font-size: .9rem; width: 1.1rem; text-align: center; }

.fault-section p,
.fault-section ul {
    font-size: .88rem; color: var(--text); line-height: 1.6;
}

.fault-section ul { list-style: none; padding: 0; }
.fault-section ul li {
    padding: .35rem 0 .35rem 1.2rem; position: relative;
}
.fault-section ul li::before {
    content: "•"; position: absolute; left: 0;
    color: var(--primary); font-weight: 700;
}

.fault-section .cause-item {
    background: var(--bg); padding: .65rem .85rem; margin-bottom: .35rem;
    border-radius: var(--radius-sm); border-left: 3px solid var(--cor-destaque);
    font-size: .85rem;
}

.fault-section .solution-item {
    background: var(--bg); padding: .65rem .85rem; margin-bottom: .35rem;
    border-radius: var(--radius-sm); border-left: 3px solid var(--cor-sucesso);
    font-size: .85rem;
}

.no-results {
    text-align: center; padding: 2rem 1rem; color: var(--text-secondary);
}
.no-results i { font-size: 2.5rem; margin-bottom: .75rem; opacity: .5; display: block; }
.no-results p { font-size: .95rem; margin-bottom: .25rem; }
.no-results .hint { font-size: .8rem; opacity: .7; }

.fault-count {
    font-size: .78rem; color: var(--text-secondary); margin-top: .5rem;
    font-weight: 500;
}

.search-box { position: relative; margin-bottom: .75rem; }
.search-box input {
    width: 100%; padding: .7rem 1rem .7rem 2.5rem;
    border: 2px solid var(--border); border-radius: var(--radius-sm);
    background: var(--bg); color: var(--text); font-size: .85rem;
    font-weight: 500; font-family: var(--font);
    transition: border-color .2s; min-height: var(--touch-target);
    -webkit-appearance: none; appearance: none;
}
.search-box input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37,99,235,.12); }
.search-box i { position: absolute; left: .85rem; top: 50%; transform: translateY(-50%); color: var(--text-secondary); }

.suggestions-box {
    position: absolute; top: 100%; left: 0; right: 0; z-index: 20;
    background: var(--surface); border: 1px solid var(--border);
    border-top: none; border-radius: 0 0 var(--radius-sm) var(--radius-sm);
    max-height: 250px; overflow-y: auto; display: none;
    box-shadow: var(--shadow-lg);
}
.suggestions-box.visible { display: block; }
.suggestions-box .suggestion-item {
    padding: .6rem .75rem; cursor: pointer; font-size: .82rem;
    border-bottom: 1px solid var(--border); transition: background .15s;
    display: flex; justify-content: space-between; align-items: center;
}
.suggestions-box .suggestion-item:last-child { border-bottom: none; }
.suggestions-box .suggestion-item:hover,
.suggestions-box .suggestion-item.active { background: var(--bg); }
.suggestions-box .suggestion-item .code { font-weight: 700; color: var(--primary); }
.suggestions-box .suggestion-item .desc { color: var(--text-secondary); font-size: .78rem; }

.quick-faults {
    display: flex; flex-wrap: wrap; gap: .4rem; margin-top: .5rem;
}
.quick-faults .chip {
    padding: .3rem .65rem; border: 1px solid var(--border);
    border-radius: 20px; font-size: .75rem; font-weight: 600;
    cursor: pointer; transition: all .15s; background: var(--bg);
    color: var(--text-secondary); font-family: var(--font);
}
.quick-faults .chip:hover {
    border-color: var(--primary); color: var(--primary); background: var(--surface);
}

.stats-row {
    display: grid; grid-template-columns: repeat(3, 1fr); gap: .75rem; margin-bottom: 1rem;
}
.stat-card {
    background: linear-gradient(145deg, var(--surface), var(--bg));
    padding: 1rem .5rem .85rem; border-radius: var(--radius-sm);
    text-align: center; border: 1px solid var(--border);
    box-shadow: var(--shadow); position: relative; overflow: hidden;
    transition: transform .2s, box-shadow .2s;
}
.stat-card:hover {
    transform: translateY(-2px); box-shadow: var(--shadow-lg);
}
.stat-card .stat-icon {
    display: block; font-size: 1.1rem; color: var(--primary); margin-bottom: .1rem;
    opacity: .7;
}
.stat-card .stat-number {
    display: block; font-size: 1.6rem; font-weight: 800;
    background: linear-gradient(135deg, var(--primary), var(--accent));
    -webkit-background-clip: text; -webkit-text-fill-color: transparent;
    background-clip: text; line-height: 1.2;
}
.stat-card .stat-label {
    font-size: .65rem; color: var(--text-secondary); font-weight: 600;
    text-transform: uppercase; letter-spacing: .04em; margin-top: .15rem;
    display: block;
}

@media (max-width: 600px) {
    .app-container { padding: 0 .5rem 1.5rem; }
    .app-header { margin: 0 -.5rem .75rem; padding: .75rem .9rem; }
    .card { padding: 1rem; }
    .header-content h1 { font-size: .9rem; }
    .input-grid { grid-template-columns: 1fr; }
    .button-group { flex-direction: column; }
    .main-button, .secondary-button { width: 100%; }
    .stats-row { grid-template-columns: repeat(3, 1fr); gap: .5rem; }
    .fault-header { flex-direction: column; align-items: flex-start; }
    .fault-header .fault-model { margin-left: 0; }
}

@media (min-width: 768px) {
    .two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
}
