/* ========================================
   CloaKing - SaaS Professional Styles
   ======================================== */

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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  line-height: 1.5;
  color: #111827;
  background: #f8fafc;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

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

.main-content {
  flex: 1;
}

.container {
  max-width: 1120px;
  margin: 0 auto;
  padding: 0 24px;
}

/* Authentication Layout (Split Screen) */
.auth-wrapper {
  display: flex;
  min-height: 100vh;
  background: white;
}

.auth-sidebar {
  display: none;
  width: 40%;
  background: linear-gradient(135deg, #0ea5e9 0%, #2563eb 100%);
  color: white;
  padding: 48px;
  flex-direction: column;
  justify-content: space-between;
}

@media (min-width: 768px) {
  .auth-sidebar {
    display: flex;
  }
}

.auth-sidebar-content h2 {
  color: white;
  font-size: 32px;
  margin-bottom: 16px;
}

.auth-sidebar-content p {
  color: rgba(255, 255, 255, 0.9);
  font-size: 18px;
}

.auth-main {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.auth-box {
  width: 100%;
  max-width: 400px;
}

/* Typography */
h1, h2, h3, h4 {
  font-weight: 700;
  letter-spacing: -0.025em;
  color: #111827;
}

/* Header/Nav */
.header {
  background: white;
  border-bottom: 1px solid #e2e8f0;
  padding: 16px 0;
  position: sticky;
  top: 0;
  z-index: 100;
}

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

.brand {
  font-size: 20px;
  font-weight: 700;
  color: #0f172a;
  text-decoration: none;
  letter-spacing: -0.025em;
}

.nav-links {
  display: flex;
  gap: 24px;
  align-items: center;
}

.nav-link {
  color: #475569;
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
  transition: color 0.2s;
}

.nav-link:hover {
  color: #0f172a;
}

/* Hero Section (Landing Page) */
.hero {
  padding: 80px 0 60px;
  background: white;
  text-align: center;
}

.hero h1 {
  font-size: 48px;
  line-height: 1.1;
  margin-bottom: 24px;
  color: #0f172a;
  max-width: 800px;
  margin-inline: auto;
}

.hero p {
  font-size: 20px;
  color: #475569;
  margin-bottom: 40px;
  max-width: 600px;
  margin-inline: auto;
}

.hero-actions {
  display: flex;
  gap: 16px;
  justify-content: center;
}

/* Feature Grid */
.features {
  padding: 80px 0;
  background: #f8fafc;
}

.feature-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 32px;
  margin-top: 48px;
}

.feature-card {
  background: white;
  padding: 32px;
  border-radius: 12px;
  border: 1px solid #e2e8f0;
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05);
}

.feature-card h3 {
  font-size: 18px;
  margin-bottom: 12px;
}

.feature-card p {
  color: #475569;
  font-size: 15px;
}

/* Forms */
.form-group {
  margin-bottom: 20px;
}

.form-label {
  display: block;
  font-size: 14px;
  font-weight: 500;
  color: #374151;
  margin-bottom: 8px;
}

.form-input {
  width: 100%;
  padding: 10px 14px;
  font-size: 15px;
  color: #111827;
  background: #fff;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  transition: all 0.15s ease-in-out;
}

.form-input:focus {
  outline: none;
  border-color: #2563eb;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 10px 20px;
  font-size: 14px;
  font-weight: 500;
  border-radius: 6px;
  transition: all 0.15s;
  cursor: pointer;
  text-decoration: none;
  border: 1px solid transparent;
}

.btn-primary {
  background: #0f172a;
  color: white;
}

.btn-primary:hover {
  background: #1e293b;
}

.btn-secondary {
  background: white;
  color: #0f172a;
  border-color: #d1d5db;
}

.btn-secondary:hover {
  background: #f3f4f6;
}

.btn-block {
  width: 100%;
}

/* Alerts & Errors */
.alert {
  padding: 12px 16px;
  border-radius: 6px;
  font-size: 14px;
  margin-bottom: 24px;
}

.alert-error {
  background: #fef2f2;
  color: #991b1b;
  border: 1px solid #fecaca;
}

