/* ==================================================
   ADAR CRM
   styles.css
================================================== */


/* ==================================================
   VARIABLES
================================================== */

:root{
  --bg:#f3f4f6;
  --panel:#ffffff;
  --ink:#171717;
  --muted:#6b7280;
  --line:#e5e7eb;
  --dark:#111827;
  --accent:#2563eb;

  --green:#20a464;
  --green-dark:#167548;

  --danger:#b42318;
  --danger-bg:#fff5f4;
  --danger-line:#f1c1bd;

  --soft:#f8fafc;

  --shadow:
    0 8px 28px rgba(17,24,39,.08);
}


/* ==================================================
   BASE
================================================== */

*{
  box-sizing:border-box;
}

html{
  height:100%;
}

body{
  margin:0;
  min-height:100%;
  font-family:
    Inter,
    ui-sans-serif,
    system-ui,
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    Roboto,
    Arial,
    sans-serif;

  background:var(--bg);
  color:var(--ink);
}

button,
input,
select,
textarea{
  font:inherit;
}

button{
  border:0;
  border-radius:10px;
  padding:10px 14px;
  cursor:pointer;
}

button:disabled{
  opacity:.55;
  cursor:not-allowed;
}

input,
select,
textarea{
  width:100%;
  border:1px solid #d1d5db;
  border-radius:10px;
  padding:10px 12px;
  background:#fff;
  outline:none;
}

textarea{
  resize:vertical;
}

input:focus,
select:focus,
textarea:focus{
  border-color:#9ca3af;
  box-shadow:
    0 0 0 3px rgba(37,99,235,.08);
}

.hidden{
  display:none!important;
}

.sub{
  color:var(--muted);
  font-size:13px;
  line-height:1.5;
}

.primary{
  background:var(--dark);
  color:#fff;
}

.primary:hover{
  background:#1f2937;
}

.error{
  color:#b91c1c;
  font-size:13px;
  margin-top:10px;
}


/* ==================================================
   LOGIN
================================================== */

.login-shell{
  min-height:100vh;
  display:grid;
  place-items:center;
  padding:24px;
}

.login-card{
  width:min(420px,100%);
  background:#fff;
  border:1px solid var(--line);
  border-radius:22px;
  padding:36px;
  box-shadow:var(--shadow);
}

.brand-mark{
  font-weight:900;
  letter-spacing:.18em;
}

.login-card h1{
  font-size:34px;
  margin:8px 0;
}

.login-card p{
  color:var(--muted);
}

label{
  display:grid;
  gap:7px;
  font-size:13px;
  color:#374151;
  margin:14px 0;
}


/* ==================================================
   ESTRUCTURA PRINCIPAL
================================================== */

.app{
  display:grid;
  grid-template-columns:
    86px
    24px
    1fr;

  min-height:100vh;
}

.main{
  min-width:0;
}


/* ==================================================
   SIDEBAR
================================================== */

.sidebar{
  background:#0f172a;
  color:#fff;

  display:flex;
  flex-direction:column;
  align-items:center;

  padding:20px 10px;
  gap:28px;
}

.logo{
  font-weight:900;
  font-size:17px;
  letter-spacing:.16em;
}

.sidebar nav{
  display:grid;
  gap:10px;
  width:100%;
}

.nav-item,
.logout{
  background:transparent;
  color:#cbd5e1;
  font-size:11px;
  padding:12px 6px;
}

.nav-item:hover{
  background:#172033;
  color:#fff;
}

.nav-item.active{
  background:#1e293b;
  color:#fff;
}

.logout{
  margin-top:auto;
}


/* ==================================================
   CHAT LATERAL
================================================== */

.chat-rail{
  position:relative;
  width:24px;
  background:#111827;
  overflow:visible;
  z-index:20;
}

.chat-label{
  position:absolute;
  inset:0;

  display:flex;
  align-items:center;
  justify-content:center;

  color:#e5e7eb;
  font-size:10px;
  letter-spacing:.15em;

  writing-mode:vertical-rl;
  transform:rotate(180deg);
}

.chat-panel{
  position:absolute;

  left:24px;
  top:0;

  height:100vh;
  width:310px;

  background:#fff;

  border-right:
    1px solid var(--line);

  box-shadow:
    12px 0 28px
    rgba(15,23,42,.08);

  transform:
    translateX(-110%);

  transition:
    transform .22s ease;

  padding:18px;

  overflow:auto;
}

.chat-rail:hover
.chat-panel{
  transform:translateX(0);
}

