/**
 * ============================================================================
 * File: styles/workspace.css
 * Responsibility: Master Application Design System & Custom UI Component Styling
 * Project: Sheet Control Portal / Dashboard-Workspace
 * Author: Minions Enterprise Solutions
 * 
 * Description:
 *   Contains CSS variables, dark navbar high-visibility pill overrides, iframe container
 *   layout rules, table designs, status badges, social link icons, modal dialogs,
 *   toast notifications, and responsive layout breakpoints.
 * ============================================================================
 */

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

:root {
  --primary: #4f46e5;
  --primary-hover: #4338ca;
  --primary-light: #eef2ff;
  --secondary: #0ea5e9;
  --success: #10b981;
  --success-light: #d1fae5;
  --warning: #f59e0b;
  --warning-light: #fef3c7;
  --danger: #ef4444;
  --danger-light: #fee2e2;
  --bg-main: #f8fafc;
  --card-bg: #ffffff;
  --text-main: #0f172a;
  --text-muted: #64748b;
  --border-color: #e2e8f0;
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 20px -2px rgba(0, 0, 0, 0.08);
  --shadow-lg: 0 10px 30px -5px rgba(0, 0, 0, 0.12);
}

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

body {
  font-family: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, sans-serif;
  background-color: var(--bg-main);
  color: var(--text-main);
  line-height: 1.5;
  padding-bottom: 50px;
}

/* App Header & Navigation */
company-navbar {
  display: block;
  width: 100%;
  position: sticky;
  top: 0;
  z-index: 1000;
}

/* Fix navbar white-on-white text visibility issue */
company-navbar .company-navbar {
  background: #1e293b !important;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1) !important;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.25) !important;
}

company-navbar .nav-links-wrapper {
  display: flex !important;
  align-items: center !important;
}

company-navbar .nav-links {
  background: rgba(15, 23, 42, 0.85) !important;
  border: 1px solid rgba(255, 255, 255, 0.18) !important;
  border-radius: 999px !important;
  padding: 4px 8px !important;
  display: flex !important;
  gap: 6px !important;
}

company-navbar .nav-links a {
  color: #cbd5e1 !important;
  background: transparent !important;
  border-radius: 999px !important;
  padding: 8px 18px !important;
  font-size: 0.9rem !important;
  font-weight: 600 !important;
  text-decoration: none !important;
  display: inline-flex !important;
  align-items: center !important;
  gap: 8px !important;
  transition: all 0.2s ease !important;
}

company-navbar .nav-links a i,
company-navbar .nav-links a svg {
  color: inherit !important;
  font-size: 1rem !important;
}

company-navbar .nav-links a:hover {
  color: #ffffff !important;
  background: rgba(255, 255, 255, 0.12) !important;
}

company-navbar .nav-links a.active {
  color: #ffffff !important;
  background: #2563eb !important;
  box-shadow: 0 2px 10px rgba(37, 99, 235, 0.4) !important;
}

/* Dashboard Shell Layout */
body.dashboard-body {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  margin: 0;
  padding: 0;
  background-color: #0f172a;
}

.iframe-container {
  flex: 1;
  width: 100%;
  display: flex;
  flex-direction: column;
  min-height: calc(100vh - 120px);
  background: #f8fafc;
}

.iframe-container iframe {
  width: 100%;
  height: 100%;
  min-height: calc(100vh - 120px);
  border: none;
  display: block;
}

/* Footer Styling */
.app-footer {
  background: #1e293b;
  color: #94a3b8;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  padding: 16px 24px;
  text-align: center;
  font-size: 0.875rem;
}

.app-footer strong {
  color: #38bdf8;
}

/* Hide header inside iframe */
html.in-iframe company-navbar,
body.in-iframe company-navbar {
  display: none !important;
}

.app-header {
  background: #ffffff;
  border-bottom: 1px solid var(--border-color);
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: var(--shadow-sm);
}

