/* OrderNau Portal Styles - matching main website theme */

/* CSS Variables for theming */
:root {
  --primary-color: #2563eb;
  --primary-hover: #1d4ed8;
  --secondary-color: #64748b;
  --background: #ffffff;
  --surface: #f8fafc;
  --border-color: #e2e8f0;
  --text-primary: #0f172a;
  --text-secondary: #64748b;
  --success: #10b981;
  --warning: #f59e0b;
  --error: #ef4444;
  --shadow: 0 1px 3px 0 rgb(0 0 0 / 0.1), 0 1px 2px -1px rgb(0 0 0 / 0.1);
  --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
  --radius: 8px;
  --radius-sm: 6px;
  --font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
}

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

body {
  font-family: var(--font-family);
  background: var(--surface);
  color: var(--text-primary);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Scrollbar styling */
*::-webkit-scrollbar {
  width: 8px;
  background: transparent;
}

*::-webkit-scrollbar-thumb {
  background-color: rgba(0, 0, 0, 0.2);
  border-radius: 10px;
}

*::-webkit-scrollbar-thumb:hover {
  background-color: rgba(0, 0, 0, 0.4);
}

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

/* Header / Topbar */
.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--background);
  padding: 12px 32px;
  border-bottom: 1px solid var(--border-color);
  box-shadow: 0 1px 3px rgba(0,0,0,0.05);
  margin-bottom: 24px;
  position: sticky;
  top: 0;
  z-index: 100;
  backdrop-filter: blur(8px);
  background: rgba(255, 255, 255, 0.95);
}

.topbar .logo {
  height: 36px;
  width: auto;
  transition: opacity 0.2s ease;
}

.topbar .logo:hover {
  opacity: 0.8;
}

.topbar h1, .topbar h2 {
  font-size: 20px !important;
  font-weight: 600 !important;
  color: var(--text-primary) !important;
  margin: 0 !important;
  margin-left: 12px !important; /* ensure spacing from logo */
}

/* Navigation Links */
a {
  color: var(--primary-color);
  text-decoration: none;
  transition: color 0.2s ease;
}

a:hover {
  color: var(--primary-hover);
}

/* Buttons */
button, .btn {
  display: inline-block;
  padding: 10px 20px;
  background: var(--primary-color);
  color: white;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: var(--shadow);
}

button:hover, .btn:hover {
  background: var(--primary-hover);
  color: white;
  box-shadow: var(--shadow-lg);
}

button:active, .btn:active {
  transform: translateY(1px);
}

/* Danger button - must come after general button styles */
button.btn-danger, .btn.btn-danger {
  background: var(--error) !important;
}

button.btn-danger:hover, .btn.btn-danger:hover {
  background: #dc2626 !important;
  color: white !important;
  box-shadow: var(--shadow-lg);
}

/* Forms */
input, select, textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-family: var(--font-family);
  background: var(--background);
  color: var(--text-primary);
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

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

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

fieldset {
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 16px;
}

legend {
  font-weight: 600;
  color: var(--text-primary);
  padding: 0 8px;
}

/* Cards */
.card {
  background: var(--background);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
  margin-bottom: 16px;
}

.card h3 {
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 12px;
  color: var(--text-primary);
}

/* Tables */
table {
  width: 100%;
  border-collapse: collapse;
  background: var(--background);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
}

.table-wrapper {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

thead {
  background: var(--surface);
}

th, td {
  padding: 12px 16px;
  text-align: left;
  border-bottom: 1px solid var(--border-color);
}

th {
  font-weight: 600;
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-secondary);
}

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

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

/* Pills / Badges */
.pill {
  display: inline-block;
  padding: 4px 12px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 500;
}

.pill.ok {
  background: #d1fae5;
  color: #065f46;
}

.pill.no {
  background: #f3f4f6;
  color: #6b7280;
}

.pill.warning {
  background: #fef3c7;
  color: #92400e;
}

