/* 
   Pimentel AI - Gestão de Negócios 
   Premium Dark Theme CSS 
*/

@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;500;600;700;800&family=Plus+Jakarta+Sans:wght@300;400;500;600;700&display=swap');

:root {
  /* Color Palette */
  --bg-primary: #070a13;
  --bg-secondary: #0d1322;
  --bg-tertiary: #151d30;
  --card-bg: rgba(21, 29, 48, 0.7);
  --card-border: rgba(34, 45, 68, 0.6);
  --card-border-hover: rgba(16, 185, 129, 0.4);
  
  --text-primary: #f3f4f6;
  --text-secondary: #9ca3af;
  --text-muted: #6b7280;
  
  /* Accent Colors */
  --color-success: #10b981;
  --color-success-rgb: 16, 185, 129;
  --color-danger: #ef4444;
  --color-danger-rgb: 239, 68, 68;
  --color-warning: #f59e0b;
  --color-warning-rgb: 245, 158, 11;
  --color-info: #6366f1;
  --color-info-rgb: 99, 102, 241;
  
  /* Fonts */
  --font-heading: 'Outfit', sans-serif;
  --font-body: 'Plus Jakarta Sans', sans-serif;
  
  /* Shadows & Radius */
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 16px 40px rgba(0, 0, 0, 0.6);
  --shadow-glow: 0 0 15px rgba(16, 185, 129, 0.15);
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 24px;
}

/* Reset */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  font-family: var(--font-body);
  -webkit-tap-highlight-color: transparent;
}

body {
  background-color: var(--bg-primary);
  color: var(--text-primary);
  height: 100vh;
  overflow: hidden;
  line-height: 1.5;
}

/* Scrollbar Customization */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}
::-webkit-scrollbar-track {
  background: var(--bg-primary);
}
::-webkit-scrollbar-thumb {
  background: var(--bg-tertiary);
  border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
  background: var(--text-muted);
}

/* Layout Framework */
#app-layout {
  display: flex;
  width: 100%;
  height: 100vh;
  overflow: hidden;
}

/* Sidebar Navigation */
aside.sidebar {
  width: 240px;
  background-color: var(--bg-secondary);
  border-right: 1px solid var(--card-border);
  display: flex;
  flex-direction: column;
  height: 100vh;
  position: fixed;
  left: 0;
  top: 0;
  z-index: 100;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.sidebar-header {
  padding: 16px 20px;
  display: flex;
  align-items: center;
  gap: 12px;
  border-bottom: 1px solid var(--card-border);
}

.sidebar-logo {
  width: 32px;
  height: 32px;
  filter: drop-shadow(0 0 8px rgba(16, 185, 129, 0.3));
}

.sidebar-title {
  font-family: var(--font-heading);
  font-size: 1.05rem;
  font-weight: 700;
  background: linear-gradient(135deg, var(--color-success) 0%, var(--color-info) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  letter-spacing: 0.5px;
}

.sidebar-menu {
  flex: 1;
  padding: 12px 12px;
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 4px;
  overflow-y: auto;
}

.sidebar-item a {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 9px 14px;
  color: var(--text-secondary);
  text-decoration: none;
  border-radius: var(--radius-md);
  font-weight: 500;
  font-size: 0.95rem;
  transition: all 0.2s ease;
  cursor: pointer;
}

.sidebar-item a:hover {
  background-color: rgba(255, 255, 255, 0.03);
  color: var(--text-primary);
}

.sidebar-item.active a {
  background: linear-gradient(135deg, rgba(16, 185, 129, 0.15) 0%, rgba(99, 102, 241, 0.05) 100%);
  color: var(--color-success);
  border-left: 3px solid var(--color-success);
  font-weight: 600;
}

.sidebar-footer {
  padding: 14px 16px;
  border-top: 1px solid var(--card-border);
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.user-profile {
  display: flex;
  align-items: center;
  gap: 12px;
}

.user-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--color-info) 0%, var(--color-success) 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  color: var(--text-primary);
  font-size: 0.9rem;
}

.user-info {
  display: flex;
  flex-direction: column;
}

.user-name {
  font-size: 0.9rem;
  font-weight: 600;
}

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

/* Main Content Area */
main.main-content {
  margin-left: 240px;
  flex: 1;
  height: 100vh;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 24px 28px;
  display: flex;
  flex-direction: column;
  gap: 20px;
  transition: all 0.3s ease;
  scrollbar-gutter: stable;
}

/* Header Action Bar */
.page-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 20px;
  flex-wrap: wrap;
}

