/* =========================================
   Portal Proveedores — Main Stylesheet
   ========================================= */

:root {
  --color-primary: #1a56db;
  --color-secondary: #7e3af2;
  --color-bg: #f3f4f6;
  --color-sidebar: #1e2537;

  --color-success: #059669;
  --color-danger: #dc2626;
  --color-warning: #d97706;

  --text: #111827;
  --text-muted: #6b7280;
  --border: #e5e7eb;
  --card-bg: #ffffff;
  --sidebar-width: 260px;
  --radius: 10px;
  --shadow: 0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.04);
  --shadow-md: 0 4px 12px rgba(0,0,0,.10);
}

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

html { font-size: 15px; }

body {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  color: var(--text);
  background: var(--color-bg);
  line-height: 1.5;
}

a { color: var(--color-primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* =========================================
   AUTH PAGES
   ========================================= */
.auth-page { background: var(--color-bg); min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px; }

.auth-container { width: 100%; max-width: 440px; }
.auth-container-wide { max-width: 680px; }

.auth-card {
  background: var(--card-bg);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  padding: 40px;
}

.auth-header { text-align: center; margin-bottom: 28px; }
.auth-logo { height: 52px; object-fit: contain; margin-bottom: 12px; }
.auth-title { font-size: 22px; font-weight: 700; color: var(--text); margin-bottom: 4px; }
.auth-subtitle { color: var(--text-muted); font-size: 14px; }

.auth-links { text-align: center; margin-top: 20px; font-size: 14px; color: var(--text-muted); }
.auth-links .separator { margin: 0 8px; }

/* =========================================
   APP LAYOUT (sidebar + content)
   ========================================= */
.app-page { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar-width);
  min-width: var(--sidebar-width);
  background: var(--color-sidebar);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0;
  height: 100vh;
  overflow-y: auto;
  z-index: 100;
}

.sidebar-header {
  padding: 24px 20px 20px;
  border-bottom: 1px solid rgba(255,255,255,.08);
}
.sidebar-logo { max-height: 44px; max-width: 160px; object-fit: contain; }
.sidebar-brand { color: #fff; font-size: 17px; font-weight: 700; letter-spacing: -.3px; }
.sidebar-role { color: rgba(255,255,255,.45); font-size: 11px; text-transform: uppercase; letter-spacing: .7px; margin-top: 4px; }

.sidebar-nav { flex: 1; padding: 12px 12px; }
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px;
  border-radius: 7px;
  color: rgba(255,255,255,.65);
  font-size: 14px;
  font-weight: 500;
  text-decoration: none;
  transition: all .15s;
  margin-bottom: 2px;
}
.nav-item:hover { background: rgba(255,255,255,.08); color: #fff; text-decoration: none; }
.nav-item.active { background: var(--color-primary); color: #fff; }

.nav-divider { border-top: 1px solid rgba(255,255,255,.08); margin: 8px 0; }

.sidebar-user-info {
  padding: 12px 20px;
  border-top: 1px solid rgba(255,255,255,.08);
}
.sidebar-user-name { color: rgba(255,255,255,.85); font-size: 13px; font-weight: 600; }
.sidebar-user-email { color: rgba(255,255,255,.45); font-size: 12px; }

.sidebar-footer { padding: 12px; border-top: 1px solid rgba(255,255,255,.08); }
.btn-logout {
  width: 100%;
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px;
  border-radius: 7px;
  background: none; border: none; cursor: pointer;
  color: rgba(255,255,255,.5); font-size: 14px; font-weight: 500;
  transition: all .15s;
}
.btn-logout:hover { background: rgba(255,255,255,.08); color: #fff; }

.main-content {
  margin-left: var(--sidebar-width);
  flex: 1;
  padding: 32px;
  max-width: 1200px;
}

/* =========================================
   PAGE HEADER
   ========================================= */
.page-header {
  display: flex; align-items: flex-start; justify-content: space-between;
  margin-bottom: 24px; flex-wrap: wrap; gap: 12px;
}
.page-title { font-size: 24px; font-weight: 700; color: var(--text); line-height: 1.2; }
.page-subtitle { color: var(--text-muted); font-size: 14px; margin-top: 4px; }

/* =========================================
   CARDS
   ========================================= */
.card {
  background: var(--card-bg);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
  margin-bottom: 24px;
  overflow: hidden;
}
.card-header {
  padding: 16px 24px;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
}
.card-title { font-size: 15px; font-weight: 600; color: var(--text); }
.card-body { padding: 24px; }

.two-col-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; }
@media (max-width: 900px) { .two-col-grid { grid-template-columns: 1fr; } }

/* =========================================
   STATS GRID
   ========================================= */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 16px; margin-bottom: 24px; }
.stat-card {
  background: var(--card-bg); border-radius: var(--radius); box-shadow: var(--shadow);
  border: 1px solid var(--border); padding: 20px;
  display: flex; align-items: center; gap: 16px;
}
.stat-icon { width: 52px; height: 52px; border-radius: 12px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.stat-value { font-size: 28px; font-weight: 700; line-height: 1; }
.stat-label { font-size: 13px; color: var(--text-muted); margin-top: 4px; }

/* =========================================
   TABLE
   ========================================= */
.table { width: 100%; border-collapse: collapse; }
.table th {
  text-align: left; padding: 10px 16px;
  font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .5px;
  color: var(--text-muted); background: #f9fafb; border-bottom: 1px solid var(--border);
}
.table td { padding: 12px 16px; border-bottom: 1px solid var(--border); font-size: 14px; vertical-align: middle; }
.table tr:last-child td { border-bottom: none; }
.table tr:hover td { background: #fafafa; }
.table-invoices { margin: 0 0 0 8px; width: calc(100% - 8px); }

.row-inactive td { opacity: .55; }
.text-truncate { max-width: 200px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.text-strong { font-weight: 600; }
.text-muted { color: var(--text-muted); }
.text-sm { font-size: 13px; }
.actions-cell { white-space: nowrap; text-align: right; }

/* =========================================
   FOLDER TREE
   ========================================= */
.folder-year { border-bottom: 1px solid var(--border); }
.folder-year:last-child { border-bottom: none; }
.folder-toggle {
  width: 100%; text-align: left; background: none; border: none; cursor: pointer;
  display: flex; align-items: center; gap: 10px;
  padding: 14px 20px; font-weight: 600; font-size: 15px; color: var(--text);
  transition: background .1s;
}
.folder-toggle:hover { background: #f9fafb; }
.folder-toggle-month { font-size: 14px; font-weight: 500; padding: 10px 20px 10px 36px; }
.folder-icon { color: #f59e0b; }
.chevron { margin-left: auto; color: var(--text-muted); transition: transform .2s; }
.folder-content { padding: 0 0 8px 0; }
.folder-month { border-top: 1px solid #f3f4f6; }
.folder-month .folder-content { padding: 0 0 12px 0; }

/* =========================================
   FILE NAME / BADGES
   ========================================= */
.file-name { display: flex; align-items: center; gap: 8px; font-size: 13px; }
.file-badge {
  display: inline-block; padding: 2px 7px; border-radius: 4px;
  font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: .5px; flex-shrink: 0;
}
.file-pdf { background: #fee2e2; color: #b91c1c; }
.file-img { background: #dbeafe; color: #1e40af; }

/* =========================================
   BADGES
   ========================================= */
.badge {
  display: inline-block; padding: 2px 10px; border-radius: 999px;
  font-size: 11px; font-weight: 600;
  background: #f3f4f6; color: var(--text-muted);
}
.badge-green { background: #d1fae5; color: #065f46; }
.badge-red { background: #fee2e2; color: #b91c1c; }
.badge-yellow { background: #fef3c7; color: #92400e; }
.badge-blue { background: #dbeafe; color: #1e40af; }

/* =========================================
   FORMS
   ========================================= */
.form-group { margin-bottom: 16px; }
.form-row { display: flex; gap: 16px; }
.form-row .form-group { flex: 1; min-width: 0; }
.form-label { display: block; font-size: 13px; font-weight: 600; color: var(--text); margin-bottom: 6px; }
.form-input {
  width: 100%; padding: 9px 12px;
  border: 1px solid var(--border); border-radius: 7px;
  font-size: 14px; color: var(--text); background: #fff;
  transition: border-color .15s, box-shadow .15s;
  font-family: inherit;
}
.form-input:focus { outline: none; border-color: var(--color-primary); box-shadow: 0 0 0 3px rgba(26,86,219,.12); }
.form-input:disabled { background: #f9fafb; color: var(--text-muted); }
.form-hint { display: block; font-size: 12px; color: var(--text-muted); margin-top: 5px; }
.form-section-title { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .7px; color: var(--text-muted); margin: 20px 0 12px; padding-bottom: 8px; border-bottom: 1px solid var(--border); }
.checkbox-label { display: flex; align-items: center; gap: 8px; font-size: 14px; cursor: pointer; }
.required { color: var(--color-danger); }

/* Color pickers */
.color-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.color-input-wrap { display: flex; align-items: center; gap: 8px; }
.color-picker { width: 40px; height: 36px; padding: 2px; border: 1px solid var(--border); border-radius: 6px; cursor: pointer; background: none; }
.color-text { flex: 1; }

/* Search */
.search-form { display: flex; gap: 10px; flex-wrap: wrap; }
.search-input { min-width: 260px; flex: 1; }

/* Upload zone */
.upload-zone {
  border: 2px dashed var(--border); border-radius: var(--radius);
  padding: 32px 24px; text-align: center; transition: border-color .2s, background .2s;
  cursor: pointer;
}
.upload-zone:hover, .upload-zone.drag-over { border-color: var(--color-primary); background: rgba(26,86,219,.03); }
.upload-zone-text { font-size: 14px; color: var(--text-muted); margin-bottom: 4px; }
.file-list { margin-top: 16px; text-align: left; }
.file-list-item { display: flex; align-items: center; gap: 8px; padding: 8px; border-radius: 6px; background: #f9fafb; border: 1px solid var(--border); margin-top: 6px; font-size: 13px; }

/* =========================================
   BUTTONS
   ========================================= */
.btn-primary, .btn-secondary, .btn-icon {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 9px 18px; border-radius: 7px;
  font-size: 14px; font-weight: 600; cursor: pointer; border: none;
  transition: all .15s; text-decoration: none; font-family: inherit;
}
.btn-primary { background: var(--color-primary); color: #fff; }
.btn-primary:hover { filter: brightness(1.1); color: #fff; text-decoration: none; }
.btn-secondary { background: #f3f4f6; color: var(--text); border: 1px solid var(--border); }
.btn-secondary:hover { background: #e5e7eb; text-decoration: none; }
.btn-block { width: 100%; justify-content: center; padding: 12px; }
.btn-link { font-size: 14px; color: var(--color-primary); background: none; border: none; cursor: pointer; padding: 0; }
.btn-link:hover { text-decoration: underline; }
.btn-link-inline { background: none; border: none; color: var(--color-primary); cursor: pointer; font-size: inherit; padding: 0; font-family: inherit; }

.btn-icon {
  padding: 6px; width: 32px; height: 32px; justify-content: center;
  background: #f3f4f6; border: 1px solid var(--border); color: var(--text-muted); border-radius: 6px;
}
.btn-icon:hover { background: #e5e7eb; text-decoration: none; }
.btn-danger { color: var(--color-danger) !important; }
.btn-danger:hover { background: #fee2e2 !important; border-color: #fca5a5 !important; }
.btn-success { color: var(--color-success) !important; }
.btn-success:hover { background: #d1fae5 !important; border-color: #6ee7b7 !important; }

/* =========================================
   FLASH MESSAGES
   ========================================= */
.flash {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 16px; border-radius: 8px; margin-bottom: 16px; font-size: 14px;
}
.flash-success { background: #d1fae5; color: #065f46; border: 1px solid #6ee7b7; }
.flash-error { background: #fee2e2; color: #b91c1c; border: 1px solid #fca5a5; }

/* =========================================
   INFO GRID (supplier detail)
   ========================================= */
.info-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 0;
  padding: 0;
}
.info-item { padding: 16px 24px; border-bottom: 1px solid var(--border); border-right: 1px solid var(--border); }
.info-item:nth-child(even):last-child, .info-item:last-child { border-right: none; }
.info-label { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .5px; color: var(--text-muted); margin-bottom: 4px; }
.info-value { font-size: 14px; font-weight: 500; color: var(--text); }

/* =========================================
   LOGO PREVIEW
   ========================================= */
.logo-preview { background: #f9fafb; border: 1px solid var(--border); border-radius: 8px; padding: 20px; text-align: center; margin-bottom: 12px; }
.logo-preview img { max-height: 80px; max-width: 200px; object-fit: contain; }
.logo-placeholder { background: #f9fafb; border: 1px dashed var(--border); border-radius: 8px; padding: 24px; text-align: center; color: var(--text-muted); font-size: 14px; margin-bottom: 16px; }

/* =========================================
   SMTP GUIDE
   ========================================= */
.smtp-guide h4 { font-size: 14px; font-weight: 700; margin: 16px 0 8px; color: var(--text); }
.smtp-guide h4:first-child { margin-top: 0; }
.smtp-guide ul { padding-left: 18px; list-style: disc; }
.smtp-guide li { font-size: 13px; color: var(--text-muted); margin-bottom: 4px; line-height: 1.6; }
.smtp-guide code { background: #f3f4f6; padding: 1px 6px; border-radius: 4px; font-family: monospace; font-size: 12px; color: var(--text); }
.info-box { background: #eff6ff; border: 1px solid #bfdbfe; border-radius: 8px; padding: 12px 16px; font-size: 13px; color: #1e40af; margin-top: 16px; }

/* =========================================
   EMPTY STATE
   ========================================= */
.empty-state {
  padding: 48px 24px; text-align: center; color: var(--text-muted); font-size: 14px;
  display: flex; flex-direction: column; align-items: center;
}

/* =========================================
   RESPONSIVE
   ========================================= */
@media (max-width: 768px) {
  .sidebar { display: none; }
  .main-content { margin-left: 0; padding: 16px; }
  .form-row { flex-direction: column; gap: 0; }
  .auth-card { padding: 28px 20px; }
  .color-grid { grid-template-columns: 1fr; }
}

/* =========================================
   ACCENT BAR (colores institucionales)
   ========================================= */
.sidebar-accent-bar {
  display: flex; gap: 5px; margin-top: 10px;
}
.sidebar-accent-bar span {
  height: 4px; flex: 1; border-radius: 3px;
}

.auth-accent-bar {
  display: flex; gap: 6px; justify-content: center; margin-top: 12px;
}
.auth-accent-bar span {
  height: 4px; width: 36px; border-radius: 3px;
}

.auth-brand-name {
  font-size: 24px; font-weight: 800; color: var(--text); letter-spacing: -.5px;
}
