/**
 * Toduma SMS Modem Gateway Admin — CSS
 * Design e estrutura idênticos ao admin wfapi/web
 * Cores adaptadas para SMS Gateway (verde operacional)
 */

:root{
  --primary:#16a34a;
  --primary-hover:#15803d;
  --primary-foreground:#FFFFFF;
  --primary-light:rgba(22,163,74,.12);
  --primary-shadow:rgba(22,163,74,.25);
  --accent:#4ade80;

  --background:#FAFAFA;
  --foreground:#0F172A;
  --card:#FFFFFF;
  --border:#E2E8F0;
  --muted:#F1F5F9;
  --muted-foreground:#64748B;

  --destructive:#da2321;
  --destructive-foreground:#FFFFFF;

  --success:#10b981;
  --warning:#f59e0b;

  --radius:12px;
  --radius-lg:16px;
  --radius-xl:24px;

  --sidebar-bg:#0a1628;
  --sidebar-fg:#E5E7EB;
  --sidebar-muted:#94A3B8;
  --sidebar-border:rgba(255,255,255,.08);
}

*{box-sizing:border-box;margin:0;padding:0}
html,body{height:100%}
body{
  font-family:'Inter',-apple-system,BlinkMacSystemFont,'Segoe UI',Roboto,sans-serif;
  color:var(--foreground);
  background:var(--background);
  line-height:1.6;
}
h1,h2,h3,h4,h5,h6{
  font-family:'Inter',sans-serif;
  font-weight:700;
  line-height:1.2;
}
a{color:inherit;text-decoration:none}

.w-full{width:100%}
.grid{display:grid}
.flex{display:flex}
.gap-2{gap:.5rem}
.gap-3{gap:.75rem}
.gap-4{gap:1rem}
.mb-2{margin-bottom:.5rem}
.mb-3{margin-bottom:.75rem}
.mb-4{margin-bottom:1rem}
.mt-2{margin-top:.5rem}
.mt-3{margin-top:.75rem}
.mt-4{margin-top:1rem}
.mt-8{margin-top:2rem}
.mt-12{margin-top:3rem}
.text-muted{color:var(--muted-foreground)}
.text-sm{font-size:.875rem}
.text-xs{font-size:.75rem}
.text-danger{color:var(--destructive)}
.text-success{color:var(--success)}
.text-center{text-align:center}

/* Shell */
.admin-shell{
  min-height:100vh;
  display:grid;
  grid-template-columns: 280px 1fr;
}

/* Sidebar */
.admin-sidebar{
  position:sticky;
  top:0;
  height:100vh;
  background:var(--sidebar-bg);
  color:var(--sidebar-fg);
  border-right:1px solid var(--sidebar-border);
  display:flex;
  flex-direction:column;
  overflow:auto;
}
.admin-sidebar__brand{
  padding:1.25rem 1rem;
  border-bottom:1px solid var(--sidebar-border);
}
.admin-brand{
  display:flex;
  align-items:center;
  gap:.75rem;
}
.admin-brand__icon{
  width:44px;
  height:44px;
  border-radius:14px;
  background:rgba(74,222,128,.12);
  display:flex;
  align-items:center;
  justify-content:center;
}
.admin-brand__title{font-weight:800;letter-spacing:.2px;color:var(--accent);font-size:1.1rem}
.admin-brand__subtitle{font-size:.75rem;color:var(--sidebar-muted)}

.admin-nav{padding:.75rem;display:flex;flex-direction:column;gap:.25rem;overflow:auto;flex:1}
.admin-nav__item{
  display:flex;
  align-items:center;
  gap:.65rem;
  padding:.65rem .75rem;
  border-radius:12px;
  color:var(--sidebar-fg);
  border:1px solid transparent;
  transition:all .15s ease;
  font-size:.9rem;
}
.admin-nav__item i{width:20px;height:20px;flex-shrink:0}
.admin-nav__item:hover{
  background:rgba(255,255,255,.06);
  border-color:rgba(255,255,255,.06);
}
.admin-nav__item.is-active{
  background:rgba(74,222,128,.1);
  border-color:rgba(74,222,128,.25);
}
.admin-nav__label{font-weight:600;font-size:.9rem}

/* Main */
.admin-main{padding:1.25rem 1.5rem 2rem;overflow-x:hidden}
.admin-topbar{
  display:flex;
  align-items:flex-start;
  gap:1rem;
  margin-bottom:1rem;
}
.admin-topbar__title h1{font-size:1.6rem}
.admin-topbar__title p{color:var(--muted-foreground);font-size:.9rem;margin-top:.25rem}

