/* ============================================================
   LocaFerr — CSS Principal
   ============================================================ */

/* ─── Reset & Base ─────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
    --primary:    #2563eb;
    --primary-dk: #1d4ed8;
    --success:    #16a34a;
    --warning:    #d97706;
    --danger:     #dc2626;
    --secondary:  #64748b;
    --info:       #0891b2;
    --orange:     #ea580c;
    --purple:     #7c3aed;
    --emerald:    #059669;

    --bg:         #f1f5f9;
    --surface:    #ffffff;
    --border:     #e2e8f0;
    --text:       #1e293b;
    --text-muted: #64748b;
    --text-light: #94a3b8;

    --sidebar-bg:     #1e293b;
    --sidebar-hover:  #334155;
    --sidebar-active: #2563eb;
    --sidebar-w:      240px;

    --radius:   8px;
    --radius-sm:4px;
    --shadow:   0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.04);
    --shadow-md:0 4px 6px rgba(0,0,0,.07), 0 2px 4px rgba(0,0,0,.05);

    --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

html { font-size: 15px; }
body { font-family: var(--font); background: var(--bg); color: var(--text); line-height: 1.5; }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; display: block; }

/* ─── Layout Principal ─────────────────────────────────────── */
.layout-main {
    margin-left: var(--sidebar-w);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    transition: margin-left .25s;
}

/* ─── Sidebar ──────────────────────────────────────────────── */
.sidebar {
    position: fixed;
    top: 0; left: 0;
    width: var(--sidebar-w);
    height: 100vh;
    background: var(--sidebar-bg);
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    z-index: 100;
    transition: transform .25s;
}
.sidebar-brand {
    padding: 20px 16px 16px;
    display: flex;
    align-items: center;
    gap: 10px;
    border-bottom: 1px solid rgba(255,255,255,.1);
}
.brand-icon { font-size: 1.5rem; }
.brand-name { color: #fff; font-size: 1.1rem; font-weight: 700; }
.sidebar-nav { flex: 1; padding: 12px 8px; }
.nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 12px;
    border-radius: var(--radius);
    color: #cbd5e1;
    font-size: .9rem;
    transition: background .15s, color .15s;
    margin-bottom: 2px;
}
.nav-item:hover, .nav-item.active {
    background: var(--sidebar-hover);
    color: #fff;
    text-decoration: none;
}
.nav-item.active { background: var(--sidebar-active); }
.nav-icon { font-size: 1rem; width: 20px; text-align: center; }
.nav-divider { height: 1px; background: rgba(255,255,255,.08); margin: 8px 0; }
.sidebar-footer { padding: 12px 16px; color: #64748b; font-size: .75rem; border-top: 1px solid rgba(255,255,255,.08); }

/* ─── Topbar ───────────────────────────────────────────────── */
.topbar {
    height: 56px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    padding: 0 24px;
    gap: 12px;
    position: sticky;
    top: 0;
    z-index: 50;
    box-shadow: var(--shadow);
}
.sidebar-toggle {
    display: none;
    flex-direction: column;
    gap: 5px;
    background: none;
    border: none;
    cursor: pointer;
    padding: 6px;
}
.sidebar-toggle span { display: block; width: 22px; height: 2px; background: var(--text); border-radius: 2px; }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 12px; }
.topbar-user { display: flex; align-items: center; gap: 8px; font-size: .875rem; }
.user-name { font-weight: 500; }
.user-badge {
    background: #e2e8f0; color: #475569; font-size: .7rem;
    padding: 2px 6px; border-radius: 20px; text-transform: uppercase;
}
.btn-logout {
    background: none; border: 1px solid var(--border); color: var(--text-muted);
    padding: 4px 10px; border-radius: var(--radius-sm); cursor: pointer; font-size: .8rem;
}
.btn-logout:hover { background: var(--bg); color: var(--danger); }

/* ─── Main Content ─────────────────────────────────────────── */
.main-content { flex: 1; padding: 24px; max-width: 1400px; width: 100%; }
.main-footer { padding: 12px 24px; color: var(--text-muted); font-size: .8rem; border-top: 1px solid var(--border); }

