/********************************************
 * DRIFTLY DASHBOARD – ESTILO GLOBAL STRIPE-LIKE
 ********************************************/

/* Reset básico */
*,
*::before,
*::after {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
}

/* Variables de diseño */
:root {
  --driftly-bg: #f4f5f7;
  --driftly-bg-elevated: #ffffff;
  --driftly-sidebar-bg: #020617;
  --driftly-sidebar-border: rgba(15, 23, 42, 0.5);
  --driftly-sidebar-hover: rgba(15, 23, 42, 0.9);
  --driftly-text-main: #111827;
  --driftly-text-muted: #6b7280;
  --driftly-border: #e5e7eb;
  --driftly-border-soft: rgba(148, 163, 184, 0.35);
  --driftly-accent: #ff7a18;
  --driftly-accent-soft: rgba(255, 122, 24, 0.08);
  --driftly-accent-strong: #e96300;
  --driftly-success-bg: #ecfdf3;
  --driftly-success-text: #166534;
  --driftly-danger-bg: #fef2f2;
  --driftly-danger-text: #991b1b;
  --driftly-radius-lg: 18px;
  --driftly-radius-md: 12px;
  --driftly-radius-pill: 999px;
  --driftly-shadow-soft: 0 18px 45px rgba(15, 23, 42, 0.12);
  --driftly-shadow-card: 0 10px 30px rgba(15, 23, 42, 0.08);
}

/********************************************
 * BODY / LAYOUT BASE
 ********************************************/

