/* ============================================================
   SISTIMA Help Desk — Main Stylesheet
   Brand: #2D3E50 (dark navy), #FFFFFF (white)
   ============================================================ */

:root {
    --brand:        #2D3E50;
    --brand-light:  #3D5166;
    --brand-dark:   #1E2D3D;
    --brand-muted:  #2D3E5018;
    --accent:       #4A9FD5;
    --accent-light: #EBF5FC;

    --bg:           #F0F4F8;
    --surface:      #FFFFFF;
    --surface-2:    #F8FAFC;
    --border:       #E2E8F0;
    --border-focus: #4A9FD5;

    --text:         #1E293B;
    --text-2:       #475569;
    --text-3:       #94A3B8;
    --text-inv:     #FFFFFF;

    --success:      #10B981;
    --warning:      #F59E0B;
    --danger:       #EF4444;
    --info:         #3B82F6;

    --radius:       10px;
    --radius-lg:    16px;
    --shadow:       0 1px 4px rgba(0,0,0,.08), 0 4px 16px rgba(0,0,0,.06);
    --shadow-lg:    0 4px 24px rgba(0,0,0,.12);

    --sidebar-w:    256px;
    --topbar-h:     64px;
    --font:         'Nunito', system-ui, sans-serif;
}

/* ---------- Reset ---------- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 15px; }
body { font-family: var(--font); background: var(--bg); color: var(--text); line-height: 1.6; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; display: block; }
ul { list-style: none; }

/* ---------- Typography ---------- */
h1 { font-size: 1.6rem; font-weight: 800; }
h2 { font-size: 1.3rem; font-weight: 700; }
h3 { font-size: 1.1rem; font-weight: 700; }
h4 { font-size: 1rem;   font-weight: 700; }

/* ---------- Layout Shell ---------- */
.layout {
    display: flex;
    min-height: 100vh;
}

/* ---------- Sidebar ---------- */
.sidebar {
    width: var(--sidebar-w);
    background: var(--brand);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0; left: 0; bottom: 0;
    z-index: 100;
    transition: transform .25s;
}

.sidebar-logo {
    padding: 20px 20px 16px;
    border-bottom: 1px solid rgba(255,255,255,.08);
    display: flex;
    align-items: center;
    gap: 12px;
}

.sidebar-logo img {
    height: 36px;
}

.sidebar-logo-text {
    line-height: 1.1;
}

.sidebar-logo-text strong {
    display: block;
    color: #fff;
    font-size: .95rem;
    font-weight: 800;
    letter-spacing: .5px;
}

.sidebar-logo-text span {
    display: block;
    color: rgba(255,255,255,.5);
    font-size: .65rem;
    letter-spacing: 1px;
    text-transform: uppercase;
}

.sidebar-nav {
    flex: 1;
    padding: 12px 0;
    overflow-y: auto;
}

.nav-section {
    padding: 8px 16px 4px;
    font-size: .68rem;
    letter-spacing: 1.2px;
    text-transform: uppercase;
    color: rgba(255,255,255,.35);
    font-weight: 700;
    margin-top: 8px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 16px;
    color: rgba(255,255,255,.7);
    font-size: .9rem;
    font-weight: 600;
    border-radius: 0;
    transition: all .15s;
    cursor: pointer;
    margin: 1px 8px;
    border-radius: 8px;
}

.nav-item:hover {
    background: rgba(255,255,255,.08);
    color: #fff;
    text-decoration: none;
}

.nav-item.active {
    background: rgba(255,255,255,.14);
    color: #fff;
}

.nav-item .nav-icon {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
    opacity: .8;
}

.nav-item.active .nav-icon,
.nav-item:hover .nav-icon { opacity: 1; }

.nav-badge {
    margin-left: auto;
    background: var(--danger);
    color: #fff;
    font-size: .65rem;
    font-weight: 700;
    padding: 2px 7px;
    border-radius: 20px;
    min-width: 20px;
    text-align: center;
}

.sidebar-footer {
    padding: 16px;
    border-top: 1px solid rgba(255,255,255,.08);
}

.user-card {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px;
    border-radius: 8px;
    cursor: pointer;
    transition: background .15s;
}

.user-card:hover { background: rgba(255,255,255,.08); }

.avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: rgba(255,255,255,.2);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: .85rem;
    font-weight: 800;
    color: #fff;
    flex-shrink: 0;
}

.avatar.sm { width: 28px; height: 28px; font-size: .7rem; }
.avatar.lg { width: 48px; height: 48px; font-size: 1.1rem; }

