/* ==========================================================================
   OS.CSS — Módulo de Ordens de Serviço | Dadon Climatização
   ========================================================================== */

:root {
    --os-bg: #0f1117;
    --os-surface: #1a1d27;
    --os-card: #20243a;
    --os-border: #2e3354;
    --os-blue: #0ea5e9;
    --os-blue-dark: #0284c7;
    --os-green: #22c55e;
    --os-orange: #f59e0b;
    --os-red: #ef4444;
    --os-purple: #a855f7;
    --os-text: #e2e8f0;
    --os-muted: #94a3b8;
    --os-radius: 12px;
    --os-shadow: 0 4px 24px rgba(0,0,0,0.35);
    --sidebar-w: 260px;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; font-family: 'Outfit', 'Montserrat', sans-serif; background: var(--os-bg); color: var(--os-text); line-height: 1.6; }
a { color: var(--os-blue); text-decoration: none; }
button { cursor: pointer; font-family: inherit; }
input, select, textarea { font-family: inherit; }

/* ---- LAYOUT ---- */
.os-wrapper { display: flex; height: 100vh; overflow: hidden; }

/* ---- SIDEBAR ---- */
.os-sidebar {
    width: var(--sidebar-w); min-width: var(--sidebar-w);
    background: var(--os-surface); border-right: 1px solid var(--os-border);
    display: flex; flex-direction: column; overflow-y: auto; z-index: 100;
    transition: transform 0.3s ease;
}
.os-sidebar-header { padding: 24px 20px 20px; border-bottom: 1px solid var(--os-border); }
.os-sidebar-brand { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.os-sidebar-brand .brand-icon {
    width: 36px; height: 36px;
    background: linear-gradient(135deg, var(--os-blue), var(--os-blue-dark));
    border-radius: 8px; display: flex; align-items: center; justify-content: center;
    color: #fff; font-size: 16px; flex-shrink: 0;
}
.brand-names { display: flex; flex-direction: column; }
.brand-names .brand-text { font-size: 15px; font-weight: 700; color: var(--os-text); }
.brand-names .brand-sub { font-size: 11px; color: var(--os-muted); }
.os-badge-admin {
    display: inline-flex; align-items: center; gap: 5px;
    background: rgba(14,165,233,0.15); color: var(--os-blue);
    font-size: 11px; font-weight: 600; padding: 3px 10px;
    border-radius: 20px; border: 1px solid rgba(14,165,233,0.3);
}
.os-nav { flex: 1; padding: 16px 12px; }
.os-nav-section { margin-bottom: 24px; }
.os-nav-label { font-size: 10px; font-weight: 700; letter-spacing: 1.2px; color: var(--os-muted); text-transform: uppercase; padding: 0 8px; margin-bottom: 6px; display: block; }
.os-nav-btn {
    display: flex; align-items: center; gap: 10px; width: 100%;
    background: transparent; border: none; color: var(--os-muted);
    font-size: 14px; font-weight: 500; padding: 10px 12px;
    border-radius: 8px; text-align: left; transition: all 0.2s; margin-bottom: 2px;
}
.os-nav-btn i { width: 18px; text-align: center; font-size: 15px; flex-shrink: 0; }
.os-nav-btn:hover { background: rgba(14,165,233,0.08); color: var(--os-text); }
.os-nav-btn.active { background: rgba(14,165,233,0.15); color: var(--os-blue); font-weight: 600; }
.os-sidebar-footer { padding: 16px 12px; border-top: 1px solid var(--os-border); display: flex; flex-direction: column; gap: 8px; }

/* ---- MAIN CONTENT ---- */
.os-content { flex: 1; display: flex; flex-direction: column; overflow: hidden; }
.os-topbar {
    background: var(--os-surface); border-bottom: 1px solid var(--os-border);
    padding: 0 28px; height: 64px;
    display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-shrink: 0;
}
.os-topbar-left { display: flex; align-items: center; gap: 12px; }
.os-topbar h1 { font-size: 18px; font-weight: 700; color: var(--os-text); }
.os-topbar-desc { font-size: 13px; color: var(--os-muted); }
.os-topbar-right { display: flex; align-items: center; gap: 10px; }
.btn-mobile-menu { display: none; background: transparent; border: none; color: var(--os-muted); font-size: 20px; padding: 6px; }

/* ---- PANELS ---- */
.os-panel-container { flex: 1; overflow-y: auto; padding: 28px; }
.os-panel { display: none; }
.os-panel.active { display: block; }

/* ---- CARDS ---- */
.os-card { background: var(--os-card); border: 1px solid var(--os-border); border-radius: var(--os-radius); padding: 24px; margin-bottom: 20px; box-shadow: var(--os-shadow); }
.os-card-title { font-size: 15px; font-weight: 700; color: var(--os-text); margin-bottom: 16px; display: flex; align-items: center; gap: 8px; }
.os-card-title i { color: var(--os-blue); }

/* ---- STATS GRID ---- */
.os-stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 16px; margin-bottom: 24px; }
.os-stat-card { background: var(--os-card); border: 1px solid var(--os-border); border-radius: var(--os-radius); padding: 20px; display: flex; align-items: center; gap: 14px; }
.os-stat-icon { width: 46px; height: 46px; border-radius: 10px; display: flex; align-items: center; justify-content: center; font-size: 20px; flex-shrink: 0; }
.os-stat-icon.blue { background: rgba(14,165,233,0.15); color: var(--os-blue); }
.os-stat-icon.green { background: rgba(34,197,94,0.15); color: var(--os-green); }
.os-stat-icon.orange { background: rgba(245,158,11,0.15); color: var(--os-orange); }
.os-stat-icon.red { background: rgba(239,68,68,0.15); color: var(--os-red); }
.os-stat-value { font-size: 26px; font-weight: 800; color: var(--os-text); line-height: 1; }
.os-stat-label { font-size: 12px; color: var(--os-muted); margin-top: 3px; }

