/* 
   Wine CRM Premium Styling
   Curated HSL Colors, Dark Luxe Theme, Glassmorphism, Micro-animations.
   Technical comments and properties in English.
*/

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

:root {
  /* HSL Color Palette */
  --bg-main: hsl(350, 25%, 8%);
  --bg-card: rgba(35, 18, 22, 0.65);
  --bg-sidebar: hsl(350, 25%, 5%);
  --border-glass: rgba(212, 175, 55, 0.15);
  --border-focus: hsl(45, 68%, 53%);
  
  --primary: hsl(353, 67%, 21%); /* Burgundy */
  --primary-light: hsl(353, 67%, 32%);
  --accent: hsl(45, 68%, 53%); /* Gold */
  --accent-hover: hsl(45, 68%, 63%);
  
  --text-primary: hsl(36, 33%, 97%); /* Soft Cream */
  --text-muted: hsl(0, 0%, 75%);
  
  --success: hsl(145, 63%, 42%);
  --warning: hsl(35, 90%, 55%);
  --danger: hsl(355, 75%, 47%);
  
  --font-sans: 'Outfit', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --transition-smooth: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  --shadow-lg: 0 10px 30px -10px rgba(0, 0, 0, 0.7);
}

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

body {
  font-family: var(--font-sans);
  background-color: var(--bg-main);
  background-image: 
    radial-gradient(at 10% 20%, rgba(88, 17, 26, 0.15) 0px, transparent 50%),
    radial-gradient(at 90% 80%, rgba(212, 175, 55, 0.05) 0px, transparent 50%);
  background-attachment: fixed;
  color: var(--text-muted);
  min-height: 100vh;
  line-height: 1.6;
  overflow-x: hidden;
}

h1, h2, h3, h4, h5, h6 {
  color: var(--text-primary);
  font-weight: 600;
  letter-spacing: -0.02em;
}

/* Layout */
.app-container {
  display: flex;
  min-height: 100vh;
}

/* Sidebar Navigation (Desktop) */
.sidebar {
  width: 280px;
  background-color: var(--bg-sidebar);
  border-right: 1px solid var(--border-glass);
  padding: 2rem 1.5rem;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  position: fixed;
  height: 100vh;
  z-index: 100;
  transition: var(--transition-smooth);
}

.brand-logo {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 3rem;
  text-decoration: none;
}

.brand-logo img {
  width: 42px;
  height: 42px;
  border-radius: 8px;
  border: 1px solid var(--accent);
}

.brand-name {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text-primary);
  background: linear-gradient(135deg, var(--text-primary) 0%, var(--accent) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.nav-menu {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  flex-grow: 1;
}

.nav-item a {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.85rem 1rem;
  color: var(--text-muted);
  text-decoration: none;
  border-radius: 8px;
  font-weight: 500;
  transition: var(--transition-smooth);
  border: 1px solid transparent;
}

.nav-item a:hover, 
.nav-item.active a {
  color: var(--text-primary);
  background-color: rgba(255, 255, 255, 0.03);
  border-color: var(--border-glass);
  transform: translateX(4px);
}

.nav-item.active a {
  border-left: 3px solid var(--accent);
  background-color: rgba(88, 17, 26, 0.2);
}

.nav-icon {
  width: 20px;
  height: 20px;
  stroke: currentColor;
  fill: none;
  stroke-width: 2;
}

.user-profile {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border-glass);
}

.user-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background-color: var(--primary);
  border: 1px solid var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  color: var(--accent);
}

.user-info h4 {
  font-size: 0.9rem;
}

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

/* Main Content Area */
.main-content {
  flex-grow: 1;
  margin-left: 280px;
  padding: 2.5rem;
  transition: var(--transition-smooth);
}

/* Header */
.top-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 2.5rem;
}

.page-title h1 {
  font-size: 2rem;
  margin-bottom: 0.25rem;
}

.page-title p {
  color: var(--text-muted);
  font-size: 0.95rem;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.75rem 1.5rem;
  border-radius: 8px;
  font-weight: 600;
  font-size: 0.95rem;
  cursor: pointer;
  transition: var(--transition-smooth);
  border: 1px solid transparent;
  text-decoration: none;
}

.btn-primary {
  background-color: var(--primary);
  color: var(--text-primary);
  border-color: rgba(212, 175, 55, 0.3);
}

.btn-primary:hover {
  background-color: var(--primary-light);
  transform: translateY(-2px);
  box-shadow: 0 4px 15px rgba(88, 17, 26, 0.4);
}

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

.btn-secondary:hover {
  background-color: rgba(255, 255, 255, 0.1);
  transform: translateY(-2px);
}