.page-title-area {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.page-title {
  font-family: var(--font-heading);
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.5px;
}

.page-subtitle {
  font-size: 0.9rem;
  color: var(--text-secondary);
}

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

/* Dashboard Cards (Módulo 8 & 5) */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 20px;
}

.kpi-card {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-lg);
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  position: relative;
  overflow: hidden;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: var(--shadow-sm);
  backdrop-filter: blur(12px);
}

.kpi-card:hover {
  transform: translateY(-4px);
  border-color: var(--card-border-hover);
  box-shadow: var(--shadow-glow), var(--shadow-md);
}

.kpi-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 4px;
  height: 100%;
  background: var(--accent-color, var(--color-info));
}

.kpi-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.kpi-title {
  font-size: 0.85rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-secondary);
}

.kpi-icon {
  width: 24px;
  height: 24px;
  color: var(--accent-color, var(--color-info));
  opacity: 0.8;
}

.kpi-value {
  font-family: var(--font-heading);
  font-size: 1.45rem;
  font-weight: 700;
  color: var(--text-primary);
  margin: 4px 0;
}

.kpi-footer {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.8rem;
  color: var(--text-secondary);
}

.trend-indicator {
  display: flex;
  align-items: center;
  gap: 4px;
  font-weight: 600;
}

.trend-up {
  color: var(--color-success);
}

.trend-down {
  color: var(--color-danger);
}

/* Section Components */
.dashboard-row {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 16px;
}

@media (max-width: 1024px) {
  .dashboard-row {
    grid-template-columns: 1fr;
  }
}

.card {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-lg);
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  box-shadow: var(--shadow-md);
  backdrop-filter: blur(12px);
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
}

.card-title {
  font-family: var(--font-heading);
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--text-primary);
}

/* Custom SVGs and Graphs styling */
.chart-container {
  position: relative;
  width: 100%;
  height: 300px;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  padding-top: 20px;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 18px;
  border-radius: var(--radius-md);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  text-decoration: none;
  border: 1px solid transparent;
}

.btn-primary {
  background-color: var(--color-success);
  color: #070a13;
}
.btn-primary:hover {
  background-color: #0d9668;
  box-shadow: 0 0 12px rgba(16, 185, 129, 0.4);
}

.btn-secondary {
  background-color: transparent;
  border-color: var(--card-border);
  color: var(--text-primary);
}
.btn-secondary:hover {
  background-color: rgba(255, 255, 255, 0.05);
  border-color: var(--text-secondary);
}

.btn-info {
  background-color: var(--color-info);
  color: #fff;
}
.btn-info:hover {
  background-color: #4f46e5;
  box-shadow: 0 0 12px rgba(99, 102, 241, 0.4);
}

.btn-danger {
  background-color: var(--color-danger);
  color: #fff;
}
.btn-danger:hover {
  background-color: #dc2626;
  box-shadow: 0 0 12px rgba(239, 68, 68, 0.4);
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Form Styles */
.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.form-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px;
}

label {
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-secondary);
}

input, select, textarea {
  background-color: var(--bg-secondary);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-md);
  padding: 10px 14px;
  color: var(--text-primary);
  font-size: 0.9rem;
  transition: all 0.2s ease;
  outline: none;
}

input:focus, select:focus, textarea:focus {
  border-color: var(--color-success);
  box-shadow: 0 0 8px rgba(16, 185, 129, 0.2);
}

input::placeholder, textarea::placeholder {
  color: var(--text-muted);
}

select {
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%239ca3af'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M19 9l-7 7-7-7'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  background-size: 16px;
  padding-right: 40px;
}

/* Tables */
.table-wrapper {
  overflow-x: auto;
  border-radius: var(--radius-md);
  border: 1px solid var(--card-border);
}

table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 0.9rem;
}