/* ---- TOOLBAR ---- */
.os-toolbar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 20px; }
.os-search-box { position: relative; flex: 1; min-width: 200px; }
.os-search-box i { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--os-muted); font-size: 14px; }
.os-search-box input { width: 100%; height: 40px; background: var(--os-surface); border: 1px solid var(--os-border); border-radius: 8px; color: var(--os-text); padding: 0 12px 0 38px; font-size: 14px; outline: none; transition: border-color 0.2s; }
.os-search-box input:focus { border-color: var(--os-blue); }
.os-search-box input::placeholder { color: var(--os-muted); }
.os-filter-select { height: 40px; background: var(--os-surface); border: 1px solid var(--os-border); border-radius: 8px; color: var(--os-text); padding: 0 12px; font-size: 14px; outline: none; cursor: pointer; }
.os-filter-select:focus { border-color: var(--os-blue); }

/* ---- TABLE ---- */
.os-table-wrapper { overflow-x: auto; border-radius: 8px; }
.os-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.os-table th { background: rgba(46,51,84,0.5); color: var(--os-muted); font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.8px; padding: 12px 16px; text-align: left; white-space: nowrap; }
.os-table td { padding: 14px 16px; border-bottom: 1px solid var(--os-border); color: var(--os-text); vertical-align: middle; }
.os-table tbody tr { transition: background 0.15s; }
.os-table tbody tr:hover { background: rgba(46,51,84,0.3); }
.os-table tbody tr:last-child td { border-bottom: none; }
.os-table .os-num { font-weight: 700; color: var(--os-blue); font-family: monospace; font-size: 13px; }
.os-table .os-client-name { font-weight: 600; }
.os-table .os-value { font-weight: 700; color: var(--os-green); }

