/**
 * Common Styles for Restaurant COGS Calculator
 * Shared across all pages for consistency
 */

:root {
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial;
  --radius: 12px;
  --pad: 14px;
  --success: #10b981;
  --danger: #ef4444;
  --warning: #f59e0b;
  --info: #06b6d4;
  --accent: #6366f1;
}

/* Dark mode (default) */
:root,
[data-theme="dark"] {
  --bg: #0f1724;
  --card: #0b1220;
  --muted: #9aa4b2;
  --text: #e6eef6;
  --text-secondary: #ffffff;
  --glass: rgba(255,255,255,0.03);
  --border: rgba(255,255,255,0.06);
  --border-light: rgba(255,255,255,0.03);
  --gradient-start: #071023;
  --gradient-end: #081226;
  --card-gradient: linear-gradient(180deg, rgba(255,255,255,0.02), transparent);
  --modal-bg: rgba(2,6,23,0.6);
  --panel-bg: #071428;
  --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
}

/* Light mode */
[data-theme="light"] {
  --bg: #f8fafc;
  --card: #ffffff;
  --muted: #64748b;
  --text: #1e293b;
  --text-secondary: #0f172a;
  --glass: rgba(0,0,0,0.05);
  --border: rgba(0,0,0,0.1);
  --border-light: rgba(0,0,0,0.05);
  --gradient-start: #f1f5f9;
  --gradient-end: #e2e8f0;
  --card-gradient: linear-gradient(180deg, rgba(0,0,0,0.02), transparent);
  --modal-bg: rgba(0,0,0,0.5);
  --panel-bg: #ffffff;
  --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
}

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

body {
  margin: 0;
  background: linear-gradient(180deg, var(--gradient-start) 0%, var(--gradient-end) 100%);
  color: var(--text);
  min-height: 100vh;
  transition: background 0.3s ease, color 0.3s ease;
}

/* Top Navigation */
.top-nav {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--card);
  backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border);
  padding: 16px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  box-shadow: var(--shadow);
}

.nav-left {
  display: flex;
  align-items: center;
  gap: 16px;
}

.nav-logo {
  width: 48px;
  height: 48px;
  background: linear-gradient(135deg, var(--accent), #7c3aed);
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  font-weight: 700;
  color: white;
  box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3);
  text-decoration: none;
}

.nav-title {
  font-size: 20px;
  font-weight: 600;
  color: var(--text-secondary);
}

.nav-center {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
  justify-content: center;
  margin: 0 24px;
}

.nav-link {
  padding: 8px 16px;
  border-radius: 8px;
  text-decoration: none;
  color: var(--muted);
  font-size: 14px;
  font-weight: 500;
  transition: all 0.3s ease;
  display: flex;
  align-items: center;
  gap: 6px;
  position: relative;
}

.nav-link:hover {
  color: var(--text);
  background: var(--glass);
}

.nav-link.active {
  color: var(--accent);
  background: rgba(99, 102, 241, 0.15);
  font-weight: 600;
}

.nav-link.active::after {
  content: '';
  position: absolute;
  bottom: -16px;
  left: 50%;
  transform: translateX(-50%);
  width: 60%;
  height: 2px;
  background: var(--accent);
  border-radius: 2px;
}

.nav-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.theme-toggle {
  background: var(--glass);
  border: 1.5px solid var(--border);
  border-radius: 10px;
  padding: 8px 14px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text);
  font-size: 14px;
  font-weight: 500;
  transition: all 0.3s ease;
}

.theme-toggle:hover {
  background: var(--card);
  border-color: var(--accent);
  color: var(--accent);
  transform: translateY(-2px);
}

/* User Profile Button */
.user-profile-btn {
  background: linear-gradient(135deg, var(--accent), #7c3aed);
  border: none;
  border-radius: 12px;
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: white;
  font-size: 18px;
  font-weight: 600;
  transition: all 0.3s ease;
  box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3);
  position: relative;
}

.user-profile-btn:hover {
  transform: scale(1.05);
  box-shadow: 0 6px 20px rgba(99, 102, 241, 0.4);
}

.user-dropdown-header {
  position: absolute;
  top: calc(100% + 12px);
  right: 0;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 16px;
  min-width: 300px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
  opacity: 0;
  visibility: hidden;
  transform: translateY(-10px);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  padding: 20px;
  backdrop-filter: blur(20px);
  z-index: 1000;
}

.user-dropdown-header.show {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.dropdown-item-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border-radius: 10px;
  cursor: pointer;
  transition: all 0.2s ease;
  color: var(--text);
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
}

.dropdown-item-header:hover {
  background: var(--glass);
  transform: translateX(4px);
}

.dropdown-item-header.logout {
  color: var(--danger);
  margin-top: 8px;
  border-top: 1px solid var(--border);
  padding-top: 16px;
}

.dropdown-item-header.logout:hover {
  background: rgba(239, 68, 68, 0.1);
}

