/* ============================================================
   GuinchaFácil — CSS Global + Temas por Perfil
   admin (preto) | guincho (verde) | cliente (branco)
   ============================================================ */

/* ---------- VARIÁVEIS GLOBAIS ---------- */
:root {
    --primary:       #2fb34a;
    --primary-dark:  #1f8a36;
    --primary-light: #d4f5dc;
    --danger:        #dc2626;
    --warning:       #d97706;
    --success:       #16a34a;
    --shadow:        0 2px 10px rgba(0,0,0,.13);
    --radius:        12px;
    --trans:         .2s ease;
}

/* ---- Tema padrão / Admin (preto) ---- */
body {
    --theme-bg:       #0d0d0d;
    --theme-surf:     #1a1a1a;
    --theme-surf2:    #252525;
    --theme-border:   #333;
    --theme-text:     #e8e8e8;
    --theme-muted:    #888;
    --theme-accent:   #2fb34a;
    --theme-nav-bg:   #000000;
    --theme-nav-txt:  #ffffff;
    --theme-card-hd:  #252525;
    --theme-sidebar:  #111111;
}

/* ---- Tema Guincho (verde escuro) ---- */
body.guincho {
    --theme-bg:       #071209;
    --theme-surf:     #0e2412;
    --theme-surf2:    #163319;
    --theme-border:   #264d2c;
    --theme-text:     #cff5d7;
    --theme-muted:    #5ea86a;
    --theme-nav-bg:   #050f06;
    --theme-nav-txt:  #a3f7b5;
    --theme-card-hd:  #163d1c;
    --theme-sidebar:  #060d07;
}

body.guincho .text-muted,
body.guincho .sidebar-title,
body.guincho .sidebar-section-header,
body.guincho .page-subtitle,
body.guincho .stat-label,
body.guincho .form-label,
body.guincho .chat-msg .sender {
    color: rgba(255,255,255,.76) !important;
}

body.guincho .sidebar-link,
body.guincho .sidebar-link i,
body.guincho .text-secondary {
    color: rgba(207,245,215,.9) !important;
}

/* ---- Tema Cliente (branco/claro) ---- */
body.cliente {
    --theme-bg:       #f3f6f4;
    --theme-surf:     #ffffff;
    --theme-surf2:    #edf5ef;
    --theme-border:   #cde5d1;
    --theme-text:     #152218;
    --theme-muted:    #4e7257;
    --theme-nav-bg:   #ffffff;
    --theme-nav-txt:  #152218;
    --theme-card-hd:  #2fb34a;
    --theme-sidebar:  #edf5ef;
}

/* ---------- RESET ---------- */
*, *::before, *::after { box-sizing: border-box; }

body {
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    background: var(--theme-bg);
    color: var(--theme-text);
    padding-top: 64px;
    min-height: 100vh;
    margin: 0;
}

/* ---------- NAVBAR ---------- */
.navbar {
    background: var(--theme-nav-bg) !important;
    border-bottom: 1px solid var(--theme-border);
    box-shadow: var(--shadow);
    position: fixed;
    top: 0; left: 0; right: 0;
    z-index: 1030;
    min-height: 64px;
}
.navbar-brand {
    font-weight: 800;
    font-size: 1.25rem;
    color: var(--theme-nav-txt) !important;
    display: flex; align-items: center; gap: 10px;
}
.navbar-brand span { color: var(--primary); }

.nav-link {
    color: var(--theme-nav-txt) !important;
    opacity: .82;
    font-weight: 500;
    padding: .45rem .85rem !important;
    border-radius: 8px;
    transition: opacity var(--trans), background var(--trans);
}
.nav-link:hover, .nav-link.active {
    opacity: 1;
    background: rgba(47,179,74,.18);
    color: var(--primary) !important;
}
body.cliente .nav-link:hover,
body.cliente .nav-link.active {
    color: var(--primary-dark) !important;
}

.navbar-toggler { border-color: var(--theme-border); }
.navbar-toggler-icon {
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 30 30'%3e%3cpath stroke='rgba(200,200,200,0.9)' stroke-width='2' d='M4 7h22M4 15h22M4 23h22'/%3e%3c/svg%3e");
}
body.cliente .navbar-toggler-icon {
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 30 30'%3e%3cpath stroke='rgba(21,34,24,0.9)' stroke-width='2' d='M4 7h22M4 15h22M4 23h22'/%3e%3c/svg%3e");
}

