/* ============================================================
   ISG.inf Design System — Service Desk
   Baseado em ESTILO.md (XML Drive / ISG.inf)
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Nunito+Sans:wght@300;400;600;700;800&display=swap');

/* ── Variáveis ─────────────────────────────────────────────── */
:root {
    --teal:        #1565c0;
    --teal-dark:   #0d47a1;
    --teal-light:  #e3f2fd;
    --teal-mid:    #bbdefb;
    --topbar-bg:   #0d47a1;
    --sidebar-bg:  #ffffff;
    --sidebar-w:   210px;
    --topbar-h:    52px;
    --body-bg:     #f4f6f8;
    --card-bg:     #ffffff;
    --border:      #e0e4ea;
    --border-dark: #c8cdd6;
    --text-main:   #2d3748;
    --text-sub:    #718096;
    --text-muted:  #a0aec0;
    --danger:      #ef5350;
    --warning:     #ffa726;
    --info:        #42a5f5;
    --green:       #66bb6a;
    --radius:      6px;
    --shadow-sm:   0 1px 4px rgba(0,0,0,0.07);
    --shadow:      0 2px 10px rgba(0,0,0,0.10);
    --font:        'Nunito Sans', sans-serif;
}

/* ── Reset base ─────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }

body {
    font-family: var(--font);
    font-size: 13px;
    color: var(--text-main);
    background: var(--body-bg);
    margin: 0;
    padding: 0;
}

a { color: var(--teal); text-decoration: none; }
a:hover { color: var(--teal-dark); }

/* ── Topbar ─────────────────────────────────────────────────── */
#topbar {
    position: fixed;
    top: 0; left: 0; right: 0;
    height: var(--topbar-h);
    background: linear-gradient(90deg, #0a3880 0%, #0d47a1 50%, #1565c0 100%);
    display: flex;
    align-items: center;
    padding: 0 16px 0 0;
    z-index: 1000;
    box-shadow: 0 2px 8px rgba(0,0,0,0.18);
}

.brand {
    width: var(--sidebar-w);
    flex-shrink: 0;
    display: flex;
    align-items: center;
    padding: 0 14px;
    height: 100%;
    background: rgba(0,0,0,0.12);
    border-right: 1px solid rgba(255,255,255,0.1);
}