.dropdown-item-header.active {
  background: rgba(99, 102, 241, 0.15);
  color: var(--accent);
  font-weight: 600;
}

/* Container */
.container {
  max-width: 1400px;
  margin: 0 auto;
  padding: 20px;
}

/* Cards */
.card {
  background: var(--card-gradient);
  padding: var(--pad);
  border-radius: var(--radius);
  border: 1px solid var(--border-light);
  transition: background 0.3s ease, border-color 0.3s ease;
  margin-bottom: 16px;
}

/* Buttons */
.btn {
  padding: 10px 20px;
  background: linear-gradient(135deg, var(--accent), #7c3aed);
  color: white;
  border: none;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s ease;
  box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3);
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 20px rgba(99, 102, 241, 0.4);
}

.btn-ghost {
  background: var(--glass);
  border: 1px solid var(--border);
  color: var(--text);
}

.btn-ghost:hover {
  background: var(--card);
  border-color: var(--accent);
  color: var(--accent);
}

/* Typography */
h1, h2, h3, h4 {
  margin: 0;
  color: var(--text-secondary);
  font-weight: 600;
}

.small {
  font-size: 13px;
  color: var(--muted);
}

/* Forms */
input, select, textarea {
  padding: 10px 12px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-size: 14px;
  transition: all 0.3s ease;
  width: 100%;
}

input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

label {
  font-size: 13px;
  color: var(--muted);
  font-weight: 500;
  display: block;
  margin-bottom: 6px;
}

/* Tables */
table {
  width: 100%;
  border-collapse: collapse;
}

th, td {
  padding: 12px;
  text-align: left;
  border-bottom: 1px solid var(--border-light);
  font-size: 14px;
}

th {
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
  background: var(--glass);
  position: sticky;
  top: 0;
}

tbody tr:hover {
  background: var(--glass);
}

/* Responsive */
@media (max-width: 768px) {
  .nav-center {
    display: none;
  }
  
  .nav-title {
    display: none;
  }
  
  .top-nav {
    padding: 12px 16px;
  }

  .nav-link span:not(:first-child) {
    display: none;
  }
  
  .nav-link {
    padding: 8px 12px;
  }
}

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

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

.fade-in {
  animation: fadeInUp 0.6s ease;
}

/* Additional common components */
.header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 24px;
  gap: 16px;
  flex-wrap: wrap;
}

.tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 20px;
  border-bottom: 2px solid var(--border);
  padding-bottom: 0;
}

.tab {
  padding: 12px 20px;
  background: transparent;
  border: none;
  border-bottom: 3px solid transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  margin-bottom: -2px;
}

.tab:hover {
  color: var(--text);
  background: var(--glass);
}

.tab.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
  font-weight: 600;
}

.tab-content {
  display: none;
  animation: fadeIn 0.3s ease;
}

.tab-content.active {
  display: block;
}

/* Full-page modal background overlay */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  width: 100vw;
  height: 100vh;
  min-width: 100vw;
  min-height: 100vh;
  background: var(--modal-bg);
  backdrop-filter: blur(8px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 2000;
  padding: 20px;
  margin: 0;
  overflow-y: auto;
  overflow-x: hidden;
  box-sizing: border-box;
}

.modal-overlay.show {
  display: flex;
}

/* Centered popup form window */
.modal {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 32px 40px;
  width: 90%;
  max-width: 900px;
  max-height: 90vh;
  overflow-y: auto;
  overflow-x: hidden;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
  display: flex;
  flex-direction: column;
  margin: auto;
  position: relative;
  /* Force center positioning */
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  flex-shrink: 0;
}

.modal-overlay.show .modal {
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  margin: 0;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 28px;
  padding-bottom: 20px;
  border-bottom: 2px solid var(--border);
  flex-shrink: 0;
}

.modal-title {
  font-size: 28px;
  font-weight: 700;
  color: var(--text-secondary);
  margin: 0;
}

.close-modal {
  background: var(--glass);
  border: 1px solid var(--border);
  color: var(--muted);
  font-size: 24px;
  cursor: pointer;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
  transition: all 0.2s ease;
}

.close-modal:hover {
  background: var(--card);
  color: var(--text);
  transform: rotate(90deg);
}

/* Full-window modal form improvements */
.modal form {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
}

.modal .form-group {
  margin-bottom: 20px;
}

.modal .form-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 20px;
  margin-bottom: 20px;
}

.modal input,
.modal select,
.modal textarea {
  font-size: 15px;
  padding: 12px 16px;
}

.modal textarea {
  min-height: 120px;
  resize: vertical;
}

.modal .btn {
  padding: 12px 24px;
  font-size: 15px;
  font-weight: 600;
}

/* Ensure modal content is scrollable */
.modal > *:not(.modal-header) {
  flex: 1;
  overflow-y: auto;
}

.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--muted);
}

.empty-state-icon {
  font-size: 64px;
  margin-bottom: 16px;
  opacity: 0.5;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.badge {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
}

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

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

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

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

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