.admin-user{display:flex;align-items:center;gap:.75rem}
.admin-user__avatar{
  width:40px;height:40px;border-radius:14px;
  display:flex;align-items:center;justify-content:center;
  background:var(--primary-light);
  color:var(--primary);
  font-weight:800;
}
.admin-user__name{font-weight:700;font-size:.9rem}
.admin-user__role{font-size:.75rem;color:var(--muted-foreground)}

/* Cards */
.card{
  background:var(--card);
  border:1px solid var(--border);
  border-radius:var(--radius-lg);
  box-shadow:0 1px 2px rgba(2,6,23,.06);
}
.card__header{padding:1rem 1.25rem;border-bottom:1px solid var(--border);display:flex;align-items:center;justify-content:space-between;gap:1rem}
.card__content{padding:1rem 1.25rem}
.card__footer{padding:1rem 1.25rem;border-top:1px solid var(--border)}

/* Stat Cards */
.stats-grid{
  display:grid;
  grid-template-columns:repeat(auto-fit, minmax(200px, 1fr));
  gap:1rem;
  margin-bottom:1.5rem;
}
.stat-card{
  background:var(--card);
  border:1px solid var(--border);
  border-radius:var(--radius-lg);
  padding:1.25rem;
  display:flex;
  align-items:flex-start;
  gap:1rem;
  transition:all .2s ease;
}
.stat-card:hover{
  transform:translateY(-2px);
  box-shadow:0 8px 25px rgba(2,6,23,.08);
}
.stat-card__icon{
  width:48px;height:48px;border-radius:14px;
  display:flex;align-items:center;justify-content:center;
  flex-shrink:0;
}
.stat-card__icon i{width:24px;height:24px}
.stat-card__value{font-size:1.75rem;font-weight:800;line-height:1}
.stat-card__label{font-size:.85rem;color:var(--muted-foreground);margin-top:.25rem}

