/* =============================================
   TymForest Logistica - Ventas Especiales
   Estilos principales
============================================= */

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: 'IBM Plex Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background-color: #f8f5ef;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='4' height='4'%3E%3Cline x1='0' y1='4' x2='4' y2='0' stroke='%23e2dbd0' stroke-width='.3'/%3E%3Cline x1='0' y1='0' x2='4' y2='4' stroke='%23e2dbd0' stroke-width='.3'/%3E%3C/svg%3E");
  color: #2c2c2c;
  display: flex;
  min-height: 100vh;
  letter-spacing: -0.01em;
}

a { color: #14532d; text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---- Login Page ---- */
.login-page {
  display: flex;
  align-items: center;
  justify-content: center;
  background: #f8f5ef;
  position: relative;
  overflow: hidden;
}

.login-container {
  width: 100%;
  max-width: 480px;
  padding: 20px;
  position: relative;
  z-index: 1;
}

.login-box {
  background: #fff;
  border-radius: 2px;
  padding: 48px;
  border: 1px solid #d6cfc4;
  position: relative;
}

.login-header {
  text-align: center;
  margin-bottom: 30px;
}

.login-logo {
  width: 72px;
  height: 72px;
  object-fit: contain;
  margin-bottom: 16px;
}

.login-header h1 {
  font-size: 24px;
  color: #14532d;
  text-transform: uppercase;
  letter-spacing: 2px;
  font-weight: 600;
}

.login-header p {
  color: #8a8078;
  margin-top: 4px;
}

.login-info {
  margin-top: 20px;
  padding: 15px;
  background: transparent;
  border-radius: 1px;
  text-align: center;
}

.login-info p {
  margin: 0;
  color: #8a8078;
  font-size: 14px;
}

/* ---- Alerts ---- */
.alert {
  padding: 12px 16px;
  border-radius: 2px;
  font-size: 14px;
  margin-bottom: 16px;
}
.alert-error { background: #fee2e2; color: #991b1b; border: 1px solid #fecaca; }
.alert-success { background: #d1fae5; color: #065f46; border: 1px solid #a7f3d0; }
.alert-warning { background: #fef3c7; color: #92400e; border: 1px solid #fcd34d; }

/* ---- Topbar ---- */
.topbar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 60px;
  background: #fff;
  border-bottom: 1px solid #d6cfc4;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0;
  z-index: 1000;
}

.topbar-left {
  display: flex;
  align-items: center;
}

.topbar-logo {
  width: 60px;
  height: 60px;
  object-fit: contain;
  padding: 10px;
  flex-shrink: 0;
  border-right: 1px solid #d6cfc4;
}

.topbar-brand {
  font-size: 15px;
  font-weight: 600;
  color: #14532d;
  padding-left: 16px;
  text-transform: uppercase;
  letter-spacing: 1.5px;
}

.topbar-right {
  display: flex;
  align-items: center;
  height: 100%;
}

.topbar-right > * {
  display: flex;
  align-items: center;
  padding: 0 24px;
  height: 100%;
  border-left: 1px solid #d6cfc4;
}

.topbar-user {
  display: flex;
  align-items: center;
  gap: 0;
  font-size: 14px;
  color: #374151;
  padding: 0 !important;
  height: 100%;
}

.topbar-user-info {
  display: flex;
  flex-direction: column;
  justify-content: center;
  line-height: 1.3;
  padding: 0 24px;
  height: 100%;
  border-left: 1px solid #d6cfc4;
}

.topbar-user-name {
  font-size: 13px;
  font-weight: 500;
  color: #2c2c2c;
}

.topbar-user-role {
  font-size: 11px;
  color: #8a8078;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.topbar-logout {
  font-size: 12px;
  color: #8a8078;
  padding: 0 24px;
  height: 100%;
  display: flex;
  align-items: center;
  border: none;
  border-left: 1px solid #d6cfc4;
  border-radius: 0;
  transition: color 0.2s;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  text-decoration: none;
}

.topbar-logout:hover {
  color: #991b1b;
  background: #fef2f2;
  text-decoration: none;
}

/* ---- Buttons ---- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 10px 20px;
  border-radius: 2px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  border: none;
  transition: all 0.15s;
  text-decoration: none;
  gap: 6px;
  white-space: nowrap;
}
.btn:hover { text-decoration: none; opacity: 0.85; }

.btn-primary {
  background: #14532d;
  color: #fff;
  font-family: inherit;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  font-size: 13px;
  font-weight: 600;
}
.btn-primary:hover { background: #1a6b3a; }

.btn-secondary {
  background: #fff;
  color: #2c2c2c;
  border: 1px solid #d6cfc4;
  font-family: inherit;
  letter-spacing: 0.02em;
  position: relative;
}
.btn-secondary:hover { background: #f8f5ef; border-color: #b8b0a4; }

.btn-success { background: #059669; color: #fff; }
.btn-success:hover { background: #047857; }

.btn-danger {
  background: #9a3412;
  color: #fff;
  font-family: inherit;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-size: 13px;
  font-weight: 600;
}
.btn-danger:hover { background: #7c2d12; }

.btn-sm { padding: 6px 12px; font-size: 12px; }
.btn-block { display: flex; width: 100%; }

.btn-microsoft {
  background: #fff;
  color: #2c2c2c;
  border: 1px solid #d6cfc4;
  font-size: 16px;
  padding: 14px 20px;
}
.btn-microsoft:hover { background: #f5f0e8; border-color: #b8b0a4; }

.btn-logout {
  background: transparent;
  color: #94a3b8;
  border: 1px solid #166534;
  width: 100%;
  margin-top: 8px;
}
.btn-logout:hover { color: #fff; border-color: #94a3b8; }

/* ---- Sidebar ---- */
.sidebar {
  width: 260px;
  background: #14532d;
  color: #fff;
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 60px;
  left: 0;
  bottom: 0;
  z-index: 100;
  transition: width 0.3s ease;
  overflow: hidden;
  border-right: 1px solid #0f3d20;
}

.sidebar-toggle {
  background: none;
  border: none;
  border-bottom: 1px solid #1a6b3a;
  color: #7fba9a;
  font-size: 16px;
  cursor: pointer;
  padding: 14px 0;
  text-align: left;
  padding-left: 21px;
  width: 100%;
  flex-shrink: 0;
  transition: all 0.15s;
}
.sidebar-toggle:hover {
  color: #fff;
  background: #1a6b3a;
}

.menu-icon {
  display: inline-block;
  width: 24px;
  text-align: center;
  font-size: 14px;
  flex-shrink: 0;
  opacity: 0.7;
}

.menu-text {
  transition: opacity 0.2s ease;
  font-size: 13px;
  letter-spacing: 0.3px;
  text-transform: uppercase;
}

.sidebar-menu {
  list-style: none;
  padding: 16px 0;
  flex: 1;
}

.sidebar-menu li a {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 18px;
  color: #a3c4b0;
  transition: all 0.15s;
  white-space: nowrap;
  border-left: 3px solid transparent;
  text-decoration: none;
}

.sidebar-menu li a:hover {
  background: #1a6b3a;
  color: #fff;
  text-decoration: none;
  border-left-color: #7fba9a;
}

.sidebar-menu li a:hover .menu-icon {
  opacity: 1;
}

.sidebar-menu li.active a {
  background: none;
  color: #fff;
  border-left-color: #4ade80;
  font-weight: 600;
}

.sidebar-menu li.active a .menu-icon {
  opacity: 1;
}

/* ---- Sidebar Pre-collapsed ---- */
.sidebar-pre-collapsed .sidebar {
  width: 60px;
  transition: none;
}
.sidebar-pre-collapsed .main-content {
  margin-left: 60px;
  transition: none;
}
.sidebar-pre-collapsed .sidebar .menu-text { opacity: 0; width: 0; overflow: hidden; }

/* ---- Sidebar Collapsed ---- */
.sidebar.collapsed { width: 60px; }
.sidebar.collapsed .menu-text { opacity: 0; width: 0; overflow: hidden; }
body.sidebar-collapsed .main-content { margin-left: 60px; }

/* ---- Main Content ---- */
.main-content {
  margin-left: 260px;
  padding: 84px 32px 24px;
  flex: 1;
  min-height: 100vh;
  transition: margin-left 0.3s ease;
}

.content-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
}

.content-header h1 {
  font-size: 22px;
  font-weight: 600;
  color: #14532d;
  text-transform: uppercase;
  letter-spacing: 1px;
}

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

/* ---- Corner Brackets ---- */
.card,
.stat-card,
.btn-secondary,
.input-bracket {
  position: relative;
}
.card::before,
.stat-card::before,
.btn-secondary::before,
.input-bracket::before,
.login-box::before {
  content: '';
  position: absolute;
  inset: -1px;
  pointer-events: none;
  background:
    linear-gradient(#b8b0a4, #b8b0a4) 0 0 / 6px 1px no-repeat,
    linear-gradient(#b8b0a4, #b8b0a4) 0 0 / 1px 6px no-repeat,
    linear-gradient(#b8b0a4, #b8b0a4) 100% 0 / 6px 1px no-repeat,
    linear-gradient(#b8b0a4, #b8b0a4) 100% 0 / 1px 6px no-repeat,
    linear-gradient(#b8b0a4, #b8b0a4) 0 100% / 6px 1px no-repeat,
    linear-gradient(#b8b0a4, #b8b0a4) 0 100% / 1px 6px no-repeat,
    linear-gradient(#b8b0a4, #b8b0a4) 100% 100% / 6px 1px no-repeat,
    linear-gradient(#b8b0a4, #b8b0a4) 100% 100% / 1px 6px no-repeat;
}

/* ---- Stats Grid ---- */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.stat-card {
  background: #fff;
  border-radius: 2px;
  padding: 20px;
  border: 1px solid #d6cfc4;
}


.stat-label {
  font-size: 11px;
  color: #8a8078;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.8px;
}

.stat-value {
  font-size: 26px;
  font-weight: 600;
  color: #14532d;
  margin-top: 6px;
  letter-spacing: -0.5px;
}

.stat-sub {
  font-size: 14px;
  color: #64748b;
  margin-top: 2px;
}

/* ---- Cards ---- */
.card {
  background: #fff;
  border-radius: 2px;
  border: 1px solid #d6cfc4;
  margin-bottom: 24px;
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid #d6cfc4;
}

.card-header h3 {
  font-size: 14px;
  font-weight: 600;
  color: #2c2c2c;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.card-body { padding: 20px; }

.content-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
}
.content-grid > * { min-width: 0; }

/* ---- Tables ---- */
.table-wrapper { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.table { width: 100%; border-collapse: collapse; }
.table th {
  text-align: left;
  padding: 10px 12px;
  font-size: 11px;
  font-weight: 600;
  color: #8a8078;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  border-bottom: 2px solid #d6cfc4;
  white-space: nowrap;
}
.table td {
  padding: 12px;
  font-size: 14px;
  border-bottom: 1px solid #d6cfc4;
  vertical-align: middle;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.table tr:hover td { background: #f5f0e8; }
.table-hover tbody tr { cursor: pointer; }

.text-center { text-align: center; }
.text-bold { font-weight: 700; }
.text-muted { color: #8a8078; font-size: 13px; }

.sortable { cursor: pointer; user-select: none; }
.sortable:hover { color: #16a34a; }
.sortable.asc::after { content: ' \2191'; }
.sortable.desc::after { content: ' \2193'; }

/* ---- Badges ---- */
.badge {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 2px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}
.badge-pendiente { background: #fef3c7; color: #92400e; }
.badge-liquidada { background: #d1fae5; color: #065f46; }
.badge-cancelada { background: #fee2e2; color: #991b1b; }
.badge-vencida { background: #fecaca; color: #7f1d1d; }

/* ---- Forms ---- */
.form-group { margin-bottom: 16px; }
.form-group label {
  display: block;
  font-size: 11px;
  font-weight: 600;
  color: #8a8078;
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.input,
.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid #d6cfc4;
  border-radius: 2px;
  font-size: 14px;
  font-family: inherit;
  letter-spacing: -0.01em;
  transition: border-color 0.2s;
  background: #fff;
}

.input:focus,
.form-group input:focus,
.form-group select:focus {
  outline: none;
  border-color: #14532d;
  box-shadow: none;
}

select.input { cursor: pointer; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-row .form-group { flex: 1; }
.checkbox-label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  cursor: pointer;
  white-space: nowrap;
}

/* ---- Filters Bar ---- */
.filters-bar {
  display: flex;
  gap: 12px;
  align-items: center;
  margin-bottom: 16px;
  flex-wrap: wrap;
}
.filters-bar .input { width: auto; min-width: 160px; }

/* ---- Totals Bar ---- */
.totals-bar {
  display: flex;
  gap: 24px;
  padding: 12px 20px;
  background: #fff;
  border-radius: 2px;
  border: 1px solid #d6cfc4;
  margin-bottom: 16px;
  font-size: 14px;
  position: relative;
}

/* ---- Pagination ---- */
.pagination {
  display: flex;
  justify-content: center;
  gap: 4px;
  margin-top: 16px;
  padding: 8px 0;
}
.pagination button {
  padding: 6px 12px;
  border: 1px solid #d6cfc4;
  background: #fff;
  border-radius: 2px;
  cursor: pointer;
  font-size: 13px;
}
.pagination button:hover { background: #f5f0e8; }
.pagination button.active { background: #16a34a; color: #fff; border-color: #16a34a; }
.pagination button:disabled { opacity: 0.5; cursor: default; }

/* ---- Modals ---- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  display: none;
  justify-content: center;
  align-items: center;
  z-index: 300;
}
.modal-overlay.open { display: flex; }
.modal {
  background: #fff;
  border-radius: 2px;
  width: 90%;
  max-width: 560px;
  max-height: 80vh;
  overflow-y: auto;
  border: 1px solid #d6cfc4;
  font-family: inherit;
}
.modal-lg { max-width: 760px; }
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid #d6cfc4;
}
.modal-header h3 {
  font-size: 13px;
  font-family: inherit;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-weight: 600;
  color: #2c2c2c;
}
.modal-close {
  background: none;
  border: none;
  font-size: 24px;
  cursor: pointer;
  color: #94a3b8;
  line-height: 1;
}
.modal-close:hover { color: #475569; }
.modal-body { padding: 20px; }
.modal-actions { display: flex; gap: 12px; justify-content: flex-end; margin-top: 16px; }

/* ---- Detail Grid ---- */
.detail-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
.detail-item label { font-size: 11px; color: #8a8078; display: block; text-transform: uppercase; letter-spacing: 0.5px; }
.detail-item span { font-size: 14px; font-weight: 500; }

/* ---- Inline Form ---- */
.inline-form {
  background: #f8f5ef;
  border-radius: 2px;
  padding: 16px;
  margin-top: 16px;
  border: 1px solid #d6cfc4;
}
.inline-form h4 { font-size: 14px; color: #14532d; margin-bottom: 12px; }

/* ---- Import Log ---- */
.import-log {
  background: #1e293b;
  color: #e2e8f0;
  padding: 16px;
  border-radius: 2px;
  font-size: 12px;
  max-height: 300px;
  overflow-y: auto;
  white-space: pre-wrap;
}

/* ---- Responsive ---- */
@media (max-width: 1200px) {
  .content-grid { grid-template-columns: 1fr; gap: 16px; }
}

@media (max-width: 768px) {
  .sidebar { width: 60px; }
  .sidebar .menu-text { opacity: 0; width: 0; overflow: hidden; }
  .main-content { margin-left: 60px; padding: 76px 16px 16px; }
  .topbar-brand { display: none; }
  .topbar-user-info { padding: 0 12px; }
  .topbar-logout { padding: 0 12px; }
  .filters-bar { flex-direction: column; }
  .filters-bar .input { width: 100%; min-width: 0; }
  .form-row { grid-template-columns: 1fr; }
  .totals-bar { flex-direction: column; gap: 8px; }
  .stats-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
  .stat-card { padding: 14px; }
  .stat-label { font-size: 11px; }
  .stat-value { font-size: 20px; }
  .stat-sub { font-size: 12px; }
  .detail-grid { grid-template-columns: 1fr; }
  .content-header { flex-direction: column; align-items: flex-start; gap: 10px; }
  .content-header h1 { font-size: 20px; }
  .card-header { padding: 12px 16px; }
  .card-body { padding: 12px; }
  .table th { padding: 8px 10px; }
  .table td { padding: 10px; font-size: 13px; }
}

@media (max-width: 480px) {
  .stats-grid { grid-template-columns: 1fr; }
}