.header-container {
  max-width: 1400px;
  margin: 0 auto;
  padding: 16px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
}

.brand-title {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--primary);
  text-decoration: none;
}

.brand-title svg {
  width: 28px;
  height: 28px;
  fill: currentColor;
}

.nav-links {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-main);
  padding: 4px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
}

.nav-item {
  padding: 8px 18px;
  border-radius: var(--radius-sm);
  text-decoration: none;
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--text-muted);
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  gap: 8px;
}

.nav-item:hover {
  color: var(--text-main);
  background: rgba(255, 255, 255, 0.8);
}

.nav-item.active {
  background: var(--card-bg);
  color: var(--primary);
  box-shadow: var(--shadow-sm);
}

/* Main Container with Upper Gap */
.workspace-container {
  max-width: 1400px;
  margin: 0 auto;
  padding: 40px 24px 32px 24px;
}

body.in-iframe .workspace-container,
html.in-iframe .workspace-container {
  padding-top: 40px !important;
  margin-top: 40px !important;
}

/* Workspace Card */
.workspace-card {
  background: var(--card-bg);
  border-radius: var(--radius-lg);
  padding: 28px;
  box-shadow: var(--shadow-md);
  border: 1px solid var(--border-color);
}

.page-header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 20px;
  margin-bottom: 24px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--border-color);
}

.page-header-title h2 {
  font-size: 1.5rem;
  font-weight: 800;
  color: var(--text-main);
  letter-spacing: -0.02em;
}

.page-header-title p {
  color: var(--text-muted);
  font-size: 0.9rem;
  margin-top: 4px;
}

/* ============================================================================
   SHEET CONTROLS, DROPDOWNS, SEARCH — Base Styles (used in index.html & admin.html)
   ============================================================================ */
.sheet-controls {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}

.sheet-select-wrapper {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--primary-light);
  padding: 8px 14px;
  border-radius: var(--radius-md);
  border: 1px solid rgba(79, 70, 229, 0.2);
}

.control-label {
  font-weight: 700;
  font-size: 0.8rem;
  color: var(--primary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  white-space: nowrap;
}

.sheet-dropdown {
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
  background: #ffffff;
  font-family: inherit;
  font-weight: 600;
  font-size: 0.95rem;
  color: var(--text-main);
  outline: none;
  cursor: pointer;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
  min-width: 160px;
  appearance: auto;
}

.sheet-dropdown:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.15);
}

.search-box-wrapper {
  display: flex;
  align-items: center;
}

.search-input {
  padding: 9px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
  background: #ffffff;
  font-family: inherit;
  font-size: 0.9rem;
  outline: none;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
  min-width: 220px;
  width: 100%;
}

.search-input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.15);
}

/* Controls & Dropdowns (legacy selectors) */
.controls-group {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}

.sheet-selector-box {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--primary-light);
  padding: 8px 14px;
  border-radius: var(--radius-md);
  border: 1px solid rgba(79, 70, 229, 0.2);
}

.sheet-selector-box label {
  font-weight: 700;
  font-size: 0.85rem;
  color: var(--primary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.sheet-select {
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
  background: #fff;
  font-family: inherit;
  font-weight: 600;
  font-size: 0.95rem;
  color: var(--text-main);
  outline: none;
  cursor: pointer;
  transition: border-color 0.2s;
}

.sheet-select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.15);
}

.search-box {
  position: relative;
  min-width: 240px;
}

.search-box input {
  width: 100%;
  padding: 9px 14px 9px 36px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
  font-family: inherit;
  font-size: 0.9rem;
  outline: none;
  transition: all 0.2s;
}

.search-box input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.15);
}

.search-box svg {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  width: 16px;
  height: 16px;
  fill: var(--text-muted);
}

/* Forms */
.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 20px;
}

.form-group {
  display: flex;
  flex-direction: column;
}

.form-group.full-width {
  grid-column: 1 / -1;
}

.form-group label {
  margin-bottom: 8px;
  font-weight: 600;
  font-size: 0.88rem;
  color: var(--text-main);
}