.chat-head{
  font-weight:800;
  margin-bottom:14px;
}

.chat-item{
  padding:12px;
  border:
    1px solid var(--line);

  border-radius:12px;
  margin-bottom:8px;
}

.chat-item b{
  font-size:12px;
}

.chat-item div{
  font-size:12px;
  line-height:1.45;
  margin-top:4px;
}

.chat-item small{
  color:var(--muted);
  display:block;
  margin-top:5px;
}


/* ==================================================
   TOPBAR
================================================== */

.topbar{
  height:88px;

  background:#fff;

  border-bottom:
    1px solid var(--line);

  display:flex;
  align-items:center;
  justify-content:space-between;

  padding:0 28px;
  gap:18px;
}

.eyebrow{
  font-size:11px;
  letter-spacing:.14em;
  color:var(--muted);
}

.topbar h2{
  margin:4px 0 0;
}

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

.smart-search-wrap{
  position:relative;
  width:min(420px,38vw);
}

.search-icon{
  position:absolute;

  left:12px;
  top:50%;

  transform:
    translateY(-50%);

  color:#6b7280;

  pointer-events:none;
}

.smart-search-wrap input{
  padding-left:34px;
}


/* ==================================================
   WORKSPACE
================================================== */

.workspace{
  display:grid;

  grid-template-columns:
    330px
    minmax(0,1fr);

  gap:18px;

  padding:18px;

  height:
    calc(100vh - 88px);
}

.list-pane,
.detail-pane,
.card{
  background:#fff;

  border:
    1px solid var(--line);

  border-radius:16px;

  box-shadow:
    0 1px 2px
    rgba(0,0,0,.02);

  overflow:auto;
}


/* ==================================================
   LISTA DE PROSPECTOS
================================================== */

.list-pane{
  min-width:0;
}

.list-toolbar{
  padding:14px;

  border-bottom:
    1px solid var(--line);

  display:grid;
  gap:8px;

  position:sticky;
  top:0;

  background:#fff;

  z-index:2;
}

.prospect-list{
  padding:8px;
}

.prospect-card{
  padding:13px;

  border-radius:12px;

  margin-bottom:6px;

  border:
    1px solid transparent;

  cursor:pointer;

  transition:
    background .15s ease,
    border-color .15s ease;
}

.prospect-card:hover{
  background:#f8fafc;
}

.prospect-card.active{
  border-color:#cbd5e1;
  background:#f8fafc;
}

.prospect-card h4{
  margin:0 0 5px;
  font-size:14px;
}

.prospect-card .meta{
  font-size:12px;
  color:var(--muted);
  line-height:1.4;
}

.badge{
  display:inline-block;

  font-size:10px;

  padding:4px 7px;

  border-radius:999px;

  background:#eef2ff;
  color:#3730a3;

  margin-top:7px;
}


/* ==================================================
   DETALLE DEL PROSPECTO
================================================== */

.detail-pane{
  padding:20px;
  min-width:0;
}

.empty-state{
  min-height:180px;
  height:100%;

  display:grid;
  place-items:center;

  color:var(--muted);

  text-align:center;

  padding:20px;
}


/* ==================================================
   CABECERA DEL PROSPECTO
================================================== */

.prospect-header{
  border-bottom:
    1px solid var(--line);

  padding-bottom:20px;
  margin-bottom:16px;
}

.prospect-header-row{
  display:flex;

  justify-content:
    space-between;

  gap:20px;

  align-items:flex-start;
}

.prospect-identity{
  display:flex;

  gap:15px;

  align-items:center;

  min-width:0;
}

.prospect-avatar{
  width:58px;
  height:58px;
  min-width:58px;

  border-radius:50%;

  display:flex;
  align-items:center;
  justify-content:center;

  background:#eef0f3;

  font-size:20px;
  font-weight:700;

  color:#151a21;
}

.prospect-title-row{
  display:flex;
  align-items:center;
  gap:10px;
}

.prospect-title{
  margin:0;

  font-size:25px;
  line-height:1.15;

  word-break:
    break-word;
}

.prospect-project{
  margin-top:4px;

  color:#6e7580;

  font-size:14px;
}

.prospect-contact-row{
  display:flex;
  flex-wrap:wrap;

  gap:8px 18px;

  margin-top:12px;

  font-size:12px;

  color:#343a43;
}

.prospect-header-actions{
  display:flex;

  align-items:flex-start;

  gap:10px;

  flex-wrap:wrap;

  justify-content:flex-end;
}