.brand a { display: flex; align-items: center; gap: 10px; text-decoration: none; }
.brand-text { color: #fff; font-size: 14px; font-weight: 700; line-height: 1.2; }
.brand-sub   { color: rgba(255,255,255,0.55); font-size: 10px; font-weight: 400; }

.topbar-right {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 6px;
}

.topbar-btn {
    width: 34px; height: 34px;
    border-radius: 50%;
    background: rgba(255,255,255,0.13);
    border: 1.5px solid rgba(255,255,255,0.25);
    display: flex; align-items: center; justify-content: center;
    color: #fff;
    font-size: 14px;
    cursor: pointer;
    transition: background .15s;
    text-decoration: none;
}
.topbar-btn:hover { background: rgba(255,255,255,0.22); color: #fff; }

.topbar-user {
    display: flex; align-items: center; gap: 8px;
    color: rgba(255,255,255,0.85);
    font-size: 12px; font-weight: 600;
    padding: 0 8px;
}

/* ── Sidebar ─────────────────────────────────────────────────── */
#sidebar {
    position: fixed;
    top: var(--topbar-h); left: 0;
    width: var(--sidebar-w);
    height: calc(100vh - var(--topbar-h));
    background: var(--sidebar-bg);
    border-right: 1px solid var(--border);
    overflow-y: auto;
    z-index: 900;
    padding: 10px 0 20px;
}

.sb-label {
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    color: var(--text-muted);
    padding: 12px 16px 4px;
}

.sb-link {
    display: flex;
    align-items: center;
    gap: 9px;
    padding: 8px 16px;
    color: var(--text-sub);
    font-size: 13px;
    font-weight: 600;
    border-left: 3px solid transparent;
    transition: all .15s;
    text-decoration: none;
    cursor: pointer;
}
.sb-link i { width: 16px; text-align: center; font-size: 13px; }
.sb-link:hover {
    background: var(--teal-light);
    color: var(--teal);
    border-left-color: var(--teal-mid);
    text-decoration: none;
}
.sb-link.active {
    background: var(--teal-light);
    color: var(--teal);
    border-left-color: var(--teal);
    font-weight: 700;
}

.sb-divider {
    height: 1px;
    background: var(--border);
    margin: 6px 12px;
}

.sb-badge {
    margin-left: auto;
    font-size: 9px;
    font-weight: 700;
    padding: 2px 6px;
    border-radius: 10px;
    text-transform: uppercase;
    letter-spacing: 0.4px;
}
.sb-badge.beta  { background: #e3f2fd; color: #1565c0; }
.sb-badge.new   { background: #e8f5e9; color: #2e7d32; }

/* ── Main content ───────────────────────────────────────────── */
#main-content {
    margin-left: var(--sidebar-w);
    margin-top: var(--topbar-h);
    padding: 20px 24px;
    min-height: calc(100vh - var(--topbar-h));
}

/* ── Breadcrumb ─────────────────────────────────────────────── */
.xd-breadcrumb {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    color: var(--text-muted);
    margin-bottom: 14px;
}
.xd-breadcrumb a { color: var(--text-sub); }
.xd-breadcrumb a:hover { color: var(--teal); }
.xd-breadcrumb .sep { color: var(--border-dark); }
.xd-breadcrumb .current { color: var(--text-main); font-weight: 600; }

/* ── Page header ────────────────────────────────────────────── */
.page-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    margin-bottom: 16px;
}
.page-title {
    font-size: 18px;
    font-weight: 700;
    color: var(--text-main);
    display: flex;
    align-items: center;
    gap: 8px;
}
.page-subtitle {
    font-size: 12px;
    color: var(--text-sub);
    margin-top: 3px;
}

/* ── Cards ──────────────────────────────────────────────────── */
.xd-card {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
}

/* ── Botões ─────────────────────────────────────────────────── */
.btn-teal {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: var(--teal);
    color: #fff;
    border: none;
    border-radius: var(--radius);
    padding: 7px 16px;
    font-family: var(--font);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: background .15s;
    text-decoration: none;
}
.btn-teal:hover { background: var(--teal-dark); color: #fff; }

.btn-outline {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: #fff;
    color: var(--teal);
    border: 1.5px solid var(--teal-mid);
    border-radius: var(--radius);
    padding: 6px 14px;
    font-family: var(--font);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all .15s;
    text-decoration: none;
}
.btn-outline:hover { background: var(--teal-light); color: var(--teal-dark); border-color: var(--teal); }

.btn-shortcut {
    background: var(--teal-light);
    color: var(--teal);
    border: 1px solid var(--teal-mid);
    border-radius: var(--radius);
    padding: 5px 12px;
    font-family: var(--font);
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: all .15s;
}
.btn-shortcut:hover { background: var(--teal-mid); }

.btn-danger {
    display: inline-flex; align-items: center; gap: 6px;
    background: var(--danger); color: #fff; border: none;
    border-radius: var(--radius); padding: 7px 16px;
    font-family: var(--font); font-size: 13px; font-weight: 600;
    cursor: pointer; transition: background .15s;
}
.btn-danger:hover { background: #c62828; color: #fff; }

/* ── Inputs ─────────────────────────────────────────────────── */
.f-label {
    display: block;
    font-size: 11px;
    font-weight: 700;
    color: var(--text-sub);
    margin-bottom: 4px;
    text-transform: uppercase;
    letter-spacing: 0.4px;
}

.xd-input {
    width: 100%;
    padding: 7px 10px;
    border: 1px solid var(--border-dark);
    border-radius: var(--radius);
    font-family: var(--font);
    font-size: 13px;
    color: var(--text-main);
    background: #fff;
    transition: border-color .15s, box-shadow .15s;
    outline: none;
}
.xd-input:focus {
    border-color: var(--teal);
    box-shadow: 0 0 0 3px rgba(21,101,192,0.12);
    background: var(--teal-light);
}
.xd-input::placeholder { color: var(--text-muted); }

.date-pair { display: flex; align-items: center; gap: 6px; }
.date-pair span { color: var(--text-muted); font-size: 11px; }

/* ── Tabela ─────────────────────────────────────────────────── */
.table-wrapper {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
}

.table-scroll { overflow-x: auto; }

.nfe-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 12.5px;
}

.nfe-table thead tr {
    background: linear-gradient(180deg, #f8fafc 0%, #f0f4f8 100%);
    border-bottom: 2px solid var(--border-dark);
}

.nfe-table th {
    padding: 10px 12px;
    font-size: 11px;
    font-weight: 700;
    color: var(--text-sub);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    white-space: nowrap;
}

.nfe-table td {
    padding: 9px 12px;
    border-bottom: 1px solid var(--border);
    color: var(--text-main);
    vertical-align: middle;
}

.nfe-table tbody tr:last-child td { border-bottom: none; }

.nfe-table tbody tr:hover td { background: #f7faff; }

/* Status de linha */
.row-novo     { background: #e3f2fd; }
.row-alta     { background: #fff8e1; }
.row-final    { background: #f1f8e9; }
.row-encerr   { background: #fafafa; color: var(--text-muted); }
.row-clickable { cursor: pointer; }
.row-clickable:hover td { background: #dbeafe !important; }

/* ── Badges de status/prioridade ────────────────────────────── */
.badge-status {
    display: inline-flex; align-items: center; gap: 4px;
    padding: 3px 8px;
    border-radius: 10px;
    font-size: 11px;
    font-weight: 700;
    white-space: nowrap;
}
.badge-novo    { background: #e3f2fd; color: #1565c0; }
.badge-atend   { background: #e8f5e9; color: #2e7d32; }
.badge-pausado { background: #fff8e1; color: #e65100; }
.badge-final   { background: #ede7f6; color: #4527a0; }
.badge-encerr  { background: #f5f5f5; color: #616161; }

.badge-alta   { background: #ffebee; color: #c62828; font-size: 11px; padding: 2px 7px; border-radius: 10px; font-weight: 700; }
.badge-media  { background: #fff8e1; color: #e65100; font-size: 11px; padding: 2px 7px; border-radius: 10px; font-weight: 700; }
.badge-baixa  { background: #f5f5f5; color: #616161; font-size: 11px; padding: 2px 7px; border-radius: 10px; font-weight: 700; }

/* ── Botões de ação na tabela ───────────────────────────────── */
.actions-cell { display: flex; align-items: center; gap: 4px; }

.action-btn {
    width: 28px; height: 28px;
    border-radius: 5px;
    display: inline-flex; align-items: center; justify-content: center;
    font-size: 12px;
    text-decoration: none;
    transition: all .15s;
    cursor: pointer;
    border: none;
    background: transparent;
}
.action-btn.view    { color: #1565c0; background: #e3f2fd; }
.action-btn.view:hover { background: #bbdefb; }
.action-btn.edit    { color: #2e7d32; background: #e8f5e9; }
.action-btn.edit:hover { background: #c8e6c9; }
.action-btn.close   { color: #6a1b9a; background: #f3e5f5; }
.action-btn.close:hover { background: #e1bee7; }
.action-btn.print   { color: #37474f; background: #eceff1; }
.action-btn.print:hover { background: #cfd8dc; }
.action-btn.money   { color: #e65100; background: #fff3e0; }
.action-btn.money:hover { background: #ffe0b2; }

/* ── Modal ──────────────────────────────────────────────────── */
.modal-content { border: none; border-radius: 10px; box-shadow: 0 8px 30px rgba(0,0,0,0.15); }
.modal-header  { border-bottom: 1px solid var(--border); padding: 14px 20px; }
.modal-title   { font-weight: 700; font-size: 15px; color: var(--text-main); }
.modal-body    { padding: 20px; }
.btn-close     { opacity: 0.5; }
.btn-close:hover { opacity: 1; }

/* ── Overlay de loading ─────────────────────────────────────── */
#query-overlay {
    display: none; position: fixed; inset: 0;
    background: rgba(255,255,255,0.82);
    z-index: 9999;
    flex-direction: column; align-items: center; justify-content: center;
    gap: 16px;
    backdrop-filter: blur(3px);
}
#query-overlay .ov-spinner {
    width: 44px; height: 44px;
    border: 4px solid var(--border);
    border-top-color: var(--teal);
    border-radius: 50%;
    animation: spin .8s linear infinite;
}
#query-overlay .ov-msg { font-size: 14px; font-weight: 600; color: var(--text-sub); }
#query-overlay .ov-sub { font-size: 12px; color: var(--text-muted); }

/* ── Spinner inline ─────────────────────────────────────────── */
.spinner {
    width: 20px; height: 20px;
    border: 3px solid var(--border);
    border-top-color: var(--teal);
    border-radius: 50%;
    animation: spin .7s linear infinite;
    flex-shrink: 0;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ── Paginação ──────────────────────────────────────────────── */
.pagination-bar {
    display: flex; align-items: center; justify-content: space-between;
    padding: 10px 14px;
    border-top: 1px solid var(--border);
    background: #fafbfc;
}
.pagination-info { font-size: 12px; color: var(--text-sub); }
.pagination-controls { display: flex; gap: 4px; }
.pag-btn {
    min-width: 30px; height: 30px;
    border: 1px solid var(--border-dark);
    background: #fff; color: var(--text-sub);
    border-radius: 5px; font-family: var(--font);
    font-size: 12px; font-weight: 600;
    cursor: pointer; transition: all .15s;
    padding: 0 8px;
}
.pag-btn:hover    { background: var(--teal-light); border-color: var(--teal); color: var(--teal); }
.pag-btn.active   { background: var(--teal); border-color: var(--teal); color: #fff; }
.pag-btn:disabled { opacity: 0.4; cursor: default; }

/* ── Flatpickr tema ISG ─────────────────────────────────────── */
.flatpickr-input { cursor: pointer !important; }
.flatpickr-calendar { font-family: var(--font) !important; border: 1px solid var(--border-dark) !important; border-radius: 8px !important; box-shadow: var(--shadow) !important; }
.flatpickr-day.selected, .flatpickr-day.selected:hover { background: var(--teal) !important; border-color: var(--teal) !important; }
.flatpickr-day:hover { background: var(--teal-light) !important; }
.flatpickr-months .flatpickr-month { background: var(--teal) !important; color: #fff !important; border-radius: 8px 8px 0 0 !important; }
.flatpickr-current-month .flatpickr-monthDropdown-months,
.flatpickr-current-month input.cur-year { color: #fff !important; }
.flatpickr-weekday { color: var(--teal-dark) !important; font-weight: 700 !important; }

/* ── Tela de login ──────────────────────────────────────────── */
.logon-page {
    min-height: 100vh;
    background: linear-gradient(135deg, #0a3880 0%, #0d47a1 40%, #1565c0 100%);
    display: flex; align-items: center; justify-content: center;
    padding: 20px;
}
.logon-card {
    background: #fff;
    border-radius: 14px;
    padding: 40px 36px;
    width: 100%; max-width: 360px;
    box-shadow: 0 12px 40px rgba(0,0,0,0.22);
}
.logon-logo { text-align: center; margin-bottom: 28px; }
.logon-logo h1 { font-size: 20px; font-weight: 800; color: var(--teal-dark); margin: 10px 0 4px; }
.logon-logo p  { font-size: 12px; color: var(--text-sub); margin: 0; }

.logon-form .fld { margin-bottom: 14px; }
.logon-form .fld label {
    display: block; font-size: 11px; font-weight: 700;
    color: var(--text-sub); margin-bottom: 5px;
    text-transform: uppercase; letter-spacing: 0.5px;
}
.logon-form .fld input {
    width: 100%; padding: 9px 12px;
    border: 1.5px solid var(--border-dark); border-radius: var(--radius);
    font-family: var(--font); font-size: 14px; color: var(--text-main);
    transition: border-color .15s, box-shadow .15s; outline: none;
}
.logon-form .fld input:focus {
    border-color: var(--teal);
    box-shadow: 0 0 0 3px rgba(21,101,192,0.12);
}
.btn-logon {
    width: 100%; padding: 11px;
    background: linear-gradient(90deg, #0d47a1, #1565c0);
    color: #fff; border: none; border-radius: var(--radius);
    font-family: var(--font); font-size: 14px; font-weight: 700;
    cursor: pointer; display: flex; align-items: center; justify-content: center;
    gap: 8px; margin-top: 6px; transition: opacity .15s;
}
.btn-logon:hover { opacity: 0.9; }
.logon-powered { text-align: center; font-size: 11px; color: var(--text-muted); margin: 20px 0 0; }
.logon-error {
    background: #ffebee; border: 1px solid #ef9a9a;
    color: #c62828; border-radius: var(--radius);
    padding: 10px 14px; font-size: 12px; font-weight: 600;
    margin-bottom: 16px; display: flex; align-items: center; gap: 8px;
}

/* ── Área de ticket / timeline ─────────────────────────────── */
.ticket-meta-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 12px;
    margin-bottom: 20px;
}
.ticket-meta-item { }
.ticket-meta-label {
    font-size: 10px; font-weight: 700;
    text-transform: uppercase; letter-spacing: 0.5px;
    color: var(--text-muted); margin-bottom: 3px;
}
.ticket-meta-value { font-size: 13px; font-weight: 600; color: var(--text-main); }

.timeline-item {
    border-left: 3px solid var(--border-dark);
    padding: 0 0 20px 16px;
    position: relative;
}
.timeline-item::before {
    content: '';
    width: 10px; height: 10px;
    border-radius: 50%;
    background: var(--teal);
    border: 2px solid #fff;
    box-shadow: 0 0 0 2px var(--teal-mid);
    position: absolute;
    left: -7px; top: 4px;
}
.timeline-item.tipo-log::before { background: var(--text-muted); box-shadow: 0 0 0 2px var(--border); }
.timeline-item.tipo-analista::before { background: var(--green); box-shadow: 0 0 0 2px #c8e6c9; }

.timeline-header {
    display: flex; align-items: center; gap: 8px;
    margin-bottom: 6px;
}
.timeline-user { font-weight: 700; font-size: 13px; color: var(--teal-dark); }
.timeline-date { font-size: 11px; color: var(--text-muted); }
.timeline-body {
    background: #f8fafc;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 12px 14px;
    font-size: 13px; line-height: 1.6;
    color: var(--text-main);
}
.timeline-body.tipo-log { background: #fafafa; color: var(--text-sub); font-size: 12px; }

/* ── Empty state ────────────────────────────────────────────── */
.empty-state {
    text-align: center;
    padding: 40px 20px;
    color: var(--text-muted);
}
.empty-state i { font-size: 32px; margin-bottom: 10px; display: block; }
.empty-state p { font-size: 13px; margin: 0; }

/* ── Seção de título interno ────────────────────────────────── */
.section-title {
    font-size: 11px; font-weight: 700;
    text-transform: uppercase; letter-spacing: 0.6px;
    color: var(--text-sub);
    padding: 12px 16px 8px;
    border-bottom: 1px solid var(--border);
    display: flex; align-items: center; gap: 7px;
}
.section-title i { color: var(--teal); }