.form-group input,
.form-group select,
.form-group textarea {
  padding: 11px 14px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  font-family: inherit;
  font-size: 0.95rem;
  outline: none;
  transition: all 0.2s ease;
  background: #ffffff;
  width: 100%;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 4px rgba(79, 70, 229, 0.1);
}

.form-control {
  padding: 11px 14px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  font-family: inherit;
  font-size: 0.95rem;
  outline: none;
  transition: all 0.2s ease;
  background: #ffffff;
  width: 100%;
}

.form-control:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 4px rgba(79, 70, 229, 0.1);
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 22px;
  font-family: inherit;
  font-weight: 600;
  font-size: 0.9rem;
  border-radius: var(--radius-md);
  border: none;
  cursor: pointer;
  transition: all 0.2s ease;
  text-decoration: none;
}

.btn-primary {
  background: var(--primary);
  color: #ffffff;
  box-shadow: 0 4px 12px rgba(79, 70, 229, 0.25);
}

.btn-primary:hover {
  background: var(--primary-hover);
  transform: translateY(-1px);
}

.btn-success {
  background: var(--success);
  color: #ffffff;
  box-shadow: 0 4px 12px rgba(16, 185, 129, 0.25);
}

.btn-success:hover {
  background: #059669;
  transform: translateY(-1px);
}

.btn-outline {
  background: transparent;
  border: 1px solid var(--border-color);
  color: var(--text-main);
}

.btn-outline:hover {
  background: var(--bg-main);
  border-color: var(--text-muted);
}

.btn-outline.active {
  background: var(--primary);
  color: #ffffff;
  border-color: var(--primary);
}

.btn-sm {
  padding: 6px 12px;
  font-size: 0.82rem;
  border-radius: var(--radius-sm);
}

/* Data Table */
.table-responsive {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
}

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

.data-table th {
  background: var(--bg-main);
  padding: 14px 16px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  font-size: 0.75rem;
  letter-spacing: 0.05em;
  border-bottom: 1px solid var(--border-color);
  white-space: nowrap;
}

.data-table td {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border-color);
  vertical-align: middle;
}

.data-table tbody tr:hover {
  background: rgba(248, 250, 252, 0.8);
}

/* Badges */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  white-space: nowrap;
}

.badge-posted {
  background: var(--success-light);
  color: #065f46;
}

.badge-scheduled {
  background: var(--primary-light);
  color: var(--primary);
}

.badge-pending {
  background: var(--warning-light);
  color: #92400e;
}

.badge-notposted {
  background: var(--danger-light);
  color: #991b1b;
}

.badge-approved {
  background: #dcfce7;
  color: #15803d;
  border: 1px solid #bbf7d0;
}

.badge-unapproved {
  background: #fef2f2;
  color: #dc2626;
  border: 1px solid #fecaca;
}