body.d-body {
  min-height: 100vh;
  background: linear-gradient(to bottom, #f9fafb, #eef1f5);
  color: var(--driftly-text-main);
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Inter", "Segoe UI", sans-serif;
  font-size: 14px;
  line-height: 1.5;
}

/* Contenedor general tipo app */
.d-app-shell {
  display: flex;
  min-height: 100vh;
  overflow: hidden;
}

/********************************************
 * SIDEBAR
 ********************************************/

.d-sidebar {
  width: 240px;
  background: radial-gradient(circle at top left, #020617, #030712 60%);
  color: #e5e7eb;
  padding: 18px 14px;
  border-right: 1px solid var(--driftly-sidebar-border);
  display: flex;
  flex-direction: column;
  gap: 24px;
  position: relative;
  z-index: 30;
}

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

.d-sidebar__logo-mark {
  width: 32px;
  height: 32px;
  border-radius: 12px;
  background: radial-gradient(circle at 20% 10%, #ffe5c2, #ff7a18 40%, #7c2d12 100%);
  box-shadow: 0 0 18px rgba(255, 122, 24, 0.7);
}

.d-sidebar__logo-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.d-sidebar__logo-title {
  font-size: 1.05rem;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.d-sidebar__logo-subtitle {
  font-size: 0.78rem;
  color: #9ca3af;
}

.d-sidebar__nav {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-top: 10px;
}

.d-sidebar__section-title {
  padding: 10px 10px 4px;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #6b7280;
}

.d-sidebar__nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 999px;
  text-decoration: none;
  color: #e5e7eb;
  font-size: 0.86rem;
  transition: background 0.15s ease, color 0.15s ease, transform 0.1s ease;
}

.d-sidebar__nav-item:hover {
  background: rgba(15, 23, 42, 0.8);
  transform: translateX(1px);
}

.d-sidebar__nav-item.is-active {
  background: linear-gradient(to right, rgba(255, 122, 24, 0.9), rgba(251, 113, 133, 0.9));
  color: #111827;
}

/********************************************
 * MAIN SHELL + HEADER
 ********************************************/

.d-main-shell {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

/* Header superior */
.d-header {
  height: 64px;
  display: flex;
  align-items: center;
  padding: 0 24px;
  background: rgba(255, 255, 255, 0.92);
  border-bottom: 1px solid var(--driftly-border-soft);
  backdrop-filter: blur(18px);
  position: sticky;
  top: 0;
  z-index: 20;
}

.d-header__title {
  display: flex;
  align-items: center;
  gap: 8px;
}

.d-header__title-main {
  font-size: 0.98rem;
  font-weight: 600;
  color: #111827;
}

.d-header__title-pill {
  font-size: 0.7rem;
  padding: 3px 7px;
  border-radius: 999px;
  background: #fef3c7;
  color: #92400e;
  border: 1px solid #facc15;
}

.d-header__menu-toggle {
  display: none;
  border: none;
  background: transparent;
  font-size: 1.1rem;
  margin-right: 10px;
  cursor: pointer;
}

.d-header__spacer {
  flex: 1;
}

.d-header__user {
  display: flex;
  align-items: center;
  gap: 14px;
}

.d-header__user-info {
  display: flex;
  flex-direction: column;
  font-size: 0.8rem;
}

.d-header__user-name {
  font-weight: 500;
}

.d-header__user-role {
  color: var(--driftly-text-muted);
  font-size: 0.75rem;
}

.d-header__logout {
  font-size: 0.8rem;
  padding: 6px 12px;
  border-radius: 999px;
  text-decoration: none;
  border: 1px solid var(--driftly-border);
  background: #f9fafb;
  color: #111827;
  transition: background 0.15s ease, border-color 0.15s ease;
}

.d-header__logout:hover {
  background: #111827;
  color: #f9fafb;
  border-color: #111827;
}

/********************************************
 * MAIN CONTENT
 ********************************************/

.d-main {
  padding: 22px 26px 32px;
  min-height: calc(100vh - 64px);
}

/* Card contenedor de página */
.d-page-card {
  max-width: 1180px;
  margin: 0 auto;
  background: var(--driftly-bg-elevated);
  border-radius: var(--driftly-radius-lg);
  box-shadow: var(--driftly-shadow-card);
  border: 1px solid rgba(148, 163, 184, 0.25);
  padding: 22px 22px 18px;
}

/* Título/subtítulo de página */
.d-page-card__header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 16px;
}

.d-page-card__title {
  font-size: 1.25rem;
  font-weight: 600;
  margin: 0 0 4px 0;
}

.d-page-card__subtitle {
  margin: 0;
  color: var(--driftly-text-muted);
  font-size: 0.9rem;
}

/********************************************
 * PLACEHOLDER / HELP TEXT
 ********************************************/

.d-placeholder {
  padding: 14px 14px;
  border-radius: 12px;
  border: 1px dashed rgba(148, 163, 184, 0.7);
  background-color: rgba(15, 23, 42, 0.02);
  font-size: 0.88rem;
  color: var(--driftly-text-muted);
}

/********************************************
 * BOTONES & BADGES
 ********************************************/

.d-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--driftly-radius-pill);
  border: 1px solid transparent;
  background: #e5e7eb;
  font-size: 0.8rem;
  padding: 7px 14px;
  cursor: pointer;
  line-height: 1.2;
  text-decoration: none;
  white-space: nowrap;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease,
    box-shadow 0.15s ease, transform 0.08s ease;
}

.d-btn:hover {
  transform: translateY(-0.5px);
}

/* Primario (naranja) */
.d-btn--primary {
  background: linear-gradient(to right, var(--driftly-accent), var(--driftly-accent-strong));
  color: #ffffff;
  box-shadow: 0 8px 18px rgba(249, 115, 22, 0.4);
  border-color: transparent;
}

.d-btn--primary:hover {
  box-shadow: 0 10px 22px rgba(249, 115, 22, 0.5);
}

/* Ghost / Secundario */
.d-btn--ghost {
  background: #f9fafb;
  border-color: var(--driftly-border);
  color: #111827;
}

.d-btn--ghost:hover {
  background: #e5e7eb;
}

/* Badges */
.d-badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 500;
}

.d-badge--success {
  background: var(--driftly-success-bg);
  color: var(--driftly-success-text);
}

.d-badge--danger {
  background: var(--driftly-danger-bg);
  color: var(--driftly-danger-text);
}

/********************************************
 * CAMPOS / FORM
 ********************************************/

.d-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 0.8rem;
}

.d-field label {
  color: var(--driftly-text-muted);
  font-size: 0.77rem;
}

.d-field input,
.d-field select,
.d-field textarea {
  border-radius: var(--driftly-radius-pill);
  border: 1px solid var(--driftly-border);
  padding: 8px 12px;
  font-size: 0.85rem;
  outline: none;
  background: #ffffff;
  transition: border-color 0.12s ease, box-shadow 0.12s ease, background 0.12s ease;
}