/* Cards & Glassmorphism */
.glass-card {
  background: var(--bg-card);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--border-glass);
  border-radius: 16px;
  padding: 1.5rem;
  box-shadow: var(--shadow-lg);
  transition: var(--transition-smooth);
}

.glass-card:hover {
  border-color: rgba(212, 175, 55, 0.3);
  transform: translateY(-4px);
}

/* Grid Metrics */
.metrics-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1.5rem;
  margin-bottom: 2.5rem;
}

.metric-card {
  display: flex;
  align-items: center;
  gap: 1.25rem;
}

.metric-icon-wrapper {
  width: 56px;
  height: 56px;
  border-radius: 12px;
  background-color: rgba(88, 17, 26, 0.3);
  border: 1px solid var(--border-glass);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--accent);
}

.metric-info h3 {
  font-size: 1.8rem;
  font-weight: 700;
  line-height: 1.2;
}

.metric-info p {
  font-size: 0.85rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* Dashboard Content Grid */
.dashboard-grid {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 1.5rem;
}

/* Tables */
.table-container {
  overflow-x: auto;
  margin-top: 1rem;
}

.custom-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
}

.custom-table th {
  padding: 1rem;
  border-bottom: 1px solid var(--border-glass);
  color: var(--text-primary);
  font-weight: 600;
  font-size: 0.9rem;
}

.custom-table td {
  padding: 1rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.03);
  font-size: 0.9rem;
  vertical-align: middle;
}

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

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

/* Status Badges */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 0.25rem 0.75rem;
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
}

.badge-success {
  background-color: rgba(76, 175, 80, 0.15);
  color: var(--success);
  border: 1px solid rgba(76, 175, 80, 0.3);
}

.badge-warning {
  background-color: rgba(255, 152, 0, 0.15);
  color: var(--warning);
  border: 1px solid rgba(255, 152, 0, 0.3);
}

.badge-danger {
  background-color: rgba(244, 67, 54, 0.15);
  color: var(--danger);
  border: 1px solid rgba(244, 67, 54, 0.3);
}

/* Activities List */
.activity-list {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  margin-top: 1rem;
}

.activity-item {
  display: flex;
  gap: 1rem;
  align-items: flex-start;
  padding-bottom: 1rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.03);
}

.activity-item:last-child {
  border-bottom: none;
  padding-bottom: 0;
}

.activity-icon {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background-color: var(--accent);
  margin-top: 0.5rem;
  box-shadow: 0 0 8px var(--accent);
  flex-shrink: 0;
}

.activity-details h4 {
  font-size: 0.95rem;
  font-weight: 600;
}

.activity-details p {
  font-size: 0.85rem;
  color: var(--text-muted);
}

.activity-time {
  margin-left: auto;
  font-size: 0.8rem;
  color: var(--text-muted);
}

/* Login Page Styling */
.login-wrapper {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 100vh;
  padding: 1.5rem;
}

.login-card {
  width: 100%;
  max-width: 420px;
  padding: 2.5rem;
}

.login-header {
  text-align: center;
  margin-bottom: 2rem;
}

.login-header img {
  width: 64px;
  height: 64px;
  margin-bottom: 1rem;
  border-radius: 12px;
  border: 1px solid var(--accent);
}

.login-header h2 {
  font-size: 1.8rem;
  margin-bottom: 0.5rem;
}

.login-header p {
  font-size: 0.9rem;
  color: var(--text-muted);
}

.alert {
  padding: 0.85rem 1.25rem;
  border-radius: 8px;
  margin-bottom: 1.5rem;
  font-size: 0.85rem;
  border: 1px solid transparent;
}

.alert-danger {
  background-color: rgba(244, 67, 54, 0.15);
  color: var(--danger);
  border-color: rgba(244, 67, 54, 0.3);
}

.form-group {
  margin-bottom: 1.25rem;
}

.form-group label {
  display: block;
  font-size: 0.85rem;
  color: var(--text-primary);
  font-weight: 500;
  margin-bottom: 0.5rem;
}

.form-control {
  width: 100%;
  padding: 0.85rem 1rem;
  background-color: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border-glass);
  border-radius: 8px;
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 0.95rem;
  transition: var(--transition-smooth);
}

.form-control:focus {
  outline: none;
  border-color: var(--border-focus);
  background-color: rgba(255, 255, 255, 0.05);
  box-shadow: 0 0 0 3px rgba(212, 175, 55, 0.1);
}

/* Mobile Bottom Navigation */
.mobile-nav {
  display: none;
}

/* Offline Banner */
.offline-banner {
  display: none;
  background-color: var(--danger);
  color: #fff;
  text-align: center;
  padding: 0.5rem;
  font-size: 0.85rem;
  font-weight: 600;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  z-index: 1000;
  box-shadow: 0 2px 10px rgba(0,0,0,0.5);
  animation: slideDown 0.3s ease;
}