.user-info strong {
    display: block;
    color: #fff;
    font-size: .82rem;
    font-weight: 700;
    line-height: 1.1;
}
.user-info span {
    color: rgba(255,255,255,.45);
    font-size: .7rem;
}

/* ---------- Main Content ---------- */
.main {
    margin-left: var(--sidebar-w);
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* ---------- Topbar ---------- */
.topbar {
    height: var(--topbar-h);
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 0 24px;
    position: sticky;
    top: 0;
    z-index: 50;
    box-shadow: 0 1px 0 var(--border);
}

.topbar-title {
    font-size: 1rem;
    font-weight: 700;
    color: var(--text);
    flex: 1;
}

.topbar-actions { display: flex; align-items: center; gap: 8px; }

.btn-icon {
    width: 38px;
    height: 38px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: transparent;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: var(--text-2);
    transition: all .15s;
}

.btn-icon:hover { background: var(--bg); color: var(--text); }

/* ---------- Page Body ---------- */
.page-body {
    padding: 24px;
    flex: 1;
}

/* ---------- Cards ---------- */
.card {
    background: var(--surface);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
}

.card-header {
    padding: 18px 24px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.card-title {
    font-size: 1rem;
    font-weight: 700;
    color: var(--text);
}

.card-body { padding: 24px; }
.card-footer {
    padding: 14px 24px;
    border-top: 1px solid var(--border);
    background: var(--surface-2);
    border-radius: 0 0 var(--radius-lg) var(--radius-lg);
}

/* ---------- Stat Cards ---------- */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.stat-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 20px;
    display: flex;
    align-items: flex-start;
    gap: 14px;
    box-shadow: var(--shadow);
    transition: transform .2s, box-shadow .2s;
}

.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

a.stat-card:hover {
    text-decoration: none;
}

.stat-icon {
    width: 46px;
    height: 46px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.stat-info { flex: 1; }

.stat-value {
    font-size: 1.7rem;
    font-weight: 800;
    line-height: 1;
    color: var(--text);
}

.stat-label {
    font-size: .78rem;
    color: var(--text-3);
    margin-top: 2px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .5px;
}

/* ---------- Tables ---------- */
.table-wrap {
    overflow-x: auto;
    border-radius: var(--radius-lg);
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: .88rem;
}

thead th {
    background: var(--surface-2);
    color: var(--text-2);
    font-size: .72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .8px;
    padding: 12px 16px;
    text-align: left;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}

tbody td {
    padding: 13px 16px;
    border-bottom: 1px solid var(--border);
    color: var(--text);
    vertical-align: middle;
}

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

tbody tr:hover { background: var(--surface-2); }

/* ---------- Badges ---------- */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: .73rem;
    font-weight: 700;
    letter-spacing: .3px;
    white-space: nowrap;
}

/* ---------- Buttons ---------- */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 9px 18px;
    border-radius: 8px;
    font-size: .88rem;
    font-weight: 700;
    border: none;
    cursor: pointer;
    transition: all .15s;
    text-decoration: none;
    white-space: nowrap;
    font-family: var(--font);
}