/* ---- BADGES ---- */
.os-badge { display: inline-flex; align-items: center; gap: 5px; padding: 4px 10px; border-radius: 20px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.os-badge.aberta { background: rgba(14,165,233,0.15); color: var(--os-blue); border: 1px solid rgba(14,165,233,0.3); }
.os-badge.em_andamento { background: rgba(245,158,11,0.15); color: var(--os-orange); border: 1px solid rgba(245,158,11,0.3); }
.os-badge.concluida { background: rgba(34,197,94,0.15); color: var(--os-green); border: 1px solid rgba(34,197,94,0.3); }
.os-badge.cancelada { background: rgba(239,68,68,0.15); color: var(--os-red); border: 1px solid rgba(239,68,68,0.3); }

/* ---- BUTTONS ---- */
.btn-os { display: inline-flex; align-items: center; gap: 7px; border: none; border-radius: 8px; font-size: 14px; font-weight: 600; padding: 9px 18px; transition: all 0.2s; }
.btn-os-primary { background: var(--os-blue); color: #fff; }
.btn-os-primary:hover { background: var(--os-blue-dark); transform: translateY(-1px); }
.btn-os-success { background: var(--os-green); color: #fff; }
.btn-os-success:hover { filter: brightness(1.1); }
.btn-os-danger { background: transparent; border: 1px solid var(--os-red); color: var(--os-red); }
.btn-os-danger:hover { background: rgba(239,68,68,0.1); }
.btn-os-ghost { background: transparent; border: 1px solid var(--os-border); color: var(--os-muted); }
.btn-os-ghost:hover { border-color: var(--os-blue); color: var(--os-blue); }
.btn-os-back { background: transparent; border: none; color: var(--os-muted); font-size: 13px; padding: 6px 0; display: inline-flex; align-items: center; gap: 6px; }
.btn-os-back:hover { color: var(--os-text); }
.btn-os-sm { padding: 5px 10px; font-size: 12px; border-radius: 6px; }
.btn-icon-only { width: 32px; height: 32px; border-radius: 6px; border: 1px solid var(--os-border); background: transparent; color: var(--os-muted); display: inline-flex; align-items: center; justify-content: center; font-size: 14px; transition: all 0.15s; }
.btn-icon-only:hover { background: rgba(14,165,233,0.1); color: var(--os-blue); border-color: var(--os-blue); }
.btn-icon-only.danger:hover { background: rgba(239,68,68,0.1); color: var(--os-red); border-color: var(--os-red); }
.btn-icon-only.green:hover { background: rgba(34,197,94,0.1); color: var(--os-green); border-color: var(--os-green); }

/* ---- FORMS ---- */
.os-form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 18px; }
.os-form-group { display: flex; flex-direction: column; gap: 6px; }
.os-form-group.full { grid-column: 1 / -1; }
.os-form-label { font-size: 13px; font-weight: 600; color: var(--os-muted); }
.os-form-label span { color: var(--os-red); margin-left: 3px; }
.os-form-input, .os-form-select, .os-form-textarea { background: var(--os-surface); border: 1px solid var(--os-border); border-radius: 8px; color: var(--os-text); padding: 10px 14px; font-size: 14px; outline: none; transition: border-color 0.2s; width: 100%; }
.os-form-input:focus, .os-form-select:focus, .os-form-textarea:focus { border-color: var(--os-blue); }
.os-form-input::placeholder, .os-form-textarea::placeholder { color: rgba(148,163,184,0.5); }
.os-form-textarea { resize: vertical; min-height: 100px; }
.os-form-select option { background: var(--os-card); }
.os-valor-row { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 18px; align-items: end; }
.os-total-display { background: rgba(34,197,94,0.08); border: 1px solid rgba(34,197,94,0.25); border-radius: 8px; padding: 10px 14px; font-size: 20px; font-weight: 800; color: var(--os-green); display: flex; align-items: center; gap: 6px; }
.os-form-actions { display: flex; align-items: center; justify-content: flex-end; gap: 10px; margin-top: 24px; padding-top: 20px; border-top: 1px solid var(--os-border); }

/* ---- MODAL ---- */
.os-modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.6); backdrop-filter: blur(4px); z-index: 900; display: flex; align-items: center; justify-content: center; padding: 20px; opacity: 0; pointer-events: none; transition: opacity 0.25s; }
.os-modal-overlay.open { opacity: 1; pointer-events: all; }
.os-modal { background: var(--os-card); border: 1px solid var(--os-border); border-radius: 16px; width: 100%; max-width: 540px; max-height: 90vh; overflow-y: auto; box-shadow: 0 20px 60px rgba(0,0,0,0.5); transform: translateY(20px) scale(0.97); transition: transform 0.25s; }
.os-modal-overlay.open .os-modal { transform: translateY(0) scale(1); }
.os-modal-header { display: flex; align-items: center; justify-content: space-between; padding: 20px 24px 16px; border-bottom: 1px solid var(--os-border); }
.os-modal-header h2 { font-size: 17px; font-weight: 700; display: flex; align-items: center; gap: 8px; }
.os-modal-header h2 i { color: var(--os-blue); }
.os-modal-close { background: transparent; border: none; color: var(--os-muted); font-size: 18px; }
.os-modal-close:hover { color: var(--os-text); }
.os-modal-body { padding: 24px; }
.os-modal-footer { display: flex; justify-content: flex-end; gap: 10px; padding: 16px 24px; border-top: 1px solid var(--os-border); }

