/* =========================================================
   Casariche / Santaella Telecomunicaciones — UI
   Paleta:  #072b3e (azul marino)
            #0093a7 (azul complementario)
            #f8f6f7 (beige/neutro)
   ========================================================= */

:root {
  --navy: #072b3e;
  --navy-600: #0a3c55;
  --teal: #0093a7;
  --teal-600: #007b8b;
  --teal-50: #e6f5f8;
  --beige: #f8f6f7;
  --beige-200: #eeeaec;
  --ink: #132b3a;
  --ink-soft: #4b5b66;
  --muted: #7b8a95;
  --line: #dde3e8;
  --danger: #b4233e;
  --danger-50: #fdecef;
  --warning: #c9690c;
  --warning-50: #fbf0e1;
  --success: #157a44;
  --success-50: #e5f4ec;
  --blue-50: #e4f0f7;
  --blue: #1e6fa3;
  --gray-50: #f1f3f5;
  --radius: 10px;
  --radius-sm: 6px;
  --shadow-sm: 0 1px 2px rgba(7,43,62,.06);
  --shadow-md: 0 4px 14px rgba(7,43,62,.08);
  --font: -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0; padding: 0;
  font-family: var(--font);
  background: var(--beige);
  color: var(--ink);
  font-size: 15px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--teal-600); text-decoration: none; }
a:hover { color: var(--navy); text-decoration: underline; }

h1, h2, h3, h4 { color: var(--navy); margin: 0 0 .5rem; font-weight: 700; line-height: 1.25; }
h1 { font-size: 1.5rem; }
h2 { font-size: 1.2rem; }
h3 { font-size: 1.05rem; }

hr { border: 0; border-top: 1px solid var(--line); margin: 1.25rem 0; }

