/**
 * Sistema de Gestão - Estilo Conta Azul
 * Design moderno, limpo, tons de azul, mobile-first
 */

:root {
    --primary: #1a56db;
    --primary-dark: #1446b0;
    --primary-light: #e8f0fe;
    --sidebar-width: 260px;
    --topbar-height: 60px;
    --radius: 12px;
    --shadow: 0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.06);
    --shadow-lg: 0 4px 12px rgba(0,0,0,0.1);
}

/* Base */
body {
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    background: var(--bs-body-bg);
    overflow-x: hidden;
}

/* Sidebar */
.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: var(--sidebar-width);
    height: 100vh;
    background: linear-gradient(180deg, var(--primary) 0%, var(--primary-dark) 100%);
    color: #fff;
    z-index: 1050;
    display: flex;
    flex-direction: column;
    transition: transform 0.3s ease;
}

.sidebar-header {
    padding: 1.25rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    border-bottom: 1px solid rgba(255,255,255,0.15);
}

.sidebar-logo { max-height: 36px; border-radius: 6px; }
.sidebar-brand { font-size: 1.75rem; }
.sidebar-title { font-weight: 600; font-size: 0.95rem; line-height: 1.2; }

.sidebar-nav {
    flex: 1;
    padding: 0.75rem;
    overflow-y: auto;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.85rem 1rem;
    color: rgba(255,255,255,0.85);
    text-decoration: none;
    border-radius: 8px;
    margin-bottom: 2px;
    font-size: 0.95rem;
    transition: all 0.2s;
}

.nav-item:hover { background: rgba(255,255,255,0.12); color: #fff; }
.nav-item.active { background: rgba(255,255,255,0.2); color: #fff; font-weight: 600; }
.nav-item i { font-size: 1.2rem; width: 24px; text-align: center; }

.sidebar-footer {
    padding: 1rem;
    border-top: 1px solid rgba(255,255,255,0.15);
}

.user-info {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.85rem;
}

/* Main content */
.main-content {
    margin-left: var(--sidebar-width);
    min-height: 100vh;
    transition: margin 0.3s ease;
}

.topbar {
    position: sticky;
    top: 0;
    height: var(--topbar-height);
    background: var(--bs-body-bg);
    border-bottom: 1px solid var(--bs-border-color);
    display: flex;
    align-items: center;
    padding: 0 1rem;
    z-index: 1040;
}

.sidebar-toggle { color: var(--bs-body-color); display: none; }
.theme-toggle { color: var(--bs-body-color); }

.page-content { padding: 1rem 0 2rem; }
.page-title { font-weight: 700; color: var(--primary); }

/* Search */
.search-box {
    position: relative;
    max-width: 500px;
}

.search-box i {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: #999;
    z-index: 2;
}

.search-box input {
    padding-left: 36px;
    border-radius: 24px;
    border: 1px solid var(--bs-border-color);
    height: 42px;
}

.search-results {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--bs-body-bg);
    border: 1px solid var(--bs-border-color);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    z-index: 1060;
    display: none;
    max-height: 300px;
    overflow-y: auto;
}

.search-results.show { display: block; }
.search-result-item {
    display: block;
    padding: 0.75rem 1rem;
    text-decoration: none;
    color: var(--bs-body-color);
    border-bottom: 1px solid var(--bs-border-color);
}
.search-result-item:hover { background: var(--primary-light); }
.search-result-item small { color: #888; }

/* Cards */
.card-modern {
    border: none;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
}

.card-modern .card-header {
    background: transparent;
    border-bottom: 1px solid var(--bs-border-color);
    font-weight: 600;
    padding: 1rem 1.25rem;
}

.card-hover { transition: transform 0.2s, box-shadow 0.2s; }
.card-hover:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); }

/* Stat cards */
.stat-card {
    background: var(--bs-body-bg);
    border-radius: var(--radius);
    padding: 1.25rem;
    box-shadow: var(--shadow);
    display: flex;
    align-items: center;
    gap: 1rem;
    height: 100%;
}

.stat-icon {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    flex-shrink: 0;
}

.stat-value { display: block; font-size: 1.25rem; font-weight: 700; line-height: 1.2; }
.stat-label { display: block; font-size: 0.8rem; color: #888; margin-top: 2px; }

/* Buttons */
.btn-primary { background: var(--primary); border-color: var(--primary); }
.btn-primary:hover { background: var(--primary-dark); border-color: var(--primary-dark); }
.btn-lg { padding: 0.65rem 1.25rem; font-size: 1rem; border-radius: 8px; }

/* Login */
.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--primary-light) 0%, #fff 50%, var(--primary-light) 100%);
}