/* ─── Page Header ──────────────────────────────────────────── */
.page-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    margin-bottom: 20px;
    gap: 12px;
    flex-wrap: wrap;
}
.page-header h2 { font-size: 1.4rem; font-weight: 700; color: var(--text); }
.page-subtitle { color: var(--text-muted); font-size: .875rem; }
.page-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* ─── Cards ────────────────────────────────────────────────── */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}
.card-header {
    padding: 14px 20px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}
.card-header h3 { font-size: 1rem; font-weight: 600; }
.card-body { padding: 20px; }
.card-body.p-0 { padding: 0; }
.mt-3 { margin-top: 12px; }
.mt-4 { margin-top: 20px; }
.mb-3 { margin-bottom: 12px; }
.card-danger-zone { border-color: #fca5a5; }
.card-success-border { border-color: #86efac; }
.card-summary { border-color: var(--primary); }

/* ─── Metric Cards ─────────────────────────────────────────── */
.cards-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}
.metric-card {
    background: var(--surface);
    border-radius: var(--radius);
    padding: 20px;
    display: flex;
    align-items: center;
    gap: 16px;
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
    transition: transform .15s, box-shadow .15s;
    color: var(--text);
}
.metric-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); text-decoration: none; }
.metric-icon { font-size: 2rem; line-height: 1; }
.metric-value { font-size: 1.6rem; font-weight: 700; line-height: 1; }
.metric-label { font-size: .8rem; color: var(--text-muted); margin-top: 2px; }