/* Search */
.search {
  margin-top: 12px;
}

.search input {
  max-width: 400px;
}

.search button {
  margin-left: 8px;
}

/* Grid */
.grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
}

/* Auth Pages */
.auth-container {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  padding: 24px;
}

.auth-card {
  background: var(--background);
  border-radius: var(--radius);
  padding: 40px;
  box-shadow: var(--shadow-lg);
  max-width: 420px;
  width: 100%;
}

.auth-card .logo {
  display: block;
  margin: 0 auto 24px;
  height: 48px;
}

.auth-card h2 {
  text-align: center;
  margin-bottom: 24px;
  color: var(--text-primary);
}

.auth-card .error {
  background: #fee;
  color: var(--error);
  padding: 12px;
  border-radius: var(--radius-sm);
  margin-bottom: 16px;
  font-size: 14px;
}

/* Utility classes */
.text-center {
  text-align: center;
}

.mt-1 { margin-top: 8px; }
.mt-2 { margin-top: 16px; }
.mt-3 { margin-top: 24px; }
.mb-1 { margin-bottom: 8px; }
.mb-2 { margin-bottom: 16px; }
.mb-3 { margin-bottom: 24px; }

.muted {
  color: var(--text-secondary);
  font-size: 14px;
}

/* Action buttons: used in portal_detail quick actions */
.action-buttons {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.action-buttons .btn {
  width: 100%;
  text-align: center;
  display: inline-block;
}
.btn-block {
  display: block;
  width: 100%;
}

/* Package description box */
.package-description {
  background: var(--surface);
  padding: 10px;
  border-radius: 6px;
  margin-top: 6px;
  white-space: pre-wrap; /* preserve newlines */
  border: 1px solid var(--border-color);
}

/* Responsive */
@media (max-width: 768px) {
  .container {
    padding: 16px;
  }
  
  .topbar {
    flex-direction: column;
    gap: 12px;
    align-items: stretch;
    padding: 12px 16px;
  }
  
  .topbar > div {
    flex-direction: column !important;
    gap: 8px !important;
  }
  
  .topbar form {
    flex-direction: column !important;
  }
  
  .topbar input[type="text"],
  .topbar input[type="date"] {
    width: 100% !important;
    max-width: none !important;
  }
  
  .topbar .btn {
    width: 100%;
    padding: 10px 16px;
  }
  
  .grid {
    grid-template-columns: 1fr;
  }
  
  .table-wrapper {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
  
  table {
    font-size: 12px;
    min-width: 600px;
  }
  
  th, td {
    padding: 8px 10px;
  }
  
  /* Make action links in tables more mobile friendly */
  td form,
  td a {
    font-size: 12px;
  }
  
  /* Auth card on mobile */
  .auth-card {
    padding: 24px;
  }
  
  /* Stat cards on mobile */
  .stat-grid {
    grid-template-columns: 1fr !important;
  }
  
  /* Tracking page mobile */
  .tracking-container {
    padding: 0 16px !important;
    margin: 30px auto !important;
  }
  
  .tracking-card {
    padding: 20px !important;
  }
  
  .tracking-code {
    font-size: 20px !important;
  }
  
  .info-row {
    flex-direction: column;
    gap: 4px;
  }
  
  /* Webhook cards */
  .webhook-card {
    padding: 16px !important;
  }
  
  .webhook-header {
    flex-direction: column !important;
    align-items: flex-start !important;
    gap: 8px;
  }
}

@media (max-width: 480px) {
  body {
    font-size: 14px;
  }
  
  .topbar h1, .topbar h2 {
    font-size: 16px;
  }
  
  button, .btn {
    font-size: 13px;
    padding: 9px 16px;
  }
  
  table {
    font-size: 11px;
  }
  
  th, td {
    padding: 6px 8px;
  }
  
  .stat-value {
    font-size: 28px !important;
  }
}