/* ============================================================
   OPTOMETRÍA SUNWATCH — Estilos globales
   ============================================================ */

/* Variables */
:root {
  --navy:        #1B2A4A;
  --navy-dark:   #0F1E38;
  --blue:        #2E5FA3;
  --blue-light:  #D6E4F7;
  --blue-pale:   #EBF3FC;
  --blue-mid:    #7BA3CC;
  --white:       #FFFFFF;
  --bg:          #F4F6FA;
  --border:      #DDE3EE;
  --text:        #1B2A4A;
  --text-muted:  #6B7A99;
  --text-light:  #374151;
  --green:       #0F6E56;
  --green-bg:    #E1F5EE;
  --green-bdr:   #9FE1CB;
  --amber:       #854F0B;
  --amber-bg:    #FFF8E6;
  --amber-bdr:   #FAEEDA;
  --red:         #A32D2D;
  --red-bg:      #FCEBEB;
  --red-bdr:     #F7C1C1;
  --purple:      #534AB7;
  --purple-bg:   #EEEDFE;
  --sidebar-w:   52px;
  --topbar-h:    52px;
  --radius:      10px;
  --radius-sm:   7px;
  --transition:  .15s ease;
}

/* Reset */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 14px; -webkit-tap-highlight-color: transparent; }
body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
       background: var(--bg); color: var(--text); line-height: 1.5; }
a { color: var(--blue); text-decoration: none; }
img { max-width: 100%; }

/* ---- LOGIN ---- */
.login-body { background: var(--navy-dark); min-height: 100vh;
              display: flex; align-items: center; justify-content: center; padding: 1rem; }
.login-wrap { width: 100%; max-width: 380px; }
.login-card { background: var(--white); border-radius: 16px; padding: 2rem 1.75rem; }
.login-logo { display: flex; justify-content: center; margin-bottom: 1rem; }
.login-logo-img { width: 64px; height: 64px; object-fit: contain; border-radius: 12px; }
.login-logo-fallback { width: 56px; height: 56px; border-radius: 50%;
                        background: var(--blue); color: #fff; font-size: 18px;
                        font-weight: 600; align-items: center; justify-content: center; }
.login-title { font-size: 1.25rem; font-weight: 600; color: var(--navy);
               text-align: center; margin-bottom: .25rem; }
.login-sub  { font-size: .8rem; color: var(--text-muted); text-align: center; margin-bottom: 1.5rem; }
.login-footer { font-size: .75rem; color: var(--text-muted); text-align: center; margin-top: 1rem; }

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

.sidebar {
  width: var(--sidebar-w); background: var(--navy-dark);
  display: flex; flex-direction: column; align-items: center;
  padding: .75rem 0; gap: 2px; flex-shrink: 0; overflow: hidden;
}
.sidebar-logo { width: 36px; height: 36px; border-radius: 50%;
                background: var(--blue); display: flex; align-items: center;
                justify-content: center; margin-bottom: .75rem; flex-shrink: 0; }
.sidebar-logo img { width: 28px; height: 28px; object-fit: contain; border-radius: 50%; }
.nav-item { width: 38px; height: 38px; border-radius: 9px;
            display: flex; align-items: center; justify-content: center;
            cursor: pointer; transition: var(--transition); color: var(--blue-mid);
            text-decoration: none; }