/* Layout */
.app-shell { display: grid; grid-template-columns: 240px 1fr; min-height: 100vh; }
.sidebar {
  background: var(--navy); color: #fff;
  display: flex; flex-direction: column; position: sticky; top: 0; max-height: 100vh;
}
.sidebar-brand {
  padding: 1rem 1.1rem; border-bottom: 1px solid rgba(255,255,255,.08);
  font-weight: 700; letter-spacing: .3px;
}
.sidebar-brand small { display:block; font-weight: 400; color: #9bb5c2; font-size: .8rem; margin-top: 2px;}
.sidebar nav { flex: 1; overflow-y: auto; padding: .5rem 0; }
.sidebar nav a {
  display: flex; align-items: center; gap: .6rem;
  color: #cfe3ec; padding: .65rem 1.1rem; font-weight: 500;
  border-left: 3px solid transparent; font-size: .95rem;
}
.sidebar nav a:hover { background: rgba(255,255,255,.05); color: #fff; text-decoration: none; }
.sidebar nav a.active { background: rgba(0,147,167,.15); border-left-color: var(--teal); color: #fff; }
.sidebar nav .sect { color: #7b96a6; text-transform: uppercase; font-size: .72rem; letter-spacing: .12em; padding: 1rem 1.1rem .35rem; }
.sidebar-foot { padding: 1rem 1.1rem; border-top: 1px solid rgba(255,255,255,.08); font-size: .85rem; }
.sidebar-foot form { display: inline; }
.sidebar-foot .logout-btn {
  background: transparent; border: 1px solid rgba(255,255,255,.15); color:#cfe3ec;
  padding: .35rem .7rem; border-radius: 6px; cursor: pointer; font-size: .85rem;
}
.sidebar-foot .logout-btn:hover { background: rgba(255,255,255,.08); }

.main { display: flex; flex-direction: column; min-width: 0; }
.topbar {
  background: #fff; border-bottom: 1px solid var(--line);
  padding: .75rem 1.25rem; display: flex; align-items: center; gap: 1rem;
  position: sticky; top: 0; z-index: 10;
}
.topbar .title { font-weight: 700; color: var(--navy); font-size: 1.05rem; }
.topbar .spacer { flex: 1; }
.topbar .user-chip { font-size: .88rem; color: var(--ink-soft); }
.mobile-toggle { display: none; background: none; border: 0; font-size: 1.4rem; color: var(--navy); cursor: pointer; }

.content { padding: 1.25rem; max-width: 1400px; width: 100%; margin: 0 auto; }

/* Cards */
.card {
  background: #fff; border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow-sm); padding: 1rem 1.1rem; margin-bottom: 1rem;
}
.card-header { display: flex; align-items: center; gap: 1rem; margin-bottom: .75rem;}
.card-header h2, .card-header h3 { margin: 0; flex: 1; }

/* Grids */
.grid { display: grid; gap: 1rem; }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
.grid-metrics { grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); }

/* Metrics */
.metric { background:#fff; padding:1rem; border:1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-sm); }
.metric .label { font-size:.8rem; color: var(--muted); text-transform:uppercase; letter-spacing:.05em;}
.metric .value { font-size: 1.8rem; font-weight: 700; color: var(--navy); margin-top: .2rem; }
.metric.accent { background: var(--teal); color: #fff; border-color: var(--teal); }
.metric.accent .label, .metric.accent .value { color: #fff; }

/* Tables */
.table { width: 100%; border-collapse: collapse; background: #fff; }
.table th, .table td { padding: .7rem .85rem; text-align: left; border-bottom: 1px solid var(--line); vertical-align: middle; font-size: .92rem;}
.table thead th { background: var(--beige-200); color: var(--navy); font-weight: 600; font-size: .78rem; text-transform: uppercase; letter-spacing: .04em;}
.table tr:hover td { background: #fcfcfd; }
.table-wrap { background:#fff; border:1px solid var(--line); border-radius: var(--radius); overflow-x: auto; box-shadow: var(--shadow-sm);}

/* Forms */
.form-row { display: grid; grid-template-columns: repeat(2, 1fr); gap: .9rem; margin-bottom: .5rem; }
.form-row-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: .9rem; margin-bottom: .5rem; }
.field { display: flex; flex-direction: column; margin-bottom: .9rem; }
.field label { font-size: .82rem; font-weight: 600; color: var(--navy); margin-bottom: .3rem; }
.field .hint { font-size: .76rem; color: var(--muted); margin-top: .2rem; }
input[type=text], input[type=email], input[type=password], input[type=tel], input[type=number],
input[type=date], input[type=datetime-local], input[type=url], select, textarea {
  width: 100%; padding: .55rem .7rem; border: 1px solid var(--line); border-radius: var(--radius-sm);
  font-family: inherit; font-size: .95rem; color: var(--ink); background: #fff;
  transition: border-color .15s, box-shadow .15s;
}
textarea { min-height: 90px; resize: vertical; }
input:focus, select:focus, textarea:focus {
  outline: 0; border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(0,147,167,.15);
}

/* Buttons */
.btn { display: inline-flex; align-items: center; gap: .5rem; justify-content: center;
  padding: .55rem 1rem; border-radius: var(--radius-sm); border: 1px solid transparent;
  font-weight: 600; cursor: pointer; font-size: .92rem; font-family: inherit; min-height: 40px;
  transition: background .15s, border-color .15s, color .15s; text-decoration: none;
}
.btn-primary { background: var(--teal); color: #fff; }
.btn-primary:hover { background: var(--teal-600); color: #fff; }
.btn-navy { background: var(--navy); color: #fff; }
.btn-navy:hover { background: var(--navy-600); color: #fff; }
.btn-outline { background: #fff; border-color: var(--line); color: var(--navy);}
.btn-outline:hover { border-color: var(--teal); color: var(--teal); }
.btn-danger { background: var(--danger); color:#fff; }
.btn-danger:hover { background: #8d1a30; }
.btn-sm { padding: .35rem .7rem; font-size: .85rem; min-height: 32px;}
.btn-block { width: 100%; }
.btn-xl { padding: .9rem 1.2rem; font-size: 1rem; min-height: 52px;}

/* Badges */
.badge { display: inline-block; padding: .2rem .55rem; border-radius: 999px; font-size: .72rem; font-weight: 600; text-transform: uppercase; letter-spacing: .04em;}
.badge-blue { background: var(--blue-50); color: var(--blue); }
.badge-green { background: var(--success-50); color: var(--success); }
.badge-red { background: var(--danger-50); color: var(--danger); }
.badge-orange { background: var(--warning-50); color: var(--warning); }
.badge-gray { background: var(--gray-50); color: var(--ink-soft); }

/* Flash */
.flash { margin-bottom: 1rem; padding: .75rem 1rem; border-radius: var(--radius-sm); border-left: 4px solid; }
.flash-success { background: var(--success-50); border-color: var(--success); color: var(--success);}
.flash-error   { background: var(--danger-50);  border-color: var(--danger);  color: var(--danger);}
.flash-info    { background: var(--teal-50);    border-color: var(--teal);    color: var(--teal-600);}

/* Timeline */
.timeline { border-left: 2px solid var(--line); padding-left: 1rem; margin: 0; }
.timeline li { list-style: none; padding: .5rem 0 .75rem 0; position: relative;}
.timeline li::before { content: ''; position: absolute; left: -1.36rem; top: .8rem; width: .6rem; height: .6rem; border-radius: 50%; background: var(--teal);}
.timeline li.event-cambio_estado::before { background: var(--warning); }
.timeline li.event-cierre::before, .timeline li.event-fin_intervencion::before { background: var(--success); }
.timeline .meta { font-size: .78rem; color: var(--muted);}

/* Auth */
.auth-shell { min-height: 100vh; display: grid; place-items: center; background: linear-gradient(135deg, var(--navy), #0d3b53);}
.auth-card { background: #fff; width: 360px; max-width: 100%; padding: 2rem; border-radius: 12px; box-shadow: 0 20px 60px rgba(0,0,0,.25); }
.auth-card h1 { text-align: center; margin-bottom: .3rem;}
.auth-card p.lead { text-align: center; color: var(--muted); margin-bottom: 1.5rem; }
.auth-links { display: flex; justify-content: space-between; margin-top: 1rem; font-size: .85rem;}

/* Filters bar */
.filters { display: flex; flex-wrap: wrap; gap: .7rem; margin-bottom: 1rem; align-items: end;}
.filters .field { margin-bottom: 0; min-width: 140px; }
.filters select, .filters input { min-width: 140px;}

/* Signature pad */
.sigpad-wrap { background:#fff; padding: 1rem; border-radius: var(--radius); border:1px solid var(--line);}
.sigpad { border: 2px dashed var(--teal); border-radius: var(--radius-sm); background: var(--beige); touch-action: none; width: 100%; height: 230px; display: block;}
.sigpad-actions { display: flex; gap: .5rem; margin-top: .5rem;}

/* Bottom nav (móvil) */
.bottom-nav { display: none; position: fixed; bottom: 0; left: 0; right: 0; background: #fff;
  border-top: 1px solid var(--line); padding: .35rem 0; z-index: 50; box-shadow: 0 -3px 10px rgba(0,0,0,.03);}
.bottom-nav a { flex: 1; display: flex; flex-direction: column; align-items: center; font-size: .68rem; color: var(--muted); padding: .3rem 0;}
.bottom-nav a span.icon { font-size: 1.2rem; margin-bottom: 2px; }
.bottom-nav a.active { color: var(--teal); }

/* Priority dot */
.prio-dot { display:inline-block; width:.6rem; height:.6rem; border-radius:50%; margin-right:.35rem; vertical-align: middle;}
.prio-baja { background: #9fb2bd; }
.prio-normal { background: var(--blue); }
.prio-alta { background: var(--warning); }
.prio-urgente { background: var(--danger); }

/* Ticket mobile cards */
.ticket-card { display: block; padding: .9rem; border: 1px solid var(--line); border-radius: var(--radius);
  margin-bottom: .7rem; background: #fff; box-shadow: var(--shadow-sm); }
.ticket-card:hover { text-decoration: none; border-color: var(--teal); }
.ticket-card .title { font-weight: 600; color: var(--navy); }
.ticket-card .meta { font-size: .8rem; color: var(--muted); margin-top: .2rem;}

/* Misc */
.muted { color: var(--muted); }
.right { text-align: right; }
.no-wrap { white-space: nowrap; }
.small { font-size: .85rem; }
.mb-0 { margin-bottom: 0 !important; }
.mt-1 { margin-top: 1rem; }
.mt-2 { margin-top: 2rem; }
.mb-1 { margin-bottom: .5rem;} .mb-2 { margin-bottom: 1rem; }
.chip { display:inline-block; background: var(--beige-200); padding: .1rem .55rem; border-radius: 999px; font-size: .75rem; color: var(--ink-soft);}
.address-block { background: var(--beige-200); padding: .5rem .7rem; border-radius: var(--radius-sm); font-size: .88rem; }

/* Tabs */
.tabs { display: flex; gap: .2rem; border-bottom: 1px solid var(--line); margin-bottom: 1rem; overflow-x: auto; }
.tabs a { padding: .6rem 1rem; color: var(--ink-soft); font-weight: 600; border-bottom: 3px solid transparent; white-space: nowrap; }
.tabs a:hover { text-decoration: none; color: var(--navy);}
.tabs a.active { color: var(--navy); border-bottom-color: var(--teal);}

/* Responsive */
@media (max-width: 900px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed; top: 0; left: -260px; width: 260px; height: 100vh;
    transition: left .2s; z-index: 100;
  }
  .sidebar.open { left: 0; box-shadow: 4px 0 20px rgba(0,0,0,.3);}
  .mobile-toggle { display: inline-flex; }
  .content { padding-bottom: 6rem; }
  .bottom-nav { display: flex; }
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
  .form-row, .form-row-3 { grid-template-columns: 1fr; }
  .table thead { display: none; }
  .table, .table tbody, .table tr, .table td { display: block; width: 100%;}
  .table tr { background:#fff; border:1px solid var(--line); border-radius: var(--radius); margin-bottom: .7rem; padding: .5rem;}
  .table td { border: 0; padding: .35rem 0; }
  .table td::before { content: attr(data-th) ": "; font-weight: 600; color: var(--navy); margin-right: .35rem; }
}

/* Print */
@media print {
  .sidebar, .topbar, .bottom-nav, .no-print { display: none !important; }
  body { background: #fff; }
  .card { box-shadow: none; border: 0;}
}