/* ==================================================
   BOTONES
================================================== */

.btn-secondary{
  background:#fff;

  border:
    1px solid #d8dde4;

  border-radius:8px;

  padding:9px 15px;

  font-weight:600;
}

.btn-secondary:hover{
  background:#f8fafc;
}

.btn-danger{
  border:
    1px solid var(--danger-line);

  background:
    var(--danger-bg);

  color:
    var(--danger);

  border-radius:8px;

  padding:9px 11px;

  font-weight:700;
}

.btn-danger:hover{
  background:#feeceb;
}

.miniEditProspect{
  background:#eef4ff;

  color:#2563eb;

  padding:5px 9px;

  font-size:11px;
}

.miniEditProspect:hover{
  background:#e0eaff;
}


/* ==================================================
   ESTADO DEL PROSPECTO
================================================== */

.stage-box{
  padding:8px 10px;

  background:#f5f6f8;

  border-radius:9px;

  min-width:145px;
}

.stage-box-label{
  font-size:10px;
  color:#717885;
  margin-bottom:4px;
}

.stage-select{
  border:0;

  background:#e8efff;

  color:#1766d7;

  padding:7px 9px;

  border-radius:7px;

  font-weight:600;

  cursor:pointer;

  box-shadow:none;
}


/* ==================================================
   SIGUIENTE ACCIÓN
================================================== */

.next-action-card{
  width:180px;

  text-align:left;

  border:0;

  border-radius:9px;

  padding:11px 13px;

  background:#171b20;

  color:#fff;

  cursor:pointer;
}

.next-action-card:hover{
  background:#252a31;
}

.next-action-label{
  font-size:10px;
  opacity:.75;
}

.next-action-title{
  display:block;

  margin-top:4px;

  font-size:13px;
}

.next-action-date{
  margin-top:3px;

  font-size:10px;

  opacity:.7;
}


/* ==================================================
   PROGRESO COMERCIAL
================================================== */

.progress-wrap{
  margin-top:22px;
  margin-bottom:4px;
}

.progress-head{
  display:flex;

  justify-content:
    space-between;

  align-items:center;

  margin-bottom:9px;

  gap:12px;
}

.progress-title{
  font-size:12px;
  font-weight:700;
  color:#253044;
}

.progress-value{
  font-size:11px;
  color:#778195;
}

.progress-track{
  width:100%;
  height:7px;

  border-radius:999px;

  background:#e9edf0;

  overflow:hidden;
}

.progress-bar{
  height:100%;

  background:
    var(--green);

  border-radius:999px;

  transition:
    width .25s ease;
}

.progress-labels{
  display:flex;

  justify-content:
    space-between;

  margin-top:7px;

  gap:6px;
}

.progress-label{
  width:12.5%;

  font-size:9px;

  text-align:center;

  white-space:nowrap;

  overflow:hidden;

  text-overflow:ellipsis;

  color:#a2a8b2;
}

.progress-label.active{
  color:
    var(--green-dark);

  font-weight:600;
}


/* ==================================================
   PESTAÑAS
================================================== */

.tabs{
  display:flex;

  gap:6px;

  margin:16px 0;

  overflow-x:auto;

  padding-bottom:2px;
}

.tabs button{
  background:#f3f4f6;

  color:#374151;

  font-size:12px;

  white-space:nowrap;
}

.tabs button:hover{
  background:#e9edf2;
}

.tabs button.active{
  background:#111827;
  color:#fff;
}


/* ==================================================
   TARJETAS
================================================== */

.cards-grid{
  display:grid;

  grid-template-columns:
    repeat(
      2,
      minmax(0,1fr)
    );

  gap:12px;
}

.info-card{
  border:
    1px solid var(--line);

  border-radius:14px;

  padding:14px;

  min-width:0;
}

.info-card h3{
  margin:0 0 10px;
  font-size:13px;
}

.info-card-head{
  display:flex;

  justify-content:
    space-between;

  align-items:center;

  gap:12px;
}

.info-card-head h3{
  margin:0;
}

.kv{
  display:grid;

  grid-template-columns:
    130px
    minmax(0,1fr);

  gap:7px 10px;

  font-size:12px;
}

.kv b{
  color:#6b7280;
  font-weight:600;
}

.kv span{
  min-width:0;
  word-break:break-word;
}

.full-card{
  grid-column:1/-1;
}

.timeline-item{
  padding:10px 0;

  border-bottom:
    1px solid var(--line);

  font-size:12px;

  line-height:1.5;
}