/* Alerts */
.alert{
  display:flex;
  align-items:flex-start;
  gap:.75rem;
  padding:1rem 1.1rem;
  border-radius:var(--radius);
  border:1px solid var(--border);
  background:var(--card);
  margin: .75rem 0;
}
.alert i{width:18px;height:18px;margin-top:2px;flex-shrink:0}
.alert-error{border-color:#FECACA;background:#FEF2F2;color:#7F1D1D}
.alert-success{border-color:#BBF7D0;background:#F0FDF4;color:#166534}
.alert-warning{border-color:#FDE68A;background:#FFFBEB;color:#92400E}
.alert-info{border-color:#BFDBFE;background:#EFF6FF;color:#1E40AF}

/* Forms */
label{font-size:.875rem;font-weight:600;display:block;margin-bottom:.35rem}
.input, select, textarea{
  width:100%;
  border:1px solid var(--border);
  background:var(--card);
  color:var(--foreground);
  border-radius:12px;
  padding:.7rem .85rem;
  font-size:.9rem;
  font-family:inherit;
  transition:all .15s ease;
}
textarea{min-height:110px;resize:vertical}
.input:focus, select:focus, textarea:focus{
  outline:none;
  border-color:rgba(22,163,74,.55);
  box-shadow:0 0 0 4px var(--primary-light);
}
.form-row{display:grid;grid-template-columns:repeat(12,1fr);gap:1rem}
.col-12{grid-column:span 12}
.col-8{grid-column:span 8}
.col-6{grid-column:span 6}
.col-4{grid-column:span 4}
.col-3{grid-column:span 3}
.help{font-size:.8rem;color:var(--muted-foreground);margin-top:.35rem}

/* Buttons */
.btn{
  height:42px;
  border-radius:14px;
  border:1px solid transparent;
  padding:0 1rem;
  font-weight:700;
  font-size:.9rem;
  cursor:pointer;
  display:inline-flex;
  align-items:center;
  justify-content:center;
  gap:.5rem;
  transition:all .15s ease;
  user-select:none;
  font-family:inherit;
  white-space:nowrap;
}
.btn i{width:18px;height:18px}
.btn-primary{
  background:linear-gradient(135deg, var(--primary), var(--primary-hover));
  color:var(--primary-foreground);
  box-shadow:0 8px 20px var(--primary-shadow);
}
.btn-primary:hover{transform:translateY(-1px);box-shadow:0 12px 28px var(--primary-shadow)}
.btn-secondary{
  background:var(--muted);
  border-color:var(--border);
  color:var(--foreground);
}
.btn-secondary:hover{background:#e8ecf0;border-color:var(--primary-shadow)}
.btn-ghost{
  background:transparent;
  border-color:transparent;
  color:var(--foreground);
}
.btn-ghost:hover{background:rgba(2,6,23,.04)}
.btn-destructive{
  background:var(--destructive);
  color:var(--destructive-foreground);
}
.btn-destructive:hover{filter:brightness(.95)}
.btn-success{background:var(--success);color:#fff;}
.btn-success:hover{filter:brightness(.95)}
.btn-warning{background:var(--warning);color:#fff;}
.btn-warning:hover{filter:brightness(.95)}
.btn-icon{width:42px;padding:0}
.btn-sm{height:34px;font-size:.8rem;padding:0 .75rem;border-radius:10px}
.btn-sm i{width:15px;height:15px}

/* Spinner */
.spinner{
  display:inline-block;
  width:18px;height:18px;
  border:2px solid currentColor;
  border-right-color:transparent;
  border-radius:999px;
  animation:spin .75s linear infinite;
}
@keyframes spin{to{transform:rotate(360deg)}}

/* Tables */
.table-wrap{width:100%;overflow:auto;border-radius:var(--radius-lg);border:1px solid var(--border)}
table{width:100%;border-collapse:separate;border-spacing:0}
th,td{padding:.75rem .85rem;border-bottom:1px solid var(--border);text-align:left;font-size:.9rem}
th{font-size:.75rem;letter-spacing:.08em;text-transform:uppercase;color:var(--muted-foreground);background:linear-gradient(180deg, #fff, #fafafa);position:sticky;top:0}
tr:hover td{background:#f8fff8}
tr:last-child td{border-bottom:none}

/* Badges */
.badge{
  display:inline-flex;align-items:center;gap:.35rem;
  padding:.2rem .55rem;border-radius:999px;font-size:.75rem;font-weight:800;
  border:1px solid var(--border);background:var(--card)
}
.badge-primary{border-color:rgba(22,163,74,.35);background:var(--primary-light);color:#15803d}
.badge-success{border-color:rgba(16,185,129,.35);background:rgba(16,185,129,.12);color:#166534}
.badge-warning{border-color:rgba(245,158,11,.35);background:rgba(245,158,11,.12);color:#92400E}
.badge-danger{border-color:rgba(218,35,33,.35);background:rgba(218,35,33,.12);color:#991B1B}
.badge-info{border-color:rgba(96,165,250,.35);background:rgba(96,165,250,.12);color:#1e40af}
.badge-secondary{border-color:var(--border);background:var(--muted);color:var(--muted-foreground)}

/* Status Indicator */
.status-dot{
  width:10px;height:10px;border-radius:999px;display:inline-block;flex-shrink:0;
}
.status-dot--online{background:#10b981;box-shadow:0 0 0 3px rgba(16,185,129,.25)}
.status-dot--offline{background:#ef4444;box-shadow:0 0 0 3px rgba(239,68,68,.25)}
.status-dot--conectando{background:#f59e0b;box-shadow:0 0 0 3px rgba(245,158,11,.25);animation:pulse 1.5s ease-in-out infinite}
@keyframes pulse{0%,100%{opacity:1}50%{opacity:.4}}

/* Modals */
.modal{
  position:fixed;
  inset:0;
  display:none;
  z-index:60;
}
.modal.is-open{display:block}
.modal__overlay{
  position:absolute;
  inset:0;
  background:rgba(2,6,23,.55);
  backdrop-filter: blur(3px);
}
.modal__panel{
  position:relative;
  width:min(860px, calc(100vw - 2rem));
  max-height: calc(100vh - 2rem);
  margin:1rem auto;
  background:var(--card);
  border:1px solid var(--border);
  border-radius: var(--radius-xl);
  box-shadow: 0 30px 80px rgba(2,6,23,.35);
  overflow:hidden;
  display:flex;
  flex-direction:column;
}
.modal__header{
  padding:1rem 1.25rem;
  border-bottom:1px solid var(--border);
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:1rem;
}
.modal__title{font-weight:700;font-size:1.15rem;}
.modal__close{
  border:1px solid var(--border);
  background:var(--muted);
  border-radius:14px;
  width:42px;height:42px;
  display:inline-flex;align-items:center;justify-content:center;
  cursor:pointer;
}
.modal__close:hover{background:var(--primary-light)}
.modal__close i{width:18px;height:18px}
.modal__body{padding:1rem 1.25rem;overflow:auto}
.modal__footer{
  padding:1rem 1.25rem;
  border-top:1px solid var(--border);
  display:flex;
  justify-content:flex-end;
  gap:.75rem;
}

/* Tabs */
.tabs{
  display:flex;
  gap:0;
  border-bottom:2px solid var(--border);
  margin-bottom:1.5rem;
}
.tab{
  padding:.75rem 1.25rem;
  font-weight:600;
  font-size:.9rem;
  color:var(--muted-foreground);
  border-bottom:2px solid transparent;
  margin-bottom:-2px;
  cursor:pointer;
  transition:all .15s ease;
  background:none;
  border-top:none;border-left:none;border-right:none;
  font-family:inherit;
}
.tab:hover{color:var(--foreground)}
.tab.is-active{
  color:var(--primary);
  border-bottom-color:var(--primary);
}
.tab-content{display:none}
.tab-content.is-active{display:block}

/* Empty State */
.empty-state{
  text-align:center;
  padding:4rem 2rem;
  color:var(--muted-foreground);
}
.empty-state i{width:48px;height:48px;margin-bottom:1rem;opacity:.5}
.empty-state h3{font-size:1.25rem;color:var(--foreground);margin-bottom:.5rem}
.empty-state p{max-width:420px;margin:0 auto}

/* Actions Row */
.actions-row{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:1rem;
  margin-bottom:1.25rem;
  flex-wrap:wrap;
}

/* Embed Code Block */
.embed-code{
  position:relative;
  background:#0f172a;
  color:#e2e8f0;
  border-radius:var(--radius);
  padding:1rem 1.25rem;
  font-family:'Consolas','Monaco',monospace;
  font-size:.85rem;
  line-height:1.5;
  overflow-x:auto;
  white-space:pre-wrap;
  word-break:break-all;
}
.embed-code__copy{
  position:absolute;
  top:.5rem;right:.5rem;
  background:rgba(255,255,255,.1);
  border:1px solid rgba(255,255,255,.15);
  color:#e2e8f0;
  border-radius:8px;
  padding:.35rem .65rem;
  font-size:.75rem;
  cursor:pointer;
  transition:all .15s ease;
}
.embed-code__copy:hover{background:rgba(255,255,255,.2)}

/* Responsive */
@media (max-width: 980px){
  .admin-shell{grid-template-columns:1fr}
  .admin-sidebar{
    position:fixed;
    inset:0 auto 0 0;
    width:280px;
    transform:translateX(-105%);
    transition:transform .2s ease;
    z-index:50;
  }
  .admin-sidebar.is-open{transform:translateX(0)}
  .admin-main{padding:1rem}
  .stats-grid{grid-template-columns:repeat(auto-fit, minmax(160px, 1fr))}
  .form-row .col-6, .form-row .col-4, .form-row .col-8{grid-column:span 12}
}

/* Login Page */
.login-page{
  min-height:100vh;
  display:flex;
  align-items:center;
  justify-content:center;
  padding:1rem;
  background: radial-gradient(circle at top right, rgba(22,163,74,.15), transparent 55%),
              radial-gradient(circle at bottom left, rgba(74,222,128,.15), transparent 55%),
              linear-gradient(135deg, #fff, #f0fff4);
}
.login-card{max-width:420px;width:100%}
.brand{display:flex;align-items:center;justify-content:center;gap:.75rem;margin-bottom:1.5rem}
.title{text-align:center;margin-bottom:.25rem;font-size:1.5rem}
.subtitle{text-align:center;color:var(--muted-foreground);margin-bottom:1.25rem}
.actions{display:flex;flex-direction:column;gap:.75rem;margin-top:.75rem}

/* Modem status signal bar */
.signal-bar{
  display:inline-flex;
  align-items:flex-end;
  gap:2px;
  height:18px;
}
.signal-bar__segment{
  width:5px;
  border-radius:2px 2px 0 0;
  background:var(--border);
}
.signal-bar__segment.active{background:var(--success)}
.signal-bar--weak .signal-bar__segment.active{background:var(--destructive)}
.signal-bar--medium .signal-bar__segment.active{background:var(--warning)}
.signal-bar--strong .signal-bar__segment.active{background:var(--success)}

/* Utility */
.truncate{overflow:hidden;text-overflow:ellipsis;white-space:nowrap;max-width:250px;display:inline-block}