/* Tab/Panel Switching styles */
.tab-content {
  display: none;
}

.tab-content.active {
  display: block;
  animation: fadeIn 0.4s ease;
}

/* Animations */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes slideDown {
  from { transform: translateY(-100%); }
  to { transform: translateY(0); }
}

/* Responsive styles */
@media (max-width: 992px) {
  .dashboard-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 768px) {
  .sidebar {
    display: none; /* Hide desktop sidebar */
  }
  
  .main-content {
    margin-left: 0;
    padding: 1.5rem 1.5rem 6rem 1.5rem; /* Add padding at the bottom for mobile nav */
  }
  
  .top-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 1rem;
  }
  
  .top-header .btn {
    width: 100%;
  }
  
  /* Mobile Bottom Navigation menu */
  .mobile-nav {
    display: flex;
    justify-content: space-around;
    align-items: center;
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    background-color: var(--bg-sidebar);
    border-top: 1px solid var(--border-glass);
    padding: 0.75rem 0.5rem;
    z-index: 999;
    box-shadow: 0 -4px 15px rgba(0,0,0,0.5);
  }
  
  .mobile-nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.25rem;
    color: var(--text-muted);
    text-decoration: none;
    font-size: 0.7rem;
    font-weight: 500;
    transition: var(--transition-smooth);
    flex: 1;
  }
  
  .mobile-nav-item:hover,
  .mobile-nav-item.active {
    color: var(--accent);
  }
  
  .mobile-nav-item svg {
    width: 22px;
    height: 22px;
  }
}

/* ===================== MODAL STYLES ===================== */

/* Dark glassmorphic backdrop */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(5, 2, 3, 0.75);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  z-index: 2000;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  animation: fadeIn 0.25s ease;
}

.modal-overlay.is-open {
  display: flex;
}

/* Modal card container */
.modal-card {
  background: hsl(350, 28%, 10%);
  border: 1px solid var(--border-glass);
  border-radius: 18px;
  padding: 2rem;
  width: 100%;
  max-width: 580px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 25px 60px rgba(0, 0, 0, 0.8), 0 0 0 1px rgba(212, 175, 55, 0.08);
  animation: modalSlideIn 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes modalSlideIn {
  from { opacity: 0; transform: translateY(24px) scale(0.97); }
  to   { opacity: 1; transform: translateY(0)  scale(1); }
}

/* Modal header */
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.75rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--border-glass);
}

.modal-header h3 {
  font-size: 1.2rem;
  color: var(--text-primary);
}

.modal-close {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.5rem;
  cursor: pointer;
  line-height: 1;
  padding: 0.25rem 0.5rem;
  border-radius: 6px;
  transition: var(--transition-smooth);
}

.modal-close:hover {
  color: var(--text-primary);
  background: rgba(255,255,255,0.06);
}

/* Form layout helpers */
.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

textarea.form-control {
  resize: vertical;
  min-height: 80px;
}

select.form-control option {
  background-color: hsl(350, 28%, 10%);
  color: var(--text-primary);
}

/* Feedback message inside modal */
.modal-feedback {
  padding: 0.75rem 1rem;
  border-radius: 8px;
  font-size: 0.875rem;
  margin-bottom: 1rem;
}

.modal-feedback.success {
  background: rgba(76, 175, 80, 0.12);
  border: 1px solid rgba(76, 175, 80, 0.3);
  color: var(--success);
}

.modal-feedback.error {
  background: rgba(244, 67, 54, 0.12);
  border: 1px solid rgba(244, 67, 54, 0.3);
  color: var(--danger);
}

/* Modal action buttons row */
.modal-actions {
  display: flex;
  gap: 0.75rem;
  justify-content: flex-end;
  margin-top: 1.5rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--border-glass);
}

/* Loading spinner on buttons */
.btn.is-loading {
  opacity: 0.7;
  pointer-events: none;
}

/* Empty state inside tables */
.empty-state {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--text-muted);
}

.empty-state svg {
  width: 48px;
  height: 48px;
  margin-bottom: 1rem;
  opacity: 0.4;
}

.empty-state p {
  font-size: 0.95rem;
}

/* Badge secondary (distributor) */
.badge-secondary {
  background-color: rgba(100, 100, 100, 0.15);
  color: var(--text-muted);
  border: 1px solid rgba(100, 100, 100, 0.3);
}

/* Responsive modal */
@media (max-width: 640px) {
  .modal-card {
    padding: 1.5rem 1.25rem;
  }
  .form-row {
    grid-template-columns: 1fr;
  }
  .modal-actions {
    flex-direction: column-reverse;
  }
  .modal-actions .btn {
    width: 100%;
    justify-content: center;
  }
}