.nav-item:hover { background: var(--navy); color: #fff; }
.nav-item.active { background: var(--blue); color: #fff; }
.nav-item svg { width: 18px; height: 18px; }
.nav-sep { width: 26px; height: 1px; background: var(--navy); margin: 3px 0; }

.main { flex: 1; display: flex; flex-direction: column; overflow: hidden; }

.topbar {
  height: var(--topbar-h); background: var(--navy); padding: 0 1rem;
  display: flex; align-items: center; justify-content: space-between; flex-shrink: 0;
}
.topbar-left { display: flex; align-items: center; gap: .6rem; }
.topbar-title { font-size: .9rem; font-weight: 500; color: #fff; }
.topbar-sub   { font-size: .7rem; color: var(--blue-mid); }
.topbar-right { display: flex; align-items: center; gap: .5rem; }

.content { flex: 1; overflow-y: auto; padding: 1rem; }

/* ---- TARJETAS ---- */
.card { background: var(--white); border-radius: var(--radius);
        border: .5px solid var(--border); padding: .875rem; margin-bottom: .75rem; }
.card-title { font-size: .7rem; font-weight: 600; color: var(--blue);
              padding-bottom: .5rem; border-bottom: .5px solid var(--blue-pale);
              margin-bottom: .75rem; letter-spacing: .03em; text-transform: uppercase; }

/* ---- FORMULARIOS ---- */
.field { display: flex; flex-direction: column; gap: .2rem; }
.field label { font-size: .7rem; font-weight: 600; color: var(--text-muted);
               letter-spacing: .03em; text-transform: uppercase; }
.field input, .field select, .field textarea {
  border: .5px solid var(--border); border-radius: var(--radius-sm);
  padding: .45rem .6rem; font-size: .8rem; color: var(--text);
  background: var(--white); width: 100%; transition: var(--transition);
  font-family: inherit;
}
.field input:focus, .field select:focus, .field textarea:focus {
  outline: none; border-color: var(--blue); box-shadow: 0 0 0 3px rgba(46,95,163,.12);
}
.field-hint { font-size: .7rem; color: var(--text-muted); }
.field textarea { resize: vertical; min-height: 60px; }
.field input[readonly] { background: var(--bg); color: var(--text-muted); cursor: default; }

.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: .6rem; }
.grid3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: .6rem; }
.grid4 { display: grid; grid-template-columns: 1fr 1fr 1fr 1fr; gap: .6rem; }
.grid5 { display: grid; grid-template-columns: repeat(5, 1fr); gap: .5rem; }

/* ---- BOTONES ---- */
.btn-primary { background: var(--blue); color: #fff; border: none;
               border-radius: var(--radius-sm); padding: .5rem .9rem;
               font-size: .8rem; font-weight: 500; cursor: pointer;
               transition: var(--transition); font-family: inherit; }
.btn-primary:hover  { background: var(--navy); }
.btn-primary:active { transform: scale(.98); }
.btn-ghost { background: transparent; color: var(--blue);
             border: .5px solid var(--blue); border-radius: var(--radius-sm);
             padding: .45rem .9rem; font-size: .8rem; font-weight: 500;
             cursor: pointer; transition: var(--transition); font-family: inherit; }
.btn-ghost:hover { background: var(--blue-pale); }
.btn-danger { background: transparent; color: var(--red);
              border: .5px solid var(--red); border-radius: var(--radius-sm);
              padding: .45rem .9rem; font-size: .8rem; font-weight: 500;
              cursor: pointer; font-family: inherit; }
.btn-full { width: 100%; padding: .65rem; }
.btn-sm   { padding: .3rem .65rem; font-size: .72rem; }
.btn-icon { background: none; border: none; cursor: pointer; color: var(--blue);
            font-size: .75rem; padding: 0; }

/* ---- BADGES ---- */
.badge { display: inline-flex; align-items: center; padding: .15rem .55rem;
         border-radius: 20px; font-size: .7rem; font-weight: 500; white-space: nowrap; }
.badge-green  { background: var(--green-bg);  color: var(--green);  }
.badge-amber  { background: var(--amber-bg);  color: var(--amber);  }
.badge-red    { background: var(--red-bg);    color: var(--red);    }
.badge-blue   { background: var(--blue-pale); color: #185FA5;       }
.badge-gray   { background: #F1EFE8;          color: #5F5E5A;       }
.badge-purple { background: var(--purple-bg); color: var(--purple); }
.badge-navy   { background: var(--navy);      color: #fff;          }

/* ---- ALERTAS ---- */
.alert { border-radius: var(--radius-sm); padding: .6rem .85rem;
         font-size: .8rem; margin-bottom: .75rem; }
.alert-error   { background: var(--red-bg);   color: var(--red);   border: .5px solid var(--red-bdr); }
.alert-success { background: var(--green-bg); color: var(--green); border: .5px solid var(--green-bdr); }
.alert-warning { background: var(--amber-bg); color: var(--amber); border: .5px solid var(--amber-bdr); }

/* ---- FILAS DE LISTA ---- */
.list-row { display: flex; align-items: center; gap: .6rem;
            background: var(--white); border-radius: var(--radius);
            padding: .65rem .85rem; margin-bottom: .4rem;
            border: .5px solid var(--border); cursor: pointer; transition: var(--transition); }
.list-row:hover { border-color: var(--blue); background: #FAFCFF; }
.list-row-info { flex: 1; }
.list-row-name { font-size: .85rem; font-weight: 500; color: var(--text); }
.list-row-meta { font-size: .72rem; color: var(--text-muted); margin-top: 1px; }

/* ---- AVATAR ---- */
.avatar { width: 34px; height: 34px; border-radius: 50%; background: var(--blue-light);
          display: flex; align-items: center; justify-content: center;
          font-size: .75rem; font-weight: 600; color: #0C447C; flex-shrink: 0; }
.avatar-lg { width: 42px; height: 42px; font-size: .9rem; }

/* ---- TABS ---- */
.tab-row { display: flex; border-bottom: .5px solid var(--border); background: var(--white); }
.tab { flex: 1; padding: .55rem .3rem; font-size: .72rem; font-weight: 500;
       text-align: center; cursor: pointer; color: var(--text-muted);
       border-bottom: 2px solid transparent; transition: var(--transition);
       white-space: nowrap; }
.tab:hover  { color: var(--blue); }
.tab.active { color: var(--blue); border-bottom-color: var(--blue); }
.tab-content { display: none; }
.tab-content.active { display: block; }

/* ---- OJO ENCABEZADOS ---- */
.eye-hdr    { background: var(--blue-pale); border-radius: 6px; padding: .3rem .5rem;
              font-size: .7rem; font-weight: 600; color: #185FA5; margin-bottom: .5rem;
              text-align: center; }
.eye-hdr.oi { background: #EEF5E8; color: #3B6D11; }

/* ---- BARRA DE PROGRESO LAB ---- */
.progress-track { display: flex; align-items: center; margin: .5rem 0; }
.p-step  { display: flex; flex-direction: column; align-items: center; }
.p-dot   { width: 10px; height: 10px; border-radius: 50%; background: var(--border); flex-shrink: 0; }
.p-dot.done { background: var(--green); }
.p-dot.now  { background: var(--blue); border: 2px solid var(--blue-light); }
.p-line { flex: 1; height: 1px; background: var(--border); }
.p-line.done { background: var(--green); }
.p-lbl { font-size: .6rem; color: var(--text-muted); margin-top: 2px; text-align: center; }

/* ---- SECCIÓN TÍTULO ---- */
.sec-title { font-size: .7rem; font-weight: 600; color: var(--text-muted);
             letter-spacing: .04em; text-transform: uppercase; margin: .75rem 0 .4rem; }

/* ---- STATS ---- */
.stat-grid { display: grid; gap: .6rem; margin-bottom: .75rem; }
.stat-card { background: var(--white); border-radius: var(--radius);
             border: .5px solid var(--border); padding: .75rem; }
.stat-val  { font-size: 1.25rem; font-weight: 500; color: var(--text); }
.stat-lbl  { font-size: .7rem; color: var(--text-muted); margin-top: 1px; }
.stat-val.green  { color: var(--green); }
.stat-val.amber  { color: var(--amber); }
.stat-val.red    { color: var(--red);   }
.stat-val.blue   { color: #185FA5;      }

/* ---- SALDO ---- */
.saldo-box { border-radius: var(--radius-sm); padding: .6rem .85rem;
             display: flex; align-items: center; justify-content: space-between; }
.saldo-ok   { background: var(--green-bg); border: .5px solid var(--green-bdr); }
.saldo-pend { background: var(--amber-bg); border: .5px solid var(--amber-bdr); }
.saldo-val  { font-size: 1.1rem; font-weight: 500; }
.saldo-lbl  { font-size: .68rem; font-weight: 600; }

/* ---- BARRAS RESUMEN ---- */
.bar-row { display: flex; align-items: center; gap: .5rem; margin-bottom: .4rem; }
.bar-name { font-size: .75rem; color: var(--text-light); width: 54px; flex-shrink: 0; }
.bar-track { flex: 1; height: 6px; background: var(--blue-pale); border-radius: 3px; overflow: hidden; }
.bar-fill  { height: 100%; border-radius: 3px; transition: width .4s ease; }
.bar-val   { font-size: .7rem; color: var(--text-muted); width: 32px; text-align: right; flex-shrink: 0; }

/* ---- TABLA PERMISOS ---- */
.perms-table { width: 100%; border-collapse: collapse; font-size: .78rem; }
.perms-table th { font-size: .68rem; font-weight: 600; color: var(--text-muted);
                  padding: .3rem .5rem; text-align: center; border-bottom: .5px solid var(--border); }
.perms-table th:first-child { text-align: left; }
.perms-table td { padding: .35rem .5rem; border-bottom: .5px solid var(--bg); }
.perms-table td:not(:first-child) { text-align: center; }
.check-yes { color: var(--green); font-size: 1rem; }
.check-no  { color: var(--red);   font-size: 1rem; }

/* ---- UTILITARIOS ---- */
.flex-between { display: flex; align-items: center; justify-content: space-between; }
.flex-center  { display: flex; align-items: center; }
.gap-sm { gap: .4rem; }
.gap-md { gap: .75rem; }
.mt-sm  { margin-top: .4rem; }
.mt-md  { margin-top: .75rem; }
.text-muted  { color: var(--text-muted); }
.text-small  { font-size: .75rem; }
.text-right  { text-align: right; }
.text-red    { color: var(--red); }
.text-green  { color: var(--green); }
.text-amber  { color: var(--amber); }
.text-blue   { color: #185FA5; }
.font-medium { font-weight: 500; }
.w-full { width: 100%; }

/* ---- RESPONSIVE iPad ---- */
@media (max-width: 768px) {
  .grid4 { grid-template-columns: 1fr 1fr; }
  .grid3 { grid-template-columns: 1fr 1fr; }
  .stat-grid.g4 { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 480px) {
  .grid4, .grid3, .grid2 { grid-template-columns: 1fr; }
}