.timeline-item:last-child{
  border-bottom:0;
}

.timeline-item strong{
  display:block;

  margin-bottom:3px;
}


/* ==================================================
   CONVERSACIONES
================================================== */

.conversation-history{
  margin-top:18px;
}

.conversation-entry{
  display:flex;

  gap:12px;

  padding:14px 0;

  border-bottom:
    1px solid var(--line);
}

.conversation-entry:last-child{
  border-bottom:0;
}

.conversation-icon{
  width:36px;
  height:36px;
  min-width:36px;

  border-radius:50%;

  background:#f3f4f6;

  display:flex;

  align-items:center;
  justify-content:center;

  font-size:15px;
}

.conversation-body{
  flex:1;
  min-width:0;
}

.conversation-top{
  display:flex;

  justify-content:
    space-between;

  gap:12px;

  align-items:center;
}

.conversation-top strong{
  font-size:13px;
}

.conversation-top span{
  font-size:11px;

  color:
    var(--muted);

  white-space:nowrap;
}

.conversation-text{
  margin-top:6px;

  font-size:13px;

  line-height:1.55;

  color:#374151;

  white-space:pre-wrap;

  word-break:break-word;
}

.conversation-direction{
  display:inline-block;

  margin-top:7px;

  padding:3px 7px;

  border-radius:999px;

  background:#f3f4f6;

  color:#6b7280;

  font-size:10px;
}

.conversation-empty{
  padding:38px 20px;

  text-align:center;

  color:var(--muted);

  font-size:13px;
}

.conversation-dialog{
  width:min(600px,92vw);
}


/* ==================================================
   OTRAS VISTAS
================================================== */

.single-pane{
  grid-template-columns:1fr;
}

.single-pane .card{
  padding:22px;
}

.ai-badge{
  display:inline-block;

  background:#111827;

  color:#fff;

  border-radius:999px;

  padding:6px 10px;

  font-size:11px;
}

.ai-card h3{
  font-size:26px;

  margin:
    12px 0 4px;
}

.ai-card p{
  color:
    var(--muted);
}

.result{
  padding:12px 0;

  border-bottom:
    1px solid var(--line);
}

.result:last-child{
  border-bottom:0;
}


/* ==================================================
   DIALOG BASE
================================================== */

dialog{
  border:0;

  border-radius:18px;

  padding:0;

  box-shadow:
    var(--shadow);

  width:
    min(760px,92vw);

  max-height:90vh;

  overflow:auto;
}

dialog::backdrop{
  background:
    rgba(15,23,42,.48);
}

.dialog-form{
  padding:22px;
}

.dialog-head{
  display:flex;

  justify-content:
    space-between;

  align-items:center;

  gap:15px;
}

.dialog-head h3{
  margin:0;
}

.icon-btn{
  font-size:24px;

  background:transparent;

  padding:5px 10px;
}

.grid2{
  display:grid;

  grid-template-columns:
    1fr 1fr;

  gap:0 14px;
}

.dialog-actions{
  display:flex;

  justify-content:
    flex-end;

  gap:10px;

  margin-top:18px;
}


/* ==================================================
   DIALOGS CRM
================================================== */

.crm-dialog{
  width:
    min(760px,92vw);
}

.crm-dialog-form{
  padding:24px;

  background:#fff;
}

.crm-dialog-header{
  display:flex;

  justify-content:
    space-between;

  align-items:center;

  gap:16px;

  margin-bottom:22px;
}

.crm-dialog-title{
  margin:0;

  font-size:22px;
}

.crm-dialog-subtitle{
  margin-top:4px;

  font-size:12px;

  color:#747b88;
}

.crm-dialog-close{
  border:0;

  background:#f1f3f5;

  width:34px;
  height:34px;

  padding:0;

  border-radius:50%;

  cursor:pointer;

  font-size:18px;

  display:flex;
  align-items:center;
  justify-content:center;
}

.crm-dialog-close:hover{
  background:#e5e7eb;
}

.crm-dialog-grid{
  display:grid;

  grid-template-columns:
    1fr 1fr;

  gap:0 15px;
}

.crm-dialog-full{
  grid-column:1/-1;
}

.crm-dialog-actions{
  display:flex;

  justify-content:
    flex-end;

  gap:10px;

  margin-top:22px;
}

.crm-btn-cancel{
  padding:10px 16px;

  border-radius:9px;

  border:
    1px solid #d5d9df;

  background:#fff;

  cursor:pointer;
}