/* ---- CONFIRM MODAL ---- */
.os-confirm-icon { font-size: 36px; text-align: center; margin-bottom: 16px; }
.os-confirm-text { text-align: center; font-size: 15px; color: var(--os-text); line-height: 1.5; }
.os-confirm-text strong { color: var(--os-red); }

/* ---- TOAST ---- */
.os-toast-container { position: fixed; bottom: 24px; right: 24px; z-index: 9999; display: flex; flex-direction: column; gap: 10px; pointer-events: none; }
.os-toast { background: var(--os-card); border: 1px solid var(--os-border); border-radius: 10px; padding: 14px 18px; display: flex; align-items: center; gap: 12px; min-width: 280px; max-width: 380px; box-shadow: var(--os-shadow); animation: slideInToast 0.3s ease; pointer-events: all; }
@keyframes slideInToast { from { opacity: 0; transform: translateX(20px); } to { opacity: 1; transform: translateX(0); } }
.os-toast.success { border-left: 3px solid var(--os-green); }
.os-toast.error { border-left: 3px solid var(--os-red); }
.os-toast.info { border-left: 3px solid var(--os-blue); }
.os-toast-icon { font-size: 18px; flex-shrink: 0; }
.os-toast.success .os-toast-icon { color: var(--os-green); }
.os-toast.error .os-toast-icon { color: var(--os-red); }
.os-toast.info .os-toast-icon { color: var(--os-blue); }
.os-toast-msg { font-size: 14px; color: var(--os-text); flex: 1; }

/* ---- EMPTY STATE ---- */
.os-empty { text-align: center; padding: 60px 20px; color: var(--os-muted); }
.os-empty i { font-size: 48px; opacity: 0.3; margin-bottom: 16px; display: block; }
.os-empty p { font-size: 15px; }