.alert-success {
  background: #f0fdf4;
  color: #166534;
  border: 1px solid #bbf7d0;
}

.error-messages {
  background: #fef2f2;
  border: 1px solid #fecaca;
  border-radius: 6px;
  padding: 16px;
  margin-bottom: 24px;
}

.error-messages h3 {
  color: #991b1b;
  font-size: 14px;
  margin-bottom: 8px;
}

.error-messages ul {
  color: #991b1b;
  font-size: 14px;
  padding-left: 20px;
}

/* Utilities */
.text-center { text-align: center; }
.mb-2 { margin-bottom: 8px; }
.mb-4 { margin-bottom: 16px; }
.mb-6 { margin-bottom: 24px; }
.mb-8 { margin-bottom: 32px; }
.mt-1 { margin-top: 4px; }
.mt-4 { margin-top: 16px; }
.mt-8 { margin-top: 32px; }
.text-muted { color: #6b7280; }
.text-sm { font-size: 14px; }
.flex { display: flex; }
.gap-2 { gap: 8px; }
.justify-between { justify-content: space-between; }
.items-center { align-items: center; }
.p-0 { padding: 0; }

/* Card Components */
.card {
  background: white;
  border-radius: 12px;
  border: 1px solid #e2e8f0;
  padding: 24px;
}

.card-compact {
  padding: 20px;
}

/* Footer */
.footer {
  border-top: 1px solid #e2e8f0;
  padding: 32px 0;
  margin-top: auto;
  background: white;
}

.footer-content {
  display: flex;
  justify-content: space-between;
  align-items: center;
  color: #64748b;
  font-size: 14px;
}

/* ========================================
   Dashboard & Sidebar Styles
   ======================================== */

.dashboard-body {
  background: #f1f5f9;
  margin: 0;
  padding: 0;
}

.dashboard-wrapper {
  display: flex;
  min-height: 100vh;
}

/* Sidebar */
.sidebar {
  width: 260px;
  background: white;
  border-right: 1px solid #e2e8f0;
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  bottom: 0;
  left: 0;
  z-index: 40;
  transition: transform 0.3s ease;
}

.sidebar-header {
  padding: 24px;
  border-bottom: 1px solid #f1f5f9;
}

.sidebar-nav {
  padding: 24px 16px;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 4px;
  overflow-y: auto;
}

.nav-section {
  font-size: 12px;
  font-weight: 700;
  color: #94a3b8;
  letter-spacing: 0.05em;
  padding: 0 16px 8px;
}

.sidebar-link {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  color: #475569;
  text-decoration: none;
  font-weight: 500;
  font-size: 14px;
  border-radius: 8px;
  transition: all 0.2s;
}

.sidebar-link:hover {
  background: #f8fafc;
  color: #0f172a;
}

.sidebar-link.active {
  background: #eff6ff;
  color: #2563eb;
}

.sidebar-footer {
  padding: 24px 16px;
  border-top: 1px solid #f1f5f9;
}

.user-info {
  padding: 0 16px 16px;
}

.user-name {
  font-weight: 600;
  color: #0f172a;
  font-size: 14px;
}

.user-email {
  word-break: break-all;
}

.logout-link {
  color: #ef4444;
}

.logout-link:hover {
  background: #fef2f2;
  color: #b91c1c;
}

/* Dashboard Main Content */
.dashboard-main {
  flex: 1;
  margin-left: 260px;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.dashboard-header {
  background: white;
  padding: 16px 24px;
  border-bottom: 1px solid #e2e8f0;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.page-title {
  margin: 0;
  font-size: 20px;
  color: #0f172a;
  font-weight: 600;
}

/* Profile Dropdown */
.profile-dropdown {
  position: relative;
}

.profile-trigger {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 12px;
  background: white;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s;
}

.profile-trigger:hover {
  background: #f8fafc;
  border-color: #cbd5e1;
}

.profile-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: linear-gradient(135deg, #0ea5e9 0%, #2563eb 100%);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 14px;
}

.profile-info {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  text-align: left;
}

.profile-name {
  font-size: 13px;
  font-weight: 600;
  color: #0f172a;
  line-height: 1.2;
}

.profile-email {
  font-size: 11px;
  color: #64748b;
  line-height: 1.2;
}

.profile-menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  background: white;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
  min-width: 240px;
  opacity: 0;
  visibility: hidden;
  transform: translateY(-10px);
  transition: all 0.2s;
  z-index: 100;
}

.profile-menu.active {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.profile-menu-header {
  padding: 12px 16px;
}

.profile-menu-divider {
  height: 1px;
  background: #e2e8f0;
  margin: 4px 0;
}

.profile-menu-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  color: #475569;
  text-decoration: none;
  font-size: 13px;
  transition: all 0.15s;
}

.profile-menu-item:hover {
  background: #f8fafc;
  color: #0f172a;
}

.profile-menu-item svg {
  flex-shrink: 0;
}

.profile-menu-item-danger {
  color: #ef4444;
}

.profile-menu-item-danger:hover {
  background: #fef2f2;
  color: #dc2626;
}

.dashboard-content {
  padding: 20px 24px;
  flex: 1;
}

/* Mobile Header */
.mobile-header {
  display: none;
  background: white;
  padding: 12px 16px;
  border-bottom: 1px solid #e2e8f0;
  justify-content: space-between;
  align-items: center;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 50;
  box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.mobile-toggle {
  background: transparent;
  border: none;
  font-size: 24px;
  cursor: pointer;
  color: #0f172a;
  padding: 4px 8px;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Table Styles & Responsive */
.table-responsive {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 13px; /* Smaller base font size for tables */
}

th {
  padding: 10px 12px;
  font-weight: 600;
  color: #475569;
  background: #f8fafc;
  border-bottom: 1px solid #e2e8f0;
  white-space: nowrap;
}

td {
  padding: 10px 12px;
  border-bottom: 1px solid #e2e8f0;
  vertical-align: middle;
}

.table-actions {
  display: flex;
  gap: 8px;
  white-space: nowrap;
}

/* Card Improvements */
.card {
  background: white;
  border-radius: 8px; /* Slightly smaller radius */
  border: 1px solid #e2e8f0;
  padding: 16px; /* Reduced padding */
  box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
}

.card-p-0 {
  padding: 0;
}

/* WhatsApp Rotator Form Grid */
.wa-number-grid {
  display: grid;
  grid-template-columns: 1fr 2fr auto;
  gap: 10px;
  align-items: start;
}

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

/* Responsive Profile Dropdown */
@media (max-width: 768px) {
  .profile-info {
    display: none;
  }
  
  .profile-trigger {
    padding: 6px;
  }
  
  .dashboard-header {
    padding: 12px 16px;
  }
}

/* Mobile optimizations */
@media (max-width: 640px) {
  .wa-number-grid {
    grid-template-columns: 1fr;
    gap: 12px;
  }
  
  .wa-actions {
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
  }
  
  .wa-actions button {
    margin-top: 0 !important;
  }
  .dashboard-content {
    padding: 12px 8px;
  }
  
  .card {
    padding: 8px;
  }
  
  td, th {
    padding: 6px 8px;
    font-size: 11px;
  }
  
  /* Hide less important columns on mobile */
  .hide-mobile {
    display: none !important;
  }
  
  /* Make URL columns wrap better on mobile */
  .url-cell {
    max-width: 100px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  
  /* Compact buttons on mobile */
  .btn {
    padding: 6px 12px;
    font-size: 12px;
  }
  
  /* Page title smaller on mobile */
  .page-title {
    font-size: 18px;
  }
  
  h2 {
    font-size: 18px;
  }
}

/* Responsive Dashboard */
@media (max-width: 768px) {
  .mobile-header {
    display: flex;
  }
  
  .dashboard-wrapper {
    padding-top: 56px; /* Height of mobile header */
  }
  
  .sidebar {
    transform: translateX(-100%);
    top: 56px; /* Below mobile header */
    height: calc(100vh - 56px);
  }
  
  .sidebar.active {
    transform: translateX(0);
    box-shadow: 0 0 0 10000px rgba(0,0,0,0.5);
  }
  
  .dashboard-main {
    margin-left: 0;
  }
  
  .dashboard-header {
    padding: 12px 16px;
  }
}