.crm-btn-cancel:hover{
  background:#f8fafc;
}

.crm-btn-save{
  padding:10px 18px;

  border-radius:9px;

  border:0;

  background:#101827;

  color:#fff;

  cursor:pointer;

  font-weight:600;
}

.crm-btn-save:hover{
  background:#1f2937;
}


/* ==================================================
   SCROLLBARS
================================================== */

.list-pane,
.detail-pane,
.card,
.chat-panel{
  scrollbar-width:thin;

  scrollbar-color:
    #cbd5e1
    transparent;
}

.list-pane::-webkit-scrollbar,
.detail-pane::-webkit-scrollbar,
.card::-webkit-scrollbar,
.chat-panel::-webkit-scrollbar{
  width:8px;
}

.list-pane::-webkit-scrollbar-thumb,
.detail-pane::-webkit-scrollbar-thumb,
.card::-webkit-scrollbar-thumb,
.chat-panel::-webkit-scrollbar-thumb{
  background:#cbd5e1;
  border-radius:999px;
}


/* ==================================================
   TABLET
================================================== */

@media(max-width:1200px){

  .prospect-header-row{
    flex-direction:column;
  }

  .prospect-header-actions{
    justify-content:flex-start;
  }

}


/* ==================================================
   RESPONSIVE
================================================== */

@media(max-width:1000px){

  .workspace{
    grid-template-columns:1fr;

    height:auto;

    min-height:
      calc(100vh - 88px);
  }

  .list-pane{
    max-height:42vh;
  }

  .actions{
    width:55%;
  }

  .smart-search-wrap{
    width:100%;
  }

  .cards-grid{
    grid-template-columns:1fr;
  }

  .topbar{
    padding:0 16px;
  }

  .sidebar{
    display:none;
  }

  .app{
    grid-template-columns:
      24px 1fr;
  }

  .chat-panel{
    width:
      min(310px,88vw);
  }

  .prospect-header-row{
    flex-direction:column;
  }

  .prospect-header-actions{
    justify-content:flex-start;
  }

  .crm-dialog-grid{
    grid-template-columns:1fr;
  }

  .crm-dialog-full{
    grid-column:auto;
  }

}


/* ==================================================
   MÓVIL
================================================== */

@media(max-width:650px){

  .topbar{
    height:auto;

    min-height:88px;

    padding:
      14px 12px;

    align-items:flex-start;

    flex-direction:column;
  }

  .actions{
    width:100%;
  }

  .workspace{
    padding:10px;

    min-height:
      calc(100vh - 110px);
  }

  .detail-pane{
    padding:14px;
  }

  .prospect-identity{
    align-items:flex-start;
  }

  .prospect-avatar{
    width:48px;
    height:48px;
    min-width:48px;

    font-size:17px;
  }

  .prospect-title{
    font-size:21px;
  }

  .prospect-contact-row{
    flex-direction:column;

    gap:5px;
  }

  .prospect-header-actions{
    width:100%;
  }

  .btn-secondary,
  .btn-danger{
    flex:1;
  }

  .stage-box{
    width:100%;
  }

  .next-action-card{
    width:100%;
  }

  .progress-labels{
    display:none;
  }

  .tabs{
    margin:
      14px -2px;
  }

  .kv{
    grid-template-columns:
      110px
      minmax(0,1fr);
  }

  .grid2{
    grid-template-columns:1fr;
  }

  .conversation-top{
    align-items:flex-start;
    flex-direction:column;
    gap:3px;
  }

  .conversation-top span{
    white-space:normal;
  }

  .info-card-head{
    align-items:flex-start;
  }

  dialog{
    width:94vw;
  }

  .crm-dialog-form,
  .dialog-form{
    padding:18px;
  }

}


/* ==================================================
   PANTALLAS MUY PEQUEÑAS
================================================== */

@media(max-width:420px){

  .app{
    grid-template-columns:
      18px 1fr;
  }

  .chat-rail{
    width:18px;
  }

  .chat-panel{
    left:18px;
  }

  .chat-label{
    font-size:8px;
  }

  .workspace{
    padding:7px;
  }

  .detail-pane{
    padding:11px;
  }

  .prospect-header-actions{
    display:grid;
    grid-template-columns:1fr 1fr;
  }

  .stage-box,
  .next-action-card{
    grid-column:1/-1;
  }

  .kv{
    grid-template-columns:1fr;
    gap:3px;
  }

  .kv span{
    margin-bottom:8px;
  }

}