/* Badge de perfil */
.badge-perfil {
    font-size: .65rem; padding: 3px 8px; border-radius: 20px;
    font-weight: 700; letter-spacing: .5px; text-transform: uppercase;
}
.badge-perfil.admin   { background: #2fb34a; color: #000; }
.badge-perfil.guincho { background: #0a2e0e; color: #7dff96; border: 1px solid #2fb34a; }
.badge-perfil.cliente { background: #2fb34a; color: #fff; }

/* ---------- LAYOUT ---------- */
.main-wrapper { display: flex; min-height: calc(100vh - 64px); }

/* Sidebar */
.sidebar {
    width: 230px;
    background: var(--theme-sidebar);
    border-right: 1px solid var(--theme-border);
    padding: 1.25rem 0;
    flex-shrink: 0;
    position: sticky;
    top: 64px;
    height: calc(100vh - 64px);
    overflow-y: auto;
}
.sidebar-title {
    font-size: .68rem; font-weight: 700; letter-spacing: 1.2px;
    text-transform: uppercase; color: var(--theme-muted);
    padding: .75rem 1.2rem .35rem;
}
.sidebar-link {
    display: flex; align-items: center; gap: .6rem;
    padding: .58rem 1.2rem;
    color: var(--theme-text);
    text-decoration: none;
    font-size: .88rem; font-weight: 500;
    border-left: 3px solid transparent;
    transition: all var(--trans);
}
.sidebar-link i { width: 18px; text-align: center; color: var(--theme-muted); transition: color var(--trans); }
.sidebar-link:hover, .sidebar-link.active {
    background: rgba(47,179,74,.1);
    color: var(--primary);
    border-left-color: var(--primary);
}
.sidebar-link:hover i, .sidebar-link.active i { color: var(--primary); }
.sidebar-link.active { font-weight: 600; }
.sidebar-sep { border: none; border-top: 1px solid var(--theme-border); margin: .65rem 1rem; }

/* Main content */
.main-content { flex: 1; padding: 2rem; min-width: 0; }

/* ---------- CARDS ---------- */
.card {
    background: var(--theme-surf);
    border: 1px solid var(--theme-border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
}
.card-header {
    background: var(--theme-card-hd);
    color: #fff;
    font-weight: 700;
    padding: .9rem 1.2rem;
    border-bottom: 1px solid var(--theme-border);
}
.card-body { padding: 1.2rem; }
.card-footer {
    background: var(--theme-surf2);
    border-top: 1px solid var(--theme-border);
    padding: .8rem 1.2rem;
}

/* Stat cards */
.stat-card {
    background: var(--theme-surf);
    border: 1px solid var(--theme-border);
    border-radius: var(--radius);
    padding: 1.4rem 1.2rem;
    text-align: center;
    box-shadow: var(--shadow);
    transition: transform var(--trans), box-shadow var(--trans);
}
.stat-card:hover { transform: translateY(-3px); box-shadow: 0 8px 22px rgba(0,0,0,.18); }
.stat-icon {
    width: 50px; height: 50px; border-radius: 14px;
    background: rgba(47,179,74,.15);
    display: flex; align-items: center; justify-content: center;
    margin: 0 auto .8rem; font-size: 1.35rem; color: var(--primary);
}
.stat-value { font-size: 1.9rem; font-weight: 800; color: var(--theme-text); line-height: 1; }
.stat-label { font-size: .78rem; color: var(--theme-muted); margin-top: .25rem; }

/* ---------- TABELAS ---------- */
.table { color: var(--theme-text); border-color: var(--theme-border); margin-bottom: 0; }
.table thead th {
    background: var(--theme-surf2);
    color: var(--theme-muted);
    font-size: .74rem; font-weight: 700;
    letter-spacing: .6px; text-transform: uppercase;
    border-bottom: 2px solid var(--theme-border);
    padding: .7rem 1rem;
}
.table tbody td { padding: .82rem 1rem; border-color: var(--theme-border); vertical-align: middle; }
.table-hover tbody tr:hover { background: rgba(47,179,74,.06); }

/* ---------- BOTÕES ---------- */
.btn { border-radius: 8px; font-weight: 600; transition: all var(--trans); }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover, .btn-primary:focus {
    background: var(--primary-dark); border-color: var(--primary-dark);
    transform: translateY(-1px); box-shadow: 0 4px 14px rgba(47,179,74,.35);
}
.btn-secondary { background: var(--theme-surf2); border-color: var(--theme-border); color: var(--theme-text); }
.btn-secondary:hover { background: var(--theme-surf); color: var(--theme-text); }
.btn-outline-primary { border-color: var(--primary); color: var(--primary); }
.btn-outline-primary:hover { background: var(--primary); color: #fff; }
.btn-socorro {
    font-size: 1.15rem; font-weight: 800;
    padding: 1rem 2.5rem; background: var(--primary);
    border: none; color: #fff; border-radius: 50px;
    box-shadow: 0 6px 20px rgba(47,179,74,.4);
}
.btn-socorro:hover {
    background: var(--primary-dark); transform: translateY(-2px);
    box-shadow: 0 10px 26px rgba(47,179,74,.5); color: #fff;
}

/* ---------- FORMULÁRIOS ---------- */
.form-control, .form-select {
    background: var(--theme-surf2);
    border-color: var(--theme-border);
    color: var(--theme-text);
    border-radius: 8px;
}
.form-control:focus, .form-select:focus {
    background: var(--theme-surf2);
    border-color: var(--primary);
    color: var(--theme-text);
    box-shadow: 0 0 0 3px rgba(47,179,74,.2);
}
.form-control::placeholder { color: var(--theme-muted); }
.form-label { color: var(--theme-muted); font-weight: 600; font-size: .86rem; }

/* ---------- BADGES DE STATUS ---------- */
.badge { border-radius: 20px; font-weight: 700; font-size: .7rem; padding: 4px 10px; }
.badge-aguardando_pagamento { background: rgba(217,119,6,.15); color: #d97706; border: 1px solid rgba(217,119,6,.3); }
.badge-aguardando_guincho   { background: rgba(59,130,246,.15); color: #60a5fa; border: 1px solid rgba(59,130,246,.3); }
.badge-a_caminho            { background: rgba(14,165,233,.15); color: #38bdf8; border: 1px solid rgba(14,165,233,.3); }
.badge-no_local             { background: rgba(52,211,153,.15); color: #34d399; border: 1px solid rgba(52,211,153,.3); }
.badge-em_reboque           { background: rgba(74,222,128,.15); color: #4ade80; border: 1px solid rgba(74,222,128,.3); }
.badge-concluido            { background: rgba(34,197,94,.15);  color: #22c55e; border: 1px solid rgba(34,197,94,.3); }
.badge-cancelado            { background: rgba(248,113,113,.15); color: #f87171; border: 1px solid rgba(248,113,113,.3); }

/* ---------- MAPA ---------- */
.map-container    { height: 70vh; min-height: 400px; border-radius: var(--radius); overflow: hidden; border: 1px solid var(--theme-border); }
.map-container-sm { height: 260px; border-radius: 8px; overflow: hidden; border: 1px solid var(--theme-border); }

/* ---------- CHAT ---------- */
.chat-box { height: 300px; overflow-y: auto; border: 1px solid var(--theme-border); border-radius: var(--radius); padding: 1rem; background: var(--theme-surf); display: flex; flex-direction: column; gap: .5rem; }
.chat-msg .bubble { max-width: 75%; padding: .5rem .9rem; border-radius: 18px; display: inline-block; font-size: .88rem; }
.chat-msg.mine { text-align: right; }
.chat-msg.mine .bubble  { background: var(--primary); color: #fff; border-bottom-right-radius: 4px; }
.chat-msg.other .bubble { background: var(--theme-surf2); color: var(--theme-text); border-bottom-left-radius: 4px; }
.chat-msg .sender { font-size: .7rem; color: var(--theme-muted); margin-bottom: 2px; }

/* ---------- STATUS STEPS ---------- */
.status-steps { display: flex; justify-content: space-between; align-items: flex-start; padding: 1.5rem 0; }
.step { display: flex; flex-direction: column; align-items: center; flex: 1; position: relative; }
.step::before { content: ''; position: absolute; top: 20px; left: -50%; width: 100%; height: 3px; background: var(--theme-border); z-index: 0; }
.step:first-child::before { display: none; }
.step-icon { width: 42px; height: 42px; border-radius: 50%; background: var(--theme-surf2); display: flex; align-items: center; justify-content: center; font-size: 1rem; z-index: 1; border: 2px solid var(--theme-border); }
.step.active .step-icon { border-color: var(--primary); color: var(--primary); }
.step.done .step-icon   { background: var(--primary); color: #fff; border-color: var(--primary); }
.step.done::before { background: var(--primary); }
.step-label { font-size: .68rem; margin-top: .35rem; text-align: center; color: var(--theme-muted); }
.step.active .step-label { color: var(--primary); font-weight: 700; }

/* ---------- TOGGLE ---------- */
.toggle-disponivel { display: flex; align-items: center; gap: .75rem; }
.toggle-switch { position: relative; width: 52px; height: 28px; }
.toggle-switch input { display: none; }
.toggle-slider { position: absolute; inset: 0; background: var(--theme-border); border-radius: 28px; cursor: pointer; transition: .3s; }
.toggle-slider::after { content: ''; position: absolute; width: 22px; height: 22px; left: 3px; top: 3px; background: #fff; border-radius: 50%; transition: .3s; }
.toggle-switch input:checked + .toggle-slider { background: var(--primary); }
.toggle-switch input:checked + .toggle-slider::after { transform: translateX(24px); }

/* ---------- ESTRELAS ---------- */
.star-rating { display: flex; flex-direction: row-reverse; justify-content: flex-end; }
.star-rating input { display: none; }
.star-rating label { font-size: 2rem; color: var(--theme-border); cursor: pointer; transition: color .15s; }
.star-rating input:checked ~ label, .star-rating label:hover, .star-rating label:hover ~ label { color: #f59e0b; }

/* ---------- PAGINAÇÃO ---------- */
.pagination .page-link { background: var(--theme-surf2); border-color: var(--theme-border); color: var(--primary); }
.pagination .page-item.active .page-link { background: var(--primary); border-color: var(--primary); color: #fff; }

/* ---------- ALERTAS ---------- */
.alert { border-radius: var(--radius); border: none; }
.alert-success { background: rgba(47,179,74,.15); color: #4ade80; }
.alert-danger   { background: rgba(220,38,38,.15);  color: #f87171; }
.alert-warning  { background: rgba(217,119,6,.15);  color: #fbbf24; }
.alert-info     { background: rgba(59,130,246,.15); color: #60a5fa; }

.status-banner-live {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: .9rem 1rem;
    margin-bottom: 1.25rem;
    border: 1px solid rgba(47,179,74,.35);
    border-left: 4px solid var(--primary);
    border-radius: var(--radius);
    background: color-mix(in srgb, var(--theme-surf) 88%, var(--primary) 12%);
    color: var(--theme-text);
}
.status-banner-title {
    display: flex;
    align-items: center;
    gap: .55rem;
    font-weight: 800;
}
.status-banner-meta {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: .5rem;
    color: var(--theme-muted);
    font-size: .88rem;
}
.status-banner-extra,
.status-banner-chat {
    border-radius: 999px;
    padding: .2rem .55rem;
    background: rgba(255,255,255,.08);
    color: var(--theme-text);
}
.status-banner-chat {
    background: rgba(59,130,246,.18);
    color: #93c5fd;
    font-weight: 700;
}
.status-banner-live .btn {
    flex: 0 0 auto;
}

/* ---------- FOOTER ---------- */
footer { background: var(--theme-sidebar); border-top: 1px solid var(--theme-border); color: var(--theme-muted); padding: 1.25rem 0; font-size: .84rem; }
footer a { color: var(--primary); text-decoration: none; }
footer a:hover { text-decoration: underline; }

/* ---------- PAGE HEADER ---------- */
.page-header { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 1rem; margin-bottom: 1.75rem; }
.page-title { font-size: 1.45rem; font-weight: 800; color: var(--theme-text); }
.page-subtitle { font-size: .85rem; color: var(--theme-muted); margin-top: .2rem; }

/* Guincho card */
.guincho-card { border-left: 4px solid var(--primary); cursor: pointer; transition: box-shadow var(--trans), transform var(--trans); }
.guincho-card:hover { box-shadow: 0 6px 20px rgba(0,0,0,.2); transform: translateY(-2px); }
.guincho-score { font-size: .76rem; color: var(--primary); font-weight: 700; }

/* ---------- RESPONSIVO ---------- */
@media (max-width: 991.98px) {
    .sidebar { width: 100%; height: auto; position: static; border-right: none; border-bottom: 1px solid var(--theme-border); display: flex; flex-wrap: wrap; gap: .2rem; padding: .5rem; }
    .sidebar-title, .sidebar-sep { display: none; }
    .sidebar-link { border-left: none; border-radius: 8px; padding: .4rem .75rem; font-size: .82rem; }
    .sidebar-link.active { border-left: none; background: rgba(47,179,74,.15); }
    .main-wrapper { flex-direction: column; }
    .main-content { padding: 1.25rem; }
}
@media (max-width: 767.98px) {
    body { padding-top: 60px; }
    .map-container { height: 50vh; min-height: 250px; }
    .status-steps { flex-direction: column; align-items: flex-start; gap: .75rem; }
    .step::before { display: none; }
    .stat-value { font-size: 1.6rem; }
    .page-header { flex-direction: column; align-items: flex-start; }
    .main-content { padding: 1rem; }
    .btn-socorro { width: 100%; }
    .status-banner-live { align-items: flex-start; flex-direction: column; }
    .status-banner-live .btn { width: 100%; }
}
@media (max-width: 575.98px) {
    .stat-card { padding: 1rem; }
    .card-body { padding: 1rem; }
    .navbar-brand { font-size: 1.05rem; }
}

/* ============================================================
   SIDEBAR - MELHORIAS DE DESIGN (seções e preview)
   ============================================================ */

/* Cabeçalho de seção da sidebar */
.sidebar-section-header {
    display: flex;
    align-items: center;
    gap: .45rem;
    font-size: .63rem;
    font-weight: 800;
    letter-spacing: 1.4px;
    text-transform: uppercase;
    color: var(--theme-muted);
    padding: .85rem 1.2rem .3rem;
    opacity: .75;
}
.sidebar-section-header i {
    font-size: .65rem;
    width: 14px;
    text-align: center;
}

/* Link de ação (criar/novo) */
.sidebar-link-action {
    font-size: .82rem;
    opacity: .85;
    padding-left: 1.5rem;
}
.sidebar-link-action i { color: var(--primary) !important; opacity: .7; }
.sidebar-link-action:hover { opacity: 1; }

/* Link de preview (ver como) */
.sidebar-link-preview {
    border-left: 3px dashed rgba(47,179,74,.35) !important;
    background: rgba(47,179,74,.04) !important;
    font-size: .83rem;
}
.sidebar-link-preview:hover {
    border-left-color: var(--primary) !important;
    background: rgba(47,179,74,.12) !important;
}

/* Badge PREVIEW inline */
.sidebar-preview-badge {
    margin-left: auto;
    font-size: .55rem;
    font-weight: 800;
    letter-spacing: .8px;
    color: var(--primary);
    border: 1px solid rgba(47,179,74,.4);
    border-radius: 4px;
    padding: 1px 4px;
    opacity: .7;
}

/* Melhoria visual geral da sidebar */
.sidebar-link {
    position: relative;
}
.sidebar-link span {
    flex: 1;
}

/* Oculta seção-header no mobile (já sumia sidebar-title antes) */
@media (max-width: 991.98px) {
    .sidebar-section-header { display: none; }
    .sidebar-link-preview .sidebar-preview-badge { display: none; }
    .sidebar-link-action { padding-left: .75rem; }
}

/* ============================================================
   GUINCHOS - cards de status
   ============================================================ */
.guincho-status-online  { background: rgba(34,197,94,.15);  color: #22c55e; border: 1px solid rgba(34,197,94,.3);  border-radius: 20px; font-size:.7rem; font-weight:700; padding: 3px 9px; }
.guincho-status-offline { background: rgba(156,163,175,.15); color: #9ca3af; border: 1px solid rgba(156,163,175,.3); border-radius: 20px; font-size:.7rem; font-weight:700; padding: 3px 9px; }
.guincho-status-ocupado { background: rgba(251,191,36,.15); color: #fbbf24; border: 1px solid rgba(251,191,36,.3);  border-radius: 20px; font-size:.7rem; font-weight:700; padding: 3px 9px; }