/* Social Link Icons */
.link-group {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.link-btn {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  text-decoration: none;
  transition: transform 0.2s;
  flex-shrink: 0;
}

.link-btn:hover {
  transform: scale(1.1);
}

.link-btn.instagram {
  background: linear-gradient(45deg, #f09433, #e6683c, #dc2743, #cc2366, #bc1888);
}

.link-btn.facebook {
  background: #1877f2;
}

.link-btn.linkedin {
  background: #0a66c2;
}

.link-btn.store {
  background: #4f46e5;
}

.link-btn svg {
  width: 16px;
  height: 16px;
  fill: currentColor;
}

/* ============================================================================
   MODAL — supports both .modal-content and .modal-card class names
   ============================================================================ */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  margin-top: 5%;
  background: rgba(15, 23, 42, 0.6);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  opacity: 0;
  visibility: hidden;
  transition: all 0.25s ease;
  padding: 10px;
}

.modal-overlay.active {
  opacity: 1;
  visibility: visible;
}

.modal-content,
.modal-card {
  background: #ffffff;
  border-radius: var(--radius-lg);
  width: 90%;
  max-width: 700px;
  padding: 80px;
  box-shadow: var(--shadow-lg);
  transform: scale(0.95);
  transition: transform 0.25s ease;
  max-height: 90vh;
  overflow-y: auto;
}

.modal-overlay.active .modal-content,
.modal-overlay.active .modal-card {
  transform: scale(1);
}

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

.modal-header h3 {
  font-size: 1.25rem;
  font-weight: 700;
}

.close-modal,
.modal-close {
  background: none;
  border: none;
  font-size: 1.5rem;
  cursor: pointer;
  color: var(--text-muted);
  width: 36px;
  height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  transition: all 0.2s ease;
  flex-shrink: 0;
}

.close-modal:hover,
.modal-close:hover {
  background: var(--danger-light);
  color: var(--danger);
}

/* Toast Notifications */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 2000;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.toast {
  padding: 12px 20px;
  border-radius: var(--radius-md);
  background: var(--text-main);
  color: #fff;
  font-size: 0.9rem;
  font-weight: 600;
  box-shadow: var(--shadow-lg);
  animation: slideIn 0.3s forwards;
}

.toast.success {
  background: var(--success);
}

.toast.error {
  background: var(--danger);
}

@keyframes slideIn {
  from {
    transform: translateX(100%);
    opacity: 0;
  }

  to {
    transform: translateX(0);
    opacity: 1;
  }
}

/* Empty State & Loader */
.empty-state {
  text-align: center;
  padding: 48px 20px;
  color: var(--text-muted);
}

.empty-state svg {
  width: 48px;
  height: 48px;
  margin-bottom: 12px;
  opacity: 0.5;
}

.spinner {
  width: 24px;
  height: 24px;
  border: 3px solid rgba(79, 70, 229, 0.2);
  border-radius: 50%;
  border-top-color: var(--primary);
  animation: spin 0.8s linear infinite;
  display: inline-block;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* ============================================================================
   SETTINGS PAGE — Card Sections
   ============================================================================ */
.settings-section {
  margin-bottom: 32px;
  padding: 24px;
  background: var(--bg-main);
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
}

.settings-section h3 {
  font-size: 1.1rem;
  font-weight: 700;
  margin-bottom: 6px;
  color: var(--text-main);
}

.settings-section p {
  font-size: 0.88rem;
  color: var(--text-muted);
  margin-bottom: 16px;
}

.settings-current {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  background: #ffffff;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  margin-bottom: 16px;
  font-size: 0.9rem;
  word-break: break-all;
}

.settings-current .label {
  font-weight: 700;
  color: var(--text-muted);
  white-space: nowrap;
}

.settings-current .value {
  color: var(--primary);
  font-weight: 600;
  font-family: 'Courier New', monospace;
}

/* ============================================================================
   RESPONSIVE DESIGN BREAKPOINTS (Mobile, Tablet, Desktop)
   ============================================================================ */

/* 1. Large Screen Adjustments (<= 1200px) */
@media screen and (max-width: 1200px) {
  .workspace-container {
    max-width: 100%;
    padding: 30px 20px 24px 20px;
  }
}

/* 2. Tablet & Medium Screens (<= 992px) */
@media screen and (max-width: 992px) {
  body.in-iframe .workspace-container,
  html.in-iframe .workspace-container {
    padding-top: 24px !important;
    margin-top: 20px !important;
  }

  .workspace-card {
    padding: 20px 18px;
  }

  .page-header-row {
    flex-direction: column;
    align-items: stretch;
    gap: 16px;
  }

  .page-header-title {
    width: 100%;
  }

  .sheet-controls,
  .controls-group {
    width: 100%;
    flex-direction: row;
    flex-wrap: wrap;
    justify-content: flex-start;
    gap: 12px;
  }

  .sheet-select-wrapper,
  .sheet-selector-box {
    flex: 1 1 auto;
    min-width: 200px;
  }

  .search-box-wrapper,
  .search-box {
    flex: 1 1 auto;
    min-width: 200px;
  }

  .modal-content,
  .modal-card {
    width: 92%;
    max-width: 600px;
    padding: 22px 18px;
  }

  .form-grid {
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  }
}

/* 3. Mobile Devices & Small Tablets (<= 768px) */
@media screen and (max-width: 768px) {
  body {
    padding-bottom: 20px;
  }

  .workspace-container {
    padding: 16px 12px 20px 12px;
  }

  body.in-iframe .workspace-container,
  html.in-iframe .workspace-container {
    padding-top: 16px !important;
    margin-top: 10px !important;
  }

  .workspace-card {
    padding: 16px 12px;
    border-radius: var(--radius-md);
  }

  .page-header-title h2 {
    font-size: 1.2rem;
  }

  .page-header-title p {
    font-size: 0.82rem;
  }

  .sheet-controls,
  .controls-group {
    flex-direction: column;
    align-items: stretch;
    width: 100%;
    gap: 10px;
  }

  .sheet-select-wrapper,
  .sheet-selector-box,
  .search-box-wrapper,
  .search-box {
    width: 100%;
    min-width: 100%;
    flex: 1 1 100%;
  }

  .sheet-dropdown,
  .sheet-select,
  .search-input,
  .search-box input {
    width: 100%;
    font-size: 0.88rem;
    padding: 10px 12px;
  }

  /* Filter buttons wrapping */
  .filter-btn-group,
  div[style*="display:flex; gap:10px;"] {
    flex-wrap: wrap;
    gap: 6px !important;
  }

  .filter-btn {
    flex: 1 1 auto;
    text-align: center;
    justify-content: center;
    padding: 8px 12px;
    font-size: 0.8rem;
  }

  /* Form Layout for Mobile */
  .form-grid {
    grid-template-columns: 1fr !important;
    gap: 14px;
  }

  .form-actions {
    flex-direction: column-reverse;
    width: 100%;
    gap: 10px;
  }

  .form-actions .btn {
    width: 100%;
    justify-content: center;
  }

  /* Table Touch Scrolling */
  .table-responsive {
    border-radius: var(--radius-sm);
    margin-top: 12px;
    border: 1px solid var(--border-color);
  }

  .data-table {
    min-width: 600px;
    font-size: 0.82rem;
  }

  .data-table th,
  .data-table td {
    padding: 10px 8px;
  }

  /* Modal on Mobile */
  .modal-overlay {
    padding: 10px;
  }

  .modal-content,
  .modal-card {
    width: 100%;
    max-width: 100%;
    padding: 18px 14px;
    max-height: 92vh;
    border-radius: var(--radius-md);
  }

  .modal-header h3 {
    font-size: 1.1rem;
  }

  /* Settings on Mobile */
  .settings-section {
    padding: 16px 12px;
  }

  .settings-current {
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
  }

  /* Toast Adjustments */
  .toast-container {
    left: 12px;
    right: 12px;
    bottom: 16px;
    width: calc(100% - 24px);
  }

  .toast {
    font-size: 0.82rem;
    padding: 10px 14px;
    text-align: center;
  }
}

/* 4. Ultra Small Screens / Phones (<= 480px) */
@media screen and (max-width: 480px) {
  .workspace-container {
    padding: 10px 8px 16px 8px;
  }

  .workspace-card {
    padding: 14px 10px;
  }

  .page-header-title h2 {
    font-size: 1.1rem;
  }

  .data-table {
    min-width: 540px;
    font-size: 0.78rem;
  }

  .btn {
    padding: 8px 14px;
    font-size: 0.82rem;
  }

  .badge {
    font-size: 0.72rem;
    padding: 3px 6px;
  }

  .sheet-select-wrapper {
    padding: 6px 10px;
  }

  .control-label {
    font-size: 0.7rem;
  }

  .modal-content,
  .modal-card {
    padding: 14px 10px;
  }
}