th {
  background-color: var(--bg-secondary);
  color: var(--text-secondary);
  font-weight: 600;
  padding: 14px 18px;
  border-bottom: 1px solid var(--card-border);
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

td {
  padding: 14px 18px;
  border-bottom: 1px solid var(--card-border);
  color: var(--text-primary);
}

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

tr:hover td {
  background-color: rgba(255, 255, 255, 0.01);
}

/* Badges */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 4px 8px;
  border-radius: 9999px;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.badge-success {
  background-color: rgba(16, 185, 129, 0.15);
  color: var(--color-success);
}

.badge-danger {
  background-color: rgba(239, 68, 68, 0.15);
  color: var(--color-danger);
}

.badge-warning {
  background-color: rgba(245, 158, 11, 0.15);
  color: var(--color-warning);
}

.badge-info {
  background-color: rgba(99, 102, 241, 0.15);
  color: var(--color-info);
}

/* Modals */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background-color: rgba(7, 10, 19, 0.85);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

.modal-overlay.active {
  opacity: 1;
  pointer-events: auto;
}

.modal-content {
  background: var(--bg-secondary);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 600px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-lg);
  transform: translateY(20px) scale(0.95);
  transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
  overflow: hidden;
}

.modal-overlay.active .modal-content {
  transform: translateY(0) scale(1);
}

.modal-header {
  padding: 20px 24px;
  border-bottom: 1px solid var(--card-border);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.modal-title {
  font-family: var(--font-heading);
  font-size: 1.25rem;
  font-weight: 700;
}

.modal-close {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  font-size: 1.5rem;
  cursor: pointer;
  line-height: 1;
}

.modal-close:hover {
  color: var(--text-primary);
}

.modal-body {
  padding: 24px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.modal-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--card-border);
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  background-color: var(--bg-primary);
}

/* Animations */
@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes slideUp {
  from { transform: translateY(16px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

.fade-in {
  animation: fadeIn 0.3s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

.slide-up {
  animation: slideUp 0.4s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

/* Progress bars for Goals */
.progress-bar-container {
  width: 100%;
  height: 8px;
  background-color: var(--bg-tertiary);
  border-radius: 9999px;
  overflow: hidden;
  position: relative;
}

.progress-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--color-info) 0%, var(--color-success) 100%);
  border-radius: 9999px;
  transition: width 0.8s cubic-bezier(0.4, 0, 0.2, 1);
  width: 0%;
}

/* Mobile Responsiveness */
@media (max-width: 768px) {
  aside.sidebar {
    width: 100%;
    height: 60px;
    top: auto;
    bottom: 0;
    border-right: none;
    border-top: 1px solid var(--card-border);
  }
  
  .sidebar-header {
    display: none; /* Hide header on mobile view */
  }
  
  .sidebar-menu {
    flex-direction: row;
    justify-content: space-around;
    padding: 0;
    gap: 0;
  }
  
  .sidebar-item a {
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 8px 4px;
    font-size: 0.65rem;
    border-radius: 0;
  }

  .sidebar-item a svg {
    width: 20px;
    height: 20px;
  }
  
  .sidebar-item.active a {
    border-left: none;
    border-bottom: 3px solid var(--color-success);
    background: transparent;
  }

  .sidebar-footer {
    display: none; /* Hide profile footer in bottom bar */
  }
  
  main.main-content {
    margin-left: 0;
    padding: 16px;
    padding-bottom: 80px; /* Space for the bottom nav */
    gap: 20px;
  }
  
  .page-title {
    font-size: 1.5rem;
  }

  .modal-content {
    max-height: 100%;
    height: 100%;
    border-radius: 0;
    max-width: 100%;
  }
}

/* Print Overrides for PDF generation (Módulo 9) */
@media print {
  body {
    background: #fff !important;
    color: #000 !important;
  }
  aside.sidebar, .page-actions, .btn, .modal-overlay {
    display: none !important;
  }
  main.main-content {
    margin-left: 0 !important;
    padding: 0 !important;
  }
  .card {
    background: transparent !important;
    border: none !important;
    box-shadow: none !important;
    padding: 0 !important;
  }
  table {
    border: 1px solid #ddd !important;
  }
  th {
    background-color: #f5f5f5 !important;
    color: #000 !important;
  }
  td, th {
    border-bottom: 1px solid #ddd !important;
  }
}

/* ─── Tooltip ⓘ ─────────────────────────────────────────────────── */
.tooltip-trigger {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: rgba(99, 102, 241, 0.15);
  color: var(--color-info);
  font-size: 0.65rem;
  font-weight: 700;
  cursor: help;
  position: relative;
  vertical-align: middle;
  margin-left: 4px;
  user-select: none;
  transition: background 0.2s;
}
.tooltip-trigger:hover {
  background: rgba(99, 102, 241, 0.3);
}
.tooltip-trigger::after {
  content: attr(title);
  position: absolute;
  bottom: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%);
  background: rgba(13, 19, 34, 0.97);
  border: 1px solid var(--card-border-hover);
  color: var(--text-primary);
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  font-size: 0.75rem;
  font-weight: 400;
  white-space: normal;
  width: max-content;
  max-width: 220px;
  text-align: center;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.2s;
  z-index: 1000;
  line-height: 1.4;
  box-shadow: var(--shadow-md);
}
.tooltip-trigger:hover::after {
  opacity: 1;
}

/* ─── Alert Bell button in sidebar-header ─────────────────────────── */
#alert-bell-btn {
  flex-shrink: 0;
}
#alert-bell-btn:hover svg {
  stroke: var(--color-warning);
}
#alert-bell-badge {
  transition: background 0.3s;
}