/* ---- MODULE SELECTOR ---- */
.module-selector-wrapper {
    display: flex; align-items: center; justify-content: center; min-height: 100vh;
    background: radial-gradient(ellipse at 30% 40%, rgba(14,165,233,0.08), transparent 60%),
                radial-gradient(ellipse at 70% 70%, rgba(168,85,247,0.06), transparent 60%), #0f1117;
    padding: 20px;
}
.module-selector-inner { width: 100%; max-width: 720px; text-align: center; }
.module-selector-logo { margin-bottom: 36px; }
.ms-icon { width: 60px; height: 60px; background: linear-gradient(135deg, #0ea5e9, #0284c7); border-radius: 16px; display: inline-flex; align-items: center; justify-content: center; font-size: 26px; color: #fff; margin-bottom: 14px; box-shadow: 0 8px 24px rgba(14,165,233,0.3); }
.ms-title { font-size: 22px; font-weight: 800; color: #e2e8f0; }
.ms-sub { font-size: 14px; color: #64748b; margin-top: 4px; }
.module-selector-subtitle { font-size: 15px; color: #94a3b8; margin-bottom: 32px; }
.module-cards-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; margin-bottom: 32px; }
.module-card { background: #1a1d27; border: 1px solid #2e3354; border-radius: 16px; padding: 32px 24px; cursor: pointer; text-align: left; display: flex; flex-direction: column; gap: 12px; transition: all 0.25s ease; position: relative; overflow: hidden; }
.module-card.mod-cms:hover { transform: translateY(-4px); border-color: #0ea5e9; box-shadow: 0 12px 40px rgba(14,165,233,0.2); }
.module-card.mod-os:hover { transform: translateY(-4px); border-color: #a855f7; box-shadow: 0 12px 40px rgba(168,85,247,0.2); }
.module-card-icon { width: 52px; height: 52px; border-radius: 12px; display: flex; align-items: center; justify-content: center; font-size: 22px; flex-shrink: 0; }
.mod-cms .module-card-icon { background: rgba(14,165,233,0.15); color: #0ea5e9; }
.mod-os .module-card-icon { background: rgba(168,85,247,0.15); color: #a855f7; }
.module-card-title { font-size: 18px; font-weight: 700; color: #e2e8f0; }
.module-card-desc { font-size: 13px; color: #64748b; line-height: 1.5; }
.module-card-arrow { align-self: flex-start; margin-top: 8px; font-size: 13px; font-weight: 600; display: flex; align-items: center; gap: 5px; }
.mod-cms .module-card-arrow { color: #0ea5e9; }
.mod-os .module-card-arrow { color: #a855f7; }
.module-logout-row { display: flex; justify-content: center; }

/* ---- PDF / PRINT DOCUMENT ---- */
.pdf-document { display: none; }
@media print {
    body { background: #fff !important; margin: 0; padding: 0; }
    .os-wrapper, .os-toast-container, .os-modal-overlay { display: none !important; }
    .pdf-document { 
        display: block !important; 
        width: 100%;
        -webkit-print-color-adjust: exact !important;
        print-color-adjust: exact !important;
        color: #111;
    }
}

/* ---- RESPONSIVE ---- */
@media (max-width: 768px) {
    .os-sidebar { position: fixed; top: 0; left: 0; bottom: 0; transform: translateX(-100%); }
    .os-sidebar.open { transform: translateX(0); box-shadow: 8px 0 24px rgba(0,0,0,0.5); }
    .btn-mobile-menu { display: flex; }
    .os-overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.5); z-index: 99; }
    .os-overlay.open { display: block; }
    .os-panel-container { padding: 16px; }
    .os-topbar { padding: 0 16px; }
    .os-stats-grid { grid-template-columns: 1fr 1fr; }
    .module-cards-grid { grid-template-columns: 1fr; }
    .os-form-grid { grid-template-columns: 1fr; }
    .os-toolbar { flex-direction: column; align-items: stretch; }
    .os-search-box { width: 100%; max-width: none; }
    
    /* Responsive Table to avoid horizontal scroll */
    .os-table-wrapper { overflow-x: hidden; }
    .os-table, .os-table thead, .os-table tbody, .os-table th, .os-table td, .os-table tr { display: block; }
    .os-table thead tr { position: absolute; top: -9999px; left: -9999px; }
    .os-table tr { border: 1px solid var(--os-border); border-radius: 8px; margin-bottom: 16px; background: var(--os-card); padding: 10px; }
    .os-table td { border: none; border-bottom: 1px solid rgba(255,255,255,0.05); position: relative; padding-left: 50%; min-height: 40px; display: flex; align-items: center; justify-content: flex-end; text-align: right; }
    .os-table td:last-child { border-bottom: 0; }
    .os-table td::before { 
        content: attr(data-label); position: absolute; left: 10px; top: 50%; transform: translateY(-50%);
        font-size: 11px; font-weight: 700; color: var(--os-muted); text-transform: uppercase; white-space: nowrap; text-align: left;
    }
}
@media (max-width: 480px) {
    .os-stats-grid { grid-template-columns: 1fr; }
    .os-valor-row { grid-template-columns: 1fr; gap: 10px; }
    .os-form-actions { flex-direction: column; }
    .os-form-actions button { width: 100%; }
    .os-modal-header h2 { font-size: 15px; }
}
