/* ===========================
   Reset & Base
=========================== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 15px; }
body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif; background: #0f172a; color: #e2e8f0; min-height: 100vh; }
a { color: inherit; text-decoration: none; }
button { cursor: pointer; font-family: inherit; }

/* ===========================
   Layout
=========================== */
.layout { display: flex; min-height: 100vh; }
.main   { flex: 1; min-width: 0; display: flex; flex-direction: column; overflow-y: auto; }

/* ===========================
   Sidebar
=========================== */
.sidebar { width: 220px; flex-shrink: 0; background: #1e293b; border-right: 1px solid #334155; display: flex; flex-direction: column; }
.sidebar-brand { display: flex; align-items: center; gap: 10px; padding: 18px 16px; border-bottom: 1px solid #334155; }
.brand-icon { font-size: 1.4rem; }
.brand-name { font-weight: 700; font-size: .9rem; color: #f1f5f9; }
.brand-org  { font-size: .7rem; color: #64748b; }
.sidebar-nav { flex: 1; padding: 10px 8px; display: flex; flex-direction: column; gap: 2px; }
.nav-item { display: flex; align-items: center; gap: 8px; padding: 8px 12px; border-radius: 8px; font-size: .85rem; color: #94a3b8; transition: background .15s, color .15s; }
.nav-item:hover, .nav-item.active { background: #334155; color: #f1f5f9; }
.nav-item.active { color: #60a5fa; background: rgba(96,165,250,.1); }
.sidebar-user { display: flex; align-items: center; gap: 8px; padding: 12px 12px; border-top: 1px solid #334155; }
.user-info { flex: 1; min-width: 0; }
.logout-btn { color: #64748b; font-size: 1rem; padding: 4px; border-radius: 6px; }
.logout-btn:hover { color: #f87171; background: #1e293b; }

/* ===========================
   Topbar
=========================== */
.topbar { display: flex; align-items: flex-start; justify-content: space-between; padding: 20px 24px 12px; border-bottom: 1px solid #1e293b; background: rgba(30,41,59,.5); }
.page-title { font-size: 1.25rem; font-weight: 700; color: #f1f5f9; }
.page-sub   { font-size: .78rem; color: #64748b; margin-top: 2px; }
.back-link  { font-size: .78rem; color: #60a5fa; margin-bottom: 4px; display: block; }

/* ===========================
   Stats
=========================== */
.stats-grid { display: grid; grid-template-columns: repeat(4,1fr); gap: 12px; padding: 16px 24px 0; }
.stat-card  { background: #1e293b; border: 1px solid #334155; border-radius: 12px; padding: 12px 14px; }
.stat-value { font-size: 1.6rem; font-weight: 700; }
.stat-label { font-size: .75rem; color: #64748b; margin-top: 2px; }
.stat-blue   .stat-value { color: #60a5fa; }
.stat-violet .stat-value { color: #a78bfa; }
.stat-green  .stat-value { color: #34d399; }
.stat-gray   .stat-value { color: #94a3b8; }

/* ===========================
   Filters
=========================== */
.filters { display: flex; align-items: center; gap: 12px; padding: 12px 24px; border-bottom: 1px solid #1e293b; flex-wrap: wrap; }
.filter-tabs { display: flex; gap: 4px; }
.filter-tab { padding: 6px 14px; border-radius: 8px; font-size: .8rem; border: 1px solid #1e293b; color: #94a3b8; transition: all .15s; }
.filter-tab:hover { border-color: #334155; color: #e2e8f0; }
.filter-tab.active { background: #334155; color: #f1f5f9; border-color: #334155; }
.search-wrap { margin-left: auto; }
.search-input { background: #1e293b; border: 1px solid #334155; border-radius: 8px; padding: 7px 12px; font-size: .82rem; color: #e2e8f0; outline: none; width: 200px; }
.search-input:focus { border-color: #3b82f6; }

/* ===========================
   Table
=========================== */
.table-card { margin: 16px 24px 24px; background: #1e293b; border: 1px solid #334155; border-radius: 12px; overflow: hidden; }
.table { width: 100%; border-collapse: collapse; font-size: .85rem; }
.table thead th { text-align: left; padding: 11px 14px; font-size: .72rem; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; color: #64748b; border-bottom: 1px solid #334155; }
.table tbody tr { border-bottom: 1px solid rgba(51,65,85,.5); transition: background .15s; }
.table tbody tr:last-child { border-bottom: none; }
.row-link { cursor: pointer; }
.row-link:hover td { background: rgba(51,65,85,.4); }
.table td { padding: 11px 14px; vertical-align: middle; }
.empty { text-align: center; color: #64748b; padding: 32px !important; }
.ticket-title { color: #e2e8f0; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 280px; }

/* ===========================
   Badges
=========================== */
.badge { display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; border-radius: 6px; font-size: .72rem; font-weight: 600; border: 1px solid transparent; }
.badge-gray   { background: rgba(100,116,139,.15); color: #94a3b8; border-color: rgba(100,116,139,.2); }
.badge-green  { background: rgba(52,211,153,.1); color: #34d399; border-color: rgba(52,211,153,.2); }
.badge-prior-baja  { background: rgba(52,211,153,.1); color: #34d399; border-color: rgba(52,211,153,.2); }
.badge-prior-media { background: rgba(251,191,36,.1); color: #fbbf24; border-color: rgba(251,191,36,.2); }
.badge-prior-alta  { background: rgba(248,113,113,.1); color: #f87171; border-color: rgba(248,113,113,.2); }
.badge-estado-abierto    { background: rgba(96,165,250,.1); color: #60a5fa; border-color: rgba(96,165,250,.2); }
.badge-estado-en-progreso{ background: rgba(167,139,250,.1); color: #a78bfa; border-color: rgba(167,139,250,.2); }
.badge-estado-resuelto   { background: rgba(52,211,153,.1); color: #34d399; border-color: rgba(52,211,153,.2); }
.badge-estado-cerrado    { background: rgba(100,116,139,.1); color: #94a3b8; border-color: rgba(100,116,139,.2); }
.badge-row { display: flex; align-items: center; gap: 8px; margin-top: 6px; flex-wrap: wrap; }

/* ===========================
   Avatars
=========================== */
.avatar-sm { width: 28px; height: 28px; border-radius: 50%; object-fit: cover; flex-shrink: 0; }
.avatar-md { width: 40px; height: 40px; border-radius: 50%; object-fit: cover; flex-shrink: 0; }
.avatar-initial { background: #3b82f6; display: flex; align-items: center; justify-content: center; font-size: .72rem; font-weight: 700; color: #fff; }
.user-cell { display: flex; align-items: center; gap: 8px; }

/* ===========================
   Cards
=========================== */
.card { background: #1e293b; border: 1px solid #334155; border-radius: 12px; padding: 18px; }
.card-title { font-size: .85rem; font-weight: 600; color: #94a3b8; text-transform: uppercase; letter-spacing: .04em; margin-bottom: 12px; }
.mb-3 { margin-bottom: 12px; }
.mb-4 { margin-bottom: 16px; }

/* ===========================
   Ticket layout
=========================== */
.ticket-layout  { display: flex; gap: 16px; padding: 16px 24px 24px; flex: 1; align-items: flex-start; }
.ticket-main    { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 0; }
.ticket-sidebar { width: 220px; flex-shrink: 0; display: flex; flex-direction: column; gap: 0; }
.ticket-description { font-size: .88rem; color: #cbd5e1; line-height: 1.65; }
.adjuntos { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.adjunto-link { display: inline-flex; align-items: center; gap: 6px; font-size: .78rem; background: #334155; border: 1px solid #475569; border-radius: 8px; padding: 5px 10px; color: #94a3b8; }
.adjunto-link:hover { color: #e2e8f0; }
.detail-row { display: flex; justify-content: space-between; font-size: .78rem; padding: 5px 0; border-bottom: 1px solid #334155; color: #94a3b8; }
.detail-row:last-child { border-bottom: none; }
.detail-row span:last-child { color: #cbd5e1; font-weight: 500; }

/* ===========================
   Comments
=========================== */
.comment { display: flex; gap: 10px; margin-bottom: 16px; }
.comment-interno { opacity: .75; }
.comment-body { flex: 1; }
.comment-header { display: flex; align-items: baseline; gap: 8px; margin-bottom: 6px; flex-wrap: wrap; }
.comment-text { background: #0f172a; border: 1px solid #334155; border-radius: 10px; border-top-left-radius: 2px; padding: 10px 14px; font-size: .85rem; color: #cbd5e1; line-height: 1.6; }
.comment-interno .comment-text { background: rgba(167,139,250,.05); border-color: rgba(167,139,250,.2); }

/* ===========================
   Forms
=========================== */
.form-container { padding: 16px 24px 32px; max-width: 680px; }
.form { display: flex; flex-direction: column; gap: 16px; }
.form-group { display: flex; flex-direction: column; gap: 6px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.label { font-size: .82rem; font-weight: 600; color: #94a3b8; }
.req   { color: #f87171; }
.hint  { font-size: .72rem; color: #64748b; margin-top: 4px; }
.input { background: #1e293b; border: 1px solid #334155; border-radius: 10px; padding: 9px 12px; color: #e2e8f0; font-size: .88rem; font-family: inherit; outline: none; transition: border-color .15s; width: 100%; }
.input:focus { border-color: #3b82f6; }
.textarea { resize: vertical; min-height: 110px; }
.input-file { background: #1e293b; border: 1px solid #334155; border-radius: 10px; padding: 8px 12px; color: #94a3b8; font-size: .82rem; width: 100%; }
.form-actions { display: flex; justify-content: flex-end; gap: 10px; padding-top: 4px; }
.mt-2 { margin-top: 8px; }
.mt-3 { margin-top: 12px; }
.check-label { display: flex; align-items: center; gap: 6px; font-size: .82rem; color: #94a3b8; cursor: pointer; }
.priority-group { display: flex; gap: 8px; }
.priority-option { display: flex; flex-direction: column; align-items: center; cursor: pointer; }
.priority-option input { display: none; }
.priority-label { padding: 6px 14px; border-radius: 8px; font-size: .8rem; font-weight: 600; border: 2px solid transparent; transition: all .15s; cursor: pointer; }
.priority-option input:checked + .priority-label { border-color: currentColor; }
.priority-baja  { background: rgba(52,211,153,.1); color: #34d399; }
.priority-media { background: rgba(251,191,36,.1); color: #fbbf24; }
.priority-alta  { background: rgba(248,113,113,.1); color: #f87171; }
.user-banner { display: flex; align-items: center; gap: 12px; background: rgba(59,130,246,.08); border: 1px solid rgba(59,130,246,.2); border-radius: 12px; padding: 12px 16px; margin-bottom: 16px; }
.ml-auto { margin-left: auto; }

/* ===========================
   Buttons
=========================== */
.btn { display: inline-flex; align-items: center; gap: 6px; padding: 8px 18px; border-radius: 10px; font-size: .85rem; font-weight: 600; border: none; transition: all .15s; }
.btn-primary   { background: #2563eb; color: #fff; box-shadow: 0 2px 8px rgba(37,99,235,.3); }
.btn-primary:hover { background: #1d4ed8; }
.btn-secondary { background: #334155; color: #e2e8f0; }
.btn-secondary:hover { background: #475569; }

/* ===========================
   Alerts
=========================== */
.alert { padding: 10px 14px; border-radius: 10px; font-size: .85rem; margin-bottom: 14px; }
.alert-error   { background: rgba(239,68,68,.1); border: 1px solid rgba(239,68,68,.3); color: #fca5a5; }
.alert-success { background: rgba(52,211,153,.08); border: 1px solid rgba(52,211,153,.2); color: #6ee7b7; }

/* ===========================
   Login
=========================== */
.login-page { display: flex; align-items: center; justify-content: center; min-height: 100vh; background: linear-gradient(135deg,#0f172a,#1e1b4b,#0f172a); }
.login-container { width: 100%; max-width: 420px; padding: 16px; }
.login-brand { text-align: center; margin-bottom: 28px; }
.login-logo { font-size: 2.5rem; margin-bottom: 10px; }
.login-brand h1 { font-size: 1.5rem; font-weight: 700; color: #f1f5f9; }
.login-subtitle { font-size: .82rem; color: #818cf8; margin-top: 4px; }
.login-card { background: rgba(255,255,255,.05); backdrop-filter: blur(12px); border: 1px solid rgba(255,255,255,.1); border-radius: 20px; padding: 28px; }
.login-card h2 { font-size: 1.1rem; font-weight: 600; color: #f1f5f9; margin-bottom: 8px; }
.login-card p  { font-size: .85rem; color: #94a3b8; margin-bottom: 20px; line-height: 1.55; }
.btn-google { display: flex; align-items: center; justify-content: center; gap: 10px; background: #fff; color: #374151; font-weight: 600; font-size: .9rem; padding: 12px 20px; border-radius: 12px; border: none; width: 100%; cursor: pointer; transition: background .15s; box-shadow: 0 2px 8px rgba(0,0,0,.2); }
.btn-google:hover { background: #f9fafb; }
.login-hint { text-align: center; font-size: .75rem; color: #64748b; margin-top: 14px; }

/* ===========================
   Utils
=========================== */
.mono      { font-family: monospace; }
.text-sm   { font-size: .82rem; }
.text-xs   { font-size: .72rem; }
.text-muted{ color: #64748b; }
.fw-bold   { font-weight: 600; }