/* ─── Keyboard shortcut hint ─────────────────────────────────────── */
.sidebar-item a::after {
  content: attr(data-shortcut);
  display: inline-flex;
  font-size: 0.6rem;
  background: rgba(255,255,255,0.06);
  border: 1px solid var(--card-border);
  border-radius: 4px;
  padding: 1px 5px;
  margin-left: auto;
  color: var(--text-muted);
  font-family: monospace;
  opacity: 0;
  transition: opacity 0.2s;
}
.sidebar-item:hover a::after,
.sidebar:hover .sidebar-item a::after {
  opacity: 1;
}

/* ─── Action item hover ───────────────────────────────────────────── */
.action-item:hover {
  opacity: 0.85;
  transform: translateX(2px);
  transition: all 0.15s ease;
}

/* ─── Enhanced Mobile Responsiveness ──────────────────────────── */
@media (max-width: 768px) {
  .page-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
  }

  .page-actions {
    width: 100%;
    flex-wrap: wrap;
    gap: 8px;
  }

  .page-actions .btn,
  .page-actions button {
    flex: 1 1 auto;
    min-height: 44px;
    font-size: 0.85rem;
    justify-content: center;
  }

  .kpi-grid {
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 12px;
  }

  .kpi-value {
    font-size: 1.4rem;
  }

  .card {
    padding: 16px;
    gap: 14px;
  }

  table {
    font-size: 0.8rem;
  }

  th, td {
    padding: 8px 10px;
  }

  .btn {
    min-height: 40px;
  }

  /* Tab toggle buttons row - wrap on mobile */
  .page-actions > div[style*="inline-flex"] {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  .btn-tab {
    font-size: 0.75rem !important;
    padding: 6px 10px !important;
    white-space: nowrap;
  }

  /* Form groups full width on mobile */
  .form-group {
    width: 100%;
  }

  /* Dashboard row already 1-col at 1024px, ensure it on mobile too */
  .dashboard-row {
    grid-template-columns: 1fr !important;
    gap: 16px;
  }

  /* Sidebar icon labels - shorter */
  .sidebar-item a span {
    display: none;
  }

  /* POS table action column */
  .table-wrapper {
    -webkit-overflow-scrolling: touch;
  }

  /* Modal full height on mobile */
  .modal-overlay {
    align-items: flex-end;
  }

  .modal-content {
    max-height: 90vh;
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  }

  /* Page subtitle smaller */
  .page-subtitle {
    font-size: 0.82rem;
  }

  /* Raio-X and breakdown grids */
  [style*="grid-template-columns: 1fr 1fr"] {
    grid-template-columns: 1fr !important;
  }

  /* Reduce filter rows in reports */
  [style*="display:flex; gap:16px; flex-wrap:wrap"] {
    flex-direction: column;
  }
}

/* Very small screens (< 400px) */
@media (max-width: 400px) {
  .kpi-grid {
    grid-template-columns: 1fr 1fr;
  }

  .kpi-value {
    font-size: 1.1rem;
  }

  .sidebar-item a {
    padding: 8px 2px;
  }
}