.login-container { width: 100%; max-width: 420px; padding: 1rem; }
.login-card {
    background: #fff;
    border-radius: var(--radius);
    padding: 2rem;
    box-shadow: var(--shadow-lg);
}

.login-icon {
    width: 64px;
    height: 64px;
    background: var(--primary-light);
    color: var(--primary);
    border-radius: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.75rem;
    margin: 0 auto 1rem;
}

/* Photos */
.photo-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    min-height: 60px;
}

.photo-thumb {
    width: 100px;
    height: 100px;
    object-fit: cover;
    border-radius: 8px;
    border: 2px solid var(--bs-border-color);
}

/* Signature */
.signature-canvas {
    width: 100%;
    height: 200px;
    border: 2px dashed var(--bs-border-color);
    border-radius: var(--radius);
    touch-action: none;
    cursor: crosshair;
}

.signature-preview { max-height: 100px; border: 1px solid #ddd; border-radius: 8px; }

/* Overlay */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 1045;
}

/* Dark mode */
[data-bs-theme="dark"] {
    --primary-light: #1e293b;
}

[data-bs-theme="dark"] .stat-card,
[data-bs-theme="dark"] .card-modern {
    background: var(--bs-body-bg);
}

[data-bs-theme="dark"] .login-card { background: #1e293b; }

/* Mobile */
@media (max-width: 991.98px) {
    .sidebar { transform: translateX(-100%); }
    .sidebar.open { transform: translateX(0); }
    .sidebar-overlay.show { display: block; }
    .main-content { margin-left: 0; }
    .sidebar-toggle { display: block; }
    .stat-value { font-size: 1rem; }
}

@media (max-width: 575.98px) {
    .search-box { margin: 0 !important; }
    .topbar { flex-wrap: wrap; height: auto; padding: 0.5rem; }
}

/* Itens da OS - mobile first */
.os-empty-state { border: 2px dashed var(--bs-border-color); border-radius: 12px; }
.os-novo-item { border-color: var(--primary) !important; border-width: 2px !important; }
.os-item-card { transition: box-shadow 0.2s; }
.os-item-card:active { box-shadow: var(--shadow); }
.os-item-num { min-width: 32px; height: 32px; display: flex; align-items: center; justify-content: center; font-size: 0.9rem; }

/* Autocomplete de cliente (OS) */
.cliente-autocomplete { min-width: 0; }
.cliente-busca-icon {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    color: #999;
    z-index: 2;
    pointer-events: none;
}
.cliente-busca-input { padding-left: 2.5rem !important; }
.cliente-sugestoes {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    right: 0;
    background: var(--bs-body-bg);
    border: 1px solid var(--bs-border-color);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    z-index: 1060;
    display: none;
    max-height: 280px;
    overflow-y: auto;
}
.cliente-sugestoes.show { display: block; }
.cliente-sugestao-item {
    display: block;
    width: 100%;
    text-align: left;
    padding: 0.75rem 1rem;
    border: none;
    background: transparent;
    color: var(--bs-body-color);
    border-bottom: 1px solid var(--bs-border-color);
}
.cliente-sugestao-item:last-child { border-bottom: none; }
.cliente-sugestao-item:hover,
.cliente-sugestao-item.active { background: var(--primary-light); }
.cliente-sugestao-empty {
    padding: 0.75rem 1rem;
    color: #888;
}

/* Fluxo guiado da OS */
.os-passo-oculto { display: none !important; }
.os-passo-revelavel.os-passo-visivel {
    animation: osPassoIn 0.35s ease;
}
@keyframes osPassoIn {
    from { opacity: 0; transform: translateY(12px); }
    to { opacity: 1; transform: translateY(0); }
}
#osCardItens.os-destaque {
    box-shadow: 0 0 0 3px rgba(26, 86, 219, 0.35);
    transition: box-shadow 0.3s ease;
}
.min-width-0 { min-width: 0; }

.table-items input.form-control { min-width: 80px; }

/* Pagination */
.pagination .page-link { border-radius: 8px; margin: 0 2px; color: var(--primary); }
.pagination .page-item.active .page-link { background: var(--primary); border-color: var(--primary); }

/* Table */
.table th { font-weight: 600; font-size: 0.85rem; text-transform: uppercase; letter-spacing: 0.03em; color: #888; }

/* Form focus */
.form-control:focus, .form-select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 0.2rem rgba(26, 86, 219, 0.15);
}