.d-field textarea {
  border-radius: var(--driftly-radius-md);
  resize: vertical;
  min-height: 80px;
}

.d-field input:focus,
.d-field select:focus,
.d-field textarea:focus {
  border-color: var(--driftly-accent);
  box-shadow: 0 0 0 1px rgba(249, 115, 22, 0.2);
}

/********************************************
 * TOOLBAR DE CATÁLOGO
 ********************************************/

.d-catalog-toolbar {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  margin-bottom: 16px;
  gap: 12px;
  flex-wrap: wrap;
}

.d-catalog-toolbar__left {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.d-catalog-toolbar__right {
  display: flex;
  gap: 8px;
}

/********************************************
 * GRID DE TARJETAS
 ********************************************/

.d-card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 18px;
  margin-top: 10px;
}

.d-product-card {
  background-color: #ffffff;
  border-radius: 16px;
  padding: 12px;
  box-shadow: var(--driftly-shadow-card);
  border: 1px solid rgba(15, 23, 42, 0.04);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.d-product-card__image-wrap {
  width: 100%;
  padding-top: 70%;
  border-radius: 12px;
  overflow: hidden;
  background: #f3f4f6;
  position: relative;
}

.d-product-card__image {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.d-product-card__body {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.d-product-card__title {
  font-size: 0.95rem;
  font-weight: 600;
}

.d-product-card__provider {
  font-size: 0.8rem;
  color: var(--driftly-text-muted);
}

.d-product-card__prices {
  margin-top: 4px;
  border-radius: 12px;
  background-color: #f9fafb;
  padding: 8px 10px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.d-product-card__price-row {
  display: flex;
  justify-content: space-between;
  font-size: 0.8rem;
}

.d-product-card__price-row .label {
  color: var(--driftly-text-muted);
}

.d-product-card__price-row .value {
  font-weight: 500;
}

.d-product-card__footer {
  margin-top: 6px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.d-product-card__status {
  font-size: 0.78rem;
}

.d-product-card__actions {
  display: flex;
  gap: 6px;
}

/********************************************
 * PAGINACIÓN
 ********************************************/

.d-pagination {
  margin-top: 18px;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.85rem;
}

.d-pagination__link {
  text-decoration: none;
  padding: 5px 10px;
  border-radius: 999px;
  border: 1px solid var(--driftly-border);
}

.d-pagination__current {
  color: var(--driftly-text-muted);
}

/********************************************
 * MODAL
 ********************************************/

.d-modal {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: none;
}

.d-modal__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
}

.d-modal__dialog {
  position: relative;
  max-width: 760px;
  margin: 40px auto;
  background: #ffffff;
  border-radius: 18px;
  box-shadow: var(--driftly-shadow-soft);
  overflow: hidden;
  max-height: calc(100vh - 80px);
  display: flex;
  flex-direction: column;
}

.d-modal__close {
  position: absolute;
  top: 10px;
  right: 14px;
  border: none;
  background: transparent;
  font-size: 1.4rem;
  line-height: 1;
  cursor: pointer;
}

.d-modal__content {
  padding: 16px 18px 14px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  overflow: auto;
}

.d-modal__header {
  display: flex;
  gap: 12px;
}

.d-modal__image-wrap {
  width: 110px;
  height: 110px;
  border-radius: 14px;
  overflow: hidden;
  background: #f3f4f6;
  flex-shrink: 0;
}

.d-modal__image-wrap img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.d-modal__title-block h2 {
  font-size: 1.05rem;
  margin: 0 0 4px 0;
}

.d-modal__title-block p {
  margin: 0;
  font-size: 0.85rem;
  color: var(--driftly-text-muted);
}

.d-modal__body {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.d-modal__section h4 {
  margin: 0 0 4px 0;
  font-size: 0.9rem;
}

.d-modal__description {
  font-size: 0.85rem;
  color: var(--driftly-text-muted);
}

.d-modal__form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.d-modal__footer {
  padding: 10px 18px 14px;
  border-top: 1px solid var(--driftly-border);
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

body.d-modal-open {
  overflow: hidden;
}

/********************************************
 * TABLA SIMPLE
 ********************************************/

.d-table {
  overflow-x: auto;
  margin-top: 10px;
}

.d-table__inner {
  width: 100%;
  border-collapse: collapse;
  background: #fff;
  border-radius: 14px;
  overflow: hidden;
}

.d-table__inner th {
  text-align: left;
  padding: 14px;
  font-size: 0.85rem;
  color: var(--driftly-text-muted);
  background: #f1f1f4;
}

.d-table__inner td {
  padding: 14px;
  border-bottom: 1px solid #eee;
  font-size: 0.92rem;
}

.d-table__inner tr:last-child td {
  border-bottom: none;
}

/********************************************
 * RESPONSIVE GLOBAL
 ********************************************/

@media (max-width: 960px) {
  .d-sidebar {
    position: fixed;
    left: -260px;
    top: 0;
    bottom: 0;
    z-index: 40;
    transition: left 0.2s ease;
  }

  body.d-sidebar-open .d-sidebar {
    left: 0;
  }

  .d-header__menu-toggle {
    display: inline-flex;
  }

  .d-main {
    padding: 18px 16px 26px;
  }

  .d-page-card {
    padding: 18px 15px 14px;
  }

  .d-modal__dialog {
    margin: 18px 10px;
  }

  .d-modal__form-grid {
    grid-template-columns: 1fr;
  }

  .d-sidebar__logo-text {
    display: none;
  }
}

@media (max-width: 640px) {
  .d-header__user-info {
    display: none;
  }

  .d-header__logout {
    padding-inline: 10px;
  }

  .d-card-grid {
    grid-template-columns: minmax(0, 1fr);
  }
}

/* ============================================
   FIX GLOBAL – FULL WIDTH EN MÓVIL
   Para todas las vistas que usan .d-page-card
   ============================================ */
@media (max-width: 640px) {
  .d-page-card {
    max-width: 100% !important;
    width: 100% !important;
    margin: 0 !important;
    border-radius: 0 !important;
    box-shadow: none !important;
    padding: 18px 14px !important;
  }

  /* Forzar layout vertical */
  .vds-perfil-layout {
    flex-direction: column !important;
    width: 100% !important;
    gap: 18px !important;
  }

  .vds-perfil-aside {
    width: 100% !important;
    display: flex !important;
    align-items: center !important;
    gap: 16px !important;
  }

  .vds-avatar-box img,
  .vds-avatar-placeholder {
    width: 80px !important;
    height: 80px !important;
  }

  /* Formularios a 1 columna */
  .vds-grid {
    grid-template-columns: 1fr !important;
  }

  .vds-field--full,
  .vds-field--half {
    grid-column: 1 / -1 !important;
  }
}

/* ============================================================
   FIX DEFINITIVO – PERMITIR ANCHO COMPLETO DEL CONTENIDO EN MÓVIL
   ============================================================ */
@media (max-width: 768px) {

    /* El wrapper principal ya NO debe comportarse como flex */
    .d-app-shell {
        display: block !important;
        width: 100% !important;
        max-width: 100% !important;
        overflow-x: hidden !important;
    }

    /* El contenedor principal ahora puede ocupar todo el ancho */
    .d-main-shell {
        width: 100% !important;
        max-width: 100% !important;
        margin: 0 !important;
        padding: 0 !important;
        display: block !important;
    }

    /* Sidebar en modo overlay, sin ocupar espacio y sin empujar layout */
    .d-sidebar {
        position: fixed !important;
        top: 0;
        bottom: 0;
        left: -260px;
        width: 240px;
        z-index: 200;
        transition: left 0.25s ease;
    }

    body.d-sidebar-open .d-sidebar {
        left: 0 !important;
    }

    /* Main content full width */
    .d-main {
        width: 100% !important;
        max-width: 100% !important;
        margin: 0 !important;
        padding: 18px 14px !important;
    }

    /* Card a ancho completo */
    .d-page-card {
        width: 100% !important;
        max-width: 100% !important;
        margin: 0 !important;
        border-radius: 0 !important;
        box-shadow: none !important;
    }
}