.card-green  { border-left: 4px solid var(--success); }
.card-blue   { border-left: 4px solid var(--primary); }
.card-yellow { border-left: 4px solid var(--warning); }
.card-red    { border-left: 4px solid var(--danger); }
.card-orange { border-left: 4px solid var(--orange); }
.card-purple { border-left: 4px solid var(--purple); }
.card-emerald{ border-left: 4px solid var(--emerald); }
.card-action { border-left: 4px solid var(--secondary); background: #f8fafc; }

/* ─── Tables ───────────────────────────────────────────────── */
.table { width: 100%; border-collapse: collapse; }
.table th, .table td { padding: 11px 16px; text-align: left; border-bottom: 1px solid var(--border); font-size: .875rem; }
.table th { font-weight: 600; color: var(--text-muted); background: #f8fafc; font-size: .8rem; text-transform: uppercase; letter-spacing: .03em; }
.table-hover tbody tr:hover { background: #f8fafc; }
.row-danger { background: #fef2f2 !important; }
.row-danger:hover { background: #fee2e2 !important; }
.total-row td { border-top: 2px solid var(--border); font-weight: 600; }
.text-right { text-align: right; }

/* ─── Buttons ──────────────────────────────────────────────── */
.btn {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 8px 16px; border-radius: var(--radius-sm); font-size: .875rem;
    font-weight: 500; cursor: pointer; border: none; transition: all .15s;
    white-space: nowrap;
}
.btn:hover { text-decoration: none; }
.btn-primary  { background: var(--primary);   color: #fff; }
.btn-primary:hover  { background: var(--primary-dk); color: #fff; }
.btn-success  { background: var(--success);   color: #fff; }
.btn-danger   { background: var(--danger);    color: #fff; }
.btn-outline  { background: transparent; border: 1px solid var(--border); color: var(--text); }
.btn-outline:hover  { background: var(--bg); color: var(--text); }
.btn-ghost    { background: transparent; color: var(--text-muted); }
.btn-ghost:hover    { background: var(--bg); color: var(--text); }
.btn-danger-outline { background: transparent; border: 1px solid var(--danger); color: var(--danger); }
.btn-danger-outline:hover { background: var(--danger); color: #fff; }
.btn-block    { width: 100%; justify-content: center; }
.btn-lg       { padding: 12px 20px; font-size: 1rem; }
.btn-sm       { padding: 4px 10px; font-size: .8rem; }

/* ─── Badges ───────────────────────────────────────────────── */
.badge {
    display: inline-block; padding: 3px 8px; border-radius: 20px;
    font-size: .72rem; font-weight: 600; letter-spacing: .02em;
}
.badge-primary   { background: #dbeafe; color: #1d4ed8; }
.badge-success   { background: #dcfce7; color: #15803d; }
.badge-warning   { background: #fef9c3; color: #92400e; }
.badge-danger    { background: #fee2e2; color: #b91c1c; }
.badge-secondary { background: #f1f5f9; color: #475569; }

/* ─── Alerts ───────────────────────────────────────────────── */
.alert {
    display: flex; align-items: center; justify-content: space-between;
    padding: 12px 16px; border-radius: var(--radius); margin-bottom: 16px;
    font-size: .875rem;
}
.alert-success { background: #dcfce7; color: #15803d; border: 1px solid #86efac; }
.alert-error   { background: #fee2e2; color: #b91c1c; border: 1px solid #fca5a5; }
.alert-warning { background: #fef9c3; color: #92400e; border: 1px solid #fde047; }
.alert-info    { background: #e0f2fe; color: #0369a1; border: 1px solid #7dd3fc; }
.alert-close   { background: none; border: none; cursor: pointer; opacity: .6; font-size: 1rem; }
.alert-close:hover { opacity: 1; }

/* ─── Forms ────────────────────────────────────────────────── */
.form-padded { padding: 20px; }
.form-group { display: flex; flex-direction: column; gap: 5px; margin-bottom: 16px; }
.form-group label { font-size: .875rem; font-weight: 500; color: var(--text); }
.form-control {
    padding: 8px 12px; border: 1px solid var(--border); border-radius: var(--radius-sm);
    font-size: .9rem; width: 100%; background: var(--surface); color: var(--text);
    transition: border-color .15s, box-shadow .15s;
}
.form-control:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37,99,235,.15); }
.form-control::placeholder { color: var(--text-light); }
select.form-control { cursor: pointer; }
textarea.form-control { resize: vertical; }
.form-hint { font-size: .78rem; color: var(--text-muted); }
.form-section-title { font-size: .9rem; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: .05em; margin: 20px 0 12px; border-bottom: 1px solid var(--border); padding-bottom: 8px; }
.form-row { display: flex; gap: 12px; flex-wrap: wrap; }
.form-row .form-group { flex: 1; min-width: 180px; }
.form-row .col-1 { flex: 0 0 80px; min-width: 80px; }
.form-row .col-2 { flex: 0 0 200px; min-width: 160px; }
.form-row .col-3 { flex: 1; min-width: 200px; }
.form-row .col-4 { flex: 2; min-width: 240px; }
.form-actions { display: flex; gap: 8px; margin-top: 24px; padding-top: 16px; border-top: 1px solid var(--border); }
.input-prefix { display: flex; align-items: center; border: 1px solid var(--border); border-radius: var(--radius-sm); overflow: hidden; }
.input-prefix span { padding: 8px 10px; background: #f8fafc; color: var(--text-muted); border-right: 1px solid var(--border); font-size: .875rem; white-space: nowrap; }
.input-prefix .form-control { border: none; border-radius: 0; }
.input-prefix .form-control:focus { box-shadow: none; }
.toggle-label { display: flex; align-items: center; gap: 8px; cursor: pointer; font-weight: 500; }
.toggle-label input[type=checkbox] { width: 16px; height: 16px; cursor: pointer; }

/* ─── Filter Bar ───────────────────────────────────────────── */
.filter-bar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.filter-input { flex: 1; min-width: 200px; padding: 7px 12px; border: 1px solid var(--border); border-radius: var(--radius-sm); font-size: .875rem; }
.filter-select { padding: 7px 10px; border: 1px solid var(--border); border-radius: var(--radius-sm); font-size: .875rem; background: var(--surface); }
.filter-tag { display: inline-flex; align-items: center; gap: 4px; }

/* ─── Auth ─────────────────────────────────────────────────── */
.auth-body { background: linear-gradient(135deg, #1e293b 0%, #334155 100%); min-height: 100vh; display: flex; align-items: center; justify-content: center; }
.auth-container { width: 100%; max-width: 400px; padding: 20px; }
.auth-card { background: var(--surface); border-radius: 12px; padding: 36px 32px; box-shadow: 0 20px 60px rgba(0,0,0,.3); }
.auth-logo { text-align: center; margin-bottom: 28px; }
.auth-logo-icon { font-size: 3rem; display: block; margin-bottom: 8px; }
.auth-logo h1 { font-size: 1.6rem; font-weight: 800; color: var(--text); }
.auth-logo p { color: var(--text-muted); font-size: .875rem; margin-top: 4px; }
.auth-form .form-group { margin-bottom: 16px; }
.auth-form .form-group label { display: block; font-size: .875rem; font-weight: 500; margin-bottom: 5px; }
.auth-form .form-control { width: 100%; }
.auth-form .btn-block { margin-top: 8px; padding: 11px; font-size: .95rem; }

/* ─── Detail Grid ──────────────────────────────────────────── */
.detail-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 12px; }
.detail-item { display: flex; flex-direction: column; gap: 2px; }
.detail-item-full { grid-column: 1 / -1; }
.detail-label { font-size: .78rem; text-transform: uppercase; letter-spacing: .05em; color: var(--text-muted); font-weight: 500; }
.detail-value { font-size: .9rem; color: var(--text); }

/* ─── Score ────────────────────────────────────────────────── */
.score-display { display: flex; flex-direction: column; gap: 12px; }
.score-stats { display: flex; gap: 20px; flex-wrap: wrap; margin-top: 8px; }
.score-stat { display: flex; flex-direction: column; align-items: center; gap: 2px; }
.score-stat strong { font-size: 1.3rem; color: var(--text); }
.score-stat span { font-size: .75rem; color: var(--text-muted); }

/* ─── Empty State ──────────────────────────────────────────── */
.empty-state { text-align: center; padding: 48px 24px; color: var(--text-muted); }
.empty-state p { margin-bottom: 16px; }
.empty-state-sm { padding: 16px; text-align: center; color: var(--text-muted); font-size: .875rem; }

/* ─── Grids ────────────────────────────────────────────────── */
.grid-2-col { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; align-items: start; }
.grid-locacao { display: grid; grid-template-columns: 1fr 360px; gap: 20px; align-items: start; }

/* ─── Locação PDV ──────────────────────────────────────────── */
.autocomplete-results {
    position: absolute; z-index: 200; background: var(--surface);
    border: 1px solid var(--border); border-radius: var(--radius-sm);
    box-shadow: var(--shadow-md); width: 100%; max-height: 260px; overflow-y: auto;
}
.autocomplete-item {
    padding: 10px 14px; cursor: pointer; font-size: .875rem;
    border-bottom: 1px solid var(--border);
}
.autocomplete-item:last-child { border-bottom: none; }
.autocomplete-item:hover { background: var(--bg); }
.autocomplete-item .item-name { font-weight: 500; }
.autocomplete-item .item-sub  { font-size: .78rem; color: var(--text-muted); }
.form-group { position: relative; }
.cliente-selecionado {
    display: flex; align-items: center; justify-content: space-between;
    padding: 10px 14px; background: #f0fdf4; border: 1px solid #86efac;
    border-radius: var(--radius-sm); margin-top: 4px;
}
.cliente-info { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; font-size: .875rem; }
.itens-lista { display: flex; flex-direction: column; gap: 8px; }
.item-locacao {
    display: flex; align-items: center; gap: 12px;
    padding: 10px 14px; background: var(--bg); border: 1px solid var(--border);
    border-radius: var(--radius-sm); font-size: .875rem;
}
.item-locacao .item-nome { flex: 1; font-weight: 500; }
.item-locacao .item-valor input { width: 100px; padding: 4px 8px; border: 1px solid var(--border); border-radius: var(--radius-sm); text-align: right; }
.item-locacao .item-remover { background: none; border: none; color: var(--danger); cursor: pointer; font-size: 1rem; padding: 4px; }
.summary-line { display: flex; justify-content: space-between; padding: 8px 0; border-bottom: 1px solid var(--border); font-size: .9rem; }
.summary-total { font-size: 1.1rem; border-bottom: none; padding-top: 12px; }
.atraso-aviso { padding-top: 24px; }

/* ─── Misc ─────────────────────────────────────────────────── */
.actions { display: flex; gap: 6px; white-space: nowrap; }
.link-primary { color: var(--primary); font-weight: 500; }
.link-primary:hover { text-decoration: underline; }
.text-success { color: var(--success); }
.text-danger  { color: var(--danger); }
.text-muted   { color: var(--text-muted); }
.mt-2 { margin-top: 8px; }
.thumb-sm { width: 36px; height: 36px; object-fit: cover; border-radius: 4px; }
.thumb-placeholder { font-size: 1.4rem; display: inline-block; width: 36px; text-align: center; }
.equip-name-cell { display: flex; align-items: center; gap: 8px; }
.equip-foto-principal { width: 100%; max-height: 220px; object-fit: cover; border-radius: var(--radius) var(--radius) 0 0; }
.equip-list { padding-left: 18px; }
.equip-list li { font-size: .875rem; margin-bottom: 4px; }
.pagination { display: flex; gap: 4px; align-items: center; margin-top: 16px; }
.page-btn { padding: 5px 10px; border: 1px solid var(--border); border-radius: var(--radius-sm); font-size: .875rem; color: var(--text); background: var(--surface); }
.page-btn:hover { background: var(--bg); text-decoration: none; }
.page-btn.active { background: var(--primary); color: #fff; border-color: var(--primary); }
.page-ellipsis { padding: 5px 6px; color: var(--text-muted); }
.current-photo { display: flex; gap: 8px; align-items: center; margin-bottom: 8px; }
.current-photo small { color: var(--text-muted); }
.align-end { align-items: flex-end; }

/* ─── Modal ────────────────────────────────────────────────── */
.modal-overlay {
    position: fixed; inset: 0;
    background: rgba(0,0,0,.45);
    display: flex; align-items: center; justify-content: center;
    z-index: 1000; padding: 16px;
}
.modal-box {
    background: var(--surface);
    border-radius: var(--radius);
    box-shadow: 0 20px 40px rgba(0,0,0,.15);
    width: 100%; max-width: 480px;
    padding: 1.5rem;
}
.modal-title { font-size: 1.05rem; font-weight: 700; margin-bottom: 1rem; }

/* ─── Table extras ─────────────────────────────────────────── */
.table-total td { background: #f8fafc; font-weight: 600; border-top: 2px solid var(--border); }
.row-highlight { background: #eff6ff; }

/* ─── Form extras ──────────────────────────────────────────── */
.form-divider { border: none; border-top: 1px solid var(--border); margin: 1.25rem 0; }
.form-hint-box { background: #f0f9ff; border: 1px solid #bae6fd; border-radius: var(--radius-sm); padding: .75rem 1rem; margin-bottom: 1rem; font-size: .85rem; }
.form-hint-box ul { margin: .5rem 0 0 1.25rem; }
.form-static { padding: .5rem 0; font-weight: 500; }

/* ─── Responsivo ───────────────────────────────────────────── */
@media (max-width: 900px) {
    .grid-2-col { grid-template-columns: 1fr; }
    .grid-locacao { grid-template-columns: 1fr; }
}

@media (max-width: 768px) {
    .sidebar { transform: translateX(-100%); }
    .sidebar.open { transform: translateX(0); }
    .layout-main { margin-left: 0; }
    .sidebar-toggle { display: flex; }
    .main-content { padding: 16px; }
    .cards-grid { grid-template-columns: repeat(2, 1fr); }
    .table { display: block; overflow-x: auto; }
    .form-row { flex-direction: column; }
    .form-row .col-1, .form-row .col-2, .form-row .col-3, .form-row .col-4 { flex: none; width: 100%; min-width: 0; }
}

@media (max-width: 480px) {
    .cards-grid { grid-template-columns: 1fr; }
    .page-header { flex-direction: column; }
}