.btn-primary {
    background: var(--brand);
    color: #fff;
}
.btn-primary:hover { background: var(--brand-light); color: #fff; text-decoration: none; }

.btn-accent {
    background: var(--accent);
    color: #fff;
}
.btn-accent:hover { background: #3a8bbf; color: #fff; text-decoration: none; }

.btn-outline {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-2);
}
.btn-outline:hover { background: var(--bg); color: var(--text); text-decoration: none; }

.btn-danger {
    background: var(--danger);
    color: #fff;
}
.btn-danger:hover { background: #dc2626; text-decoration: none; }

.btn-success {
    background: var(--success);
    color: #fff;
}
.btn-success:hover { background: #059669; text-decoration: none; }

.btn-sm { padding: 6px 12px; font-size: .8rem; }
.btn-lg { padding: 12px 24px; font-size: 1rem; }
.btn-block { width: 100%; justify-content: center; }

.btn:disabled { opacity: .5; cursor: not-allowed; }

/* ---------- Forms ---------- */
.form-group {
    margin-bottom: 18px;
}

.form-label {
    display: block;
    font-size: .82rem;
    font-weight: 700;
    color: var(--text-2);
    margin-bottom: 6px;
    letter-spacing: .2px;
}

.form-label .req { color: var(--danger); margin-left: 2px; }

.form-control {
    width: 100%;
    padding: 10px 14px;
    border: 1.5px solid var(--border);
    border-radius: 8px;
    font-size: .9rem;
    font-family: var(--font);
    color: var(--text);
    background: var(--surface);
    transition: border-color .15s, box-shadow .15s;
    outline: none;
}

.form-control:focus {
    border-color: var(--border-focus);
    box-shadow: 0 0 0 3px rgba(74,159,213,.15);
}

.form-control::placeholder { color: var(--text-3); }
textarea.form-control { resize: vertical; min-height: 120px; }
select.form-control { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2394A3B8' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center; padding-right: 36px; }

.form-hint { font-size: .75rem; color: var(--text-3); margin-top: 4px; }
.form-error { font-size: .75rem; color: var(--danger); margin-top: 4px; font-weight: 600; }

.form-row {
    display: grid;
    gap: 16px;
}
.form-row.col-2 { grid-template-columns: 1fr 1fr; }
.form-row.col-3 { grid-template-columns: 1fr 1fr 1fr; }

/* ---------- Alerts / Flash ---------- */
.alert {
    padding: 12px 16px;
    border-radius: 8px;
    font-size: .88rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 20px;
}

.alert-success { background: #ECFDF5; color: #065F46; border: 1px solid #A7F3D0; }
.alert-error   { background: #FEF2F2; color: #991B1B; border: 1px solid #FECACA; }
.alert-warning { background: #FFFBEB; color: #92400E; border: 1px solid #FDE68A; }
.alert-info    { background: #EFF6FF; color: #1E40AF; border: 1px solid #BFDBFE; }

/* ---------- File Upload ---------- */
.file-drop {
    border: 2px dashed var(--border);
    border-radius: 10px;
    padding: 32px 20px;
    text-align: center;
    cursor: pointer;
    transition: all .2s;
    background: var(--surface-2);
}

.file-drop:hover, .file-drop.drag-over {
    border-color: var(--accent);
    background: var(--accent-light);
}

.file-drop-icon { font-size: 2rem; margin-bottom: 8px; }
.file-drop p { color: var(--text-2); font-size: .88rem; }
.file-drop strong { color: var(--accent); }

.file-list { margin-top: 12px; display: flex; flex-direction: column; gap: 6px; }
.file-item {
    display: flex;
    align-items: center;
    gap: 10px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 8px 12px;
    font-size: .82rem;
}
.file-item-name { flex: 1; font-weight: 600; color: var(--text); }
.file-item-size { color: var(--text-3); }
.file-item-remove { cursor: pointer; color: var(--danger); font-size: 1rem; }

/* ---------- Chamado Card (list view) ---------- */
.chamado-item {
    display: block;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
    transition: background .12s;
    text-decoration: none;
    color: var(--text);
}

.chamado-item:last-child { border-bottom: none; }
.chamado-item:hover { background: var(--surface-2); text-decoration: none; color: var(--text); }

.chamado-item-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 6px;
}

.chamado-numero { color: var(--text-3); font-size: .78rem; font-weight: 700; }
.chamado-titulo { font-weight: 700; font-size: .95rem; flex: 1; }

.chamado-meta {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 12px;
    font-size: .77rem;
    color: var(--text-3);
}

.chamado-meta span { display: flex; align-items: center; gap: 4px; }

/* ---------- Timeline (interações) ---------- */
.timeline {
    position: relative;
    padding-left: 32px;
}

.timeline::before {
    content: '';
    position: absolute;
    left: 12px;
    top: 0;
    bottom: 0;
    width: 2px;
    background: var(--border);
}

.timeline-item {
    position: relative;
    margin-bottom: 24px;
}

.timeline-dot {
    position: absolute;
    left: -26px;
    top: 4px;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: var(--brand);
    border: 2px solid var(--surface);
    box-shadow: 0 0 0 2px var(--brand);
}

.timeline-dot.system  { background: var(--text-3); box-shadow: 0 0 0 2px var(--text-3); }
.timeline-dot.status  { background: var(--warning); box-shadow: 0 0 0 2px var(--warning); }
.timeline-dot.success { background: var(--success); box-shadow: 0 0 0 2px var(--success); }

.timeline-content {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 14px 18px;
}

.timeline-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 6px;
    flex-wrap: wrap;
}

.timeline-author { font-weight: 700; font-size: .88rem; }
.timeline-date   { color: var(--text-3); font-size: .77rem; margin-left: auto; }
.timeline-msg    { font-size: .88rem; color: var(--text); white-space: pre-wrap; }

/* ---------- Login Page ---------- */
.login-page {
    min-height: 100vh;
    display: grid;
    grid-template-columns: 1fr 1fr;
}

.login-brand {
    background: var(--brand);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 48px;
    position: relative;
    overflow: hidden;
}

.login-brand::before {
    content: '';
    position: absolute;
    inset: 0;
    background: url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Cg fill='%23ffffff' fill-opacity='0.03'%3E%3Cpath d='M36 34v-4h-2v4h-4v2h4v4h2v-4h4v-2h-4zm0-30V0h-2v4h-4v2h4v4h2V6h4V4h-4zM6 34v-4H4v4H0v2h4v4h2v-4h4v-2H6zM6 4V0H4v4H0v2h4v4h2V6h4V4H6z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E");
}

.login-brand img {
    max-width: 100%;
    height: auto;
    position: relative;
    z-index: 1;
}

.login-brand h1 {
    color: #fff;
    font-size: 2rem;
    font-weight: 900;
    text-align: center;
    position: relative;
    z-index: 1;
}

.login-brand p {
    color: rgba(255,255,255,.6);
    text-align: center;
    margin-top: 12px;
    position: relative;
    z-index: 1;
    font-size: .95rem;
}

.login-form-area {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 48px;
    background: var(--surface);
}

.login-form-box {
    width: 100%;
    max-width: 400px;
}

.login-form-box h2 {
    margin-bottom: 8px;
}

.login-form-box > p {
    color: var(--text-2);
    margin-bottom: 32px;
    font-size: .9rem;
}

/* ---------- Pagination ---------- */
.pagination {
    display: flex;
    align-items: center;
    gap: 4px;
    flex-wrap: wrap;
}

.page-btn {
    width: 34px;
    height: 34px;
    border: 1px solid var(--border);
    border-radius: 7px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: .82rem;
    font-weight: 700;
    color: var(--text-2);
    cursor: pointer;
    transition: all .12s;
    background: var(--surface);
    text-decoration: none;
}

.page-btn:hover { background: var(--bg); color: var(--text); text-decoration: none; }
.page-btn.active { background: var(--brand); color: #fff; border-color: var(--brand); }
.page-btn:disabled { opacity: .4; cursor: default; }

/* ---------- Filters Bar ---------- */
.filter-bar {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    margin-bottom: 16px;
}

.filter-bar .form-control { width: auto; min-width: 140px; }

/* ---------- Empty State ---------- */
.empty-state {
    text-align: center;
    padding: 64px 32px;
    color: var(--text-3);
}

.empty-state-icon {
    font-size: 3rem;
    margin-bottom: 16px;
    opacity: .5;
}

.empty-state h3 { color: var(--text-2); margin-bottom: 8px; }

/* ---------- Modal ---------- */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.45);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 0;
    pointer-events: none;
    transition: opacity .2s;
}

.modal-overlay.open {
    opacity: 1;
    pointer-events: all;
}

.modal {
    background: var(--surface);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    width: 100%;
    max-width: 540px;
    max-height: 90vh;
    overflow-y: auto;
    transform: translateY(16px);
    transition: transform .2s;
}

.modal-overlay.open .modal { transform: translateY(0); }

.modal-header {
    padding: 20px 24px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.modal-body { padding: 24px; }
.modal-footer {
    padding: 16px 24px;
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

/* ---------- Detail boxes ---------- */
.detail-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

.detail-item { }
.detail-label {
    font-size: .72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .8px;
    color: var(--text-3);
    margin-bottom: 3px;
}
.detail-value {
    font-size: .9rem;
    color: var(--text);
    font-weight: 600;
}

/* ---------- Responsive ---------- */
@media (max-width: 900px) {
    .sidebar { transform: translateX(-100%); }
    .sidebar.open { transform: translateX(0); }
    .main { margin-left: 0; }
    .login-page { grid-template-columns: 1fr; }
    .login-brand { display: none; }
    .form-row.col-2, .form-row.col-3 { grid-template-columns: 1fr; }
    .detail-grid { grid-template-columns: 1fr; }
}

/* ---------- Utilities ---------- */
.d-flex   { display: flex; }
.d-none   { display: none; }
.gap-2    { gap: 8px; }
.gap-3    { gap: 12px; }
.gap-4    { gap: 16px; }
.mt-1     { margin-top: 4px; }
.mt-2     { margin-top: 8px; }
.mt-3     { margin-top: 12px; }
.mt-4     { margin-top: 16px; }
.mb-3     { margin-bottom: 12px; }
.mb-4     { margin-bottom: 16px; }
.mb-6     { margin-bottom: 24px; }
.ml-auto  { margin-left: auto; }
.text-center { text-align: center; }
.text-right  { text-align: right; }
.text-muted  { color: var(--text-3); }
.text-small  { font-size: .8rem; }
.fw-bold  { font-weight: 700; }
.text-success { color: var(--success); }
.text-danger  { color: var(--danger); }
.text-warning { color: var(--warning); }
.w-100    { width: 100%; }
