/* Facebook Design System - AdForge AI Theme */

/* ============================================
   COLOR SYSTEM - CSS Variables
   ============================================ */
:root {
  /* Facebook Brand Colors */
  --fb-blue: #1877F2;
  --fb-blue-hover: #166FE5;
  --fb-blue-active: #1564D1;
  --fb-green: #42B72A;
  --fb-green-hover: #36A420;
  --fb-red: #EB1C23;
  --fb-red-hover: #D41119;
  
  /* Light Mode Colors */
  --fb-bg-primary: #F0F2F5;
  --fb-bg-secondary: #FFFFFF;
  --fb-bg-tertiary: #F8F9FA;
  --fb-text-primary: #1C1E21;
  --fb-text-secondary: #65676B;
  --fb-text-tertiary: #8A8D91;
  --fb-border: #CED0D4;
  --fb-divider: #DADDE1;
  --fb-hover-overlay: rgba(0, 0, 0, 0.05);
  --fb-active-overlay: rgba(0, 0, 0, 0.1);
  --fb-shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.1);
  --fb-shadow-md: 0 2px 4px rgba(0, 0, 0, 0.1);
  --fb-shadow-lg: 0 12px 28px rgba(0, 0, 0, 0.12);
  
  /* Glass Effect Variables */
  --glass-bg: rgba(255, 255, 255, 0.85);
  --glass-border: rgba(255, 255, 255, 0.3);
  --glass-blur: 10px;
  
  /* Transition Variables */
  --transition-fast: 150ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-base: 250ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-slow: 350ms cubic-bezier(0.4, 0, 0.2, 1);
  
  /* Border Radius */
  --radius-sm: 4px;
  --radius-md: 6px;
  --radius-lg: 8px;
  --radius-xl: 12px;
  --radius-pill: 20px;
}

/* Dark Mode Variables */
[data-theme="dark"], body.dark-mode {
  --fb-bg-primary: #18191A;
  --fb-bg-secondary: #242526;
  --fb-bg-tertiary: #3A3B3C;
  --fb-text-primary: #E4E6EB;
  --fb-text-secondary: #B0B3B8;
  --fb-text-tertiary: #8A8D91;
  --fb-border: #3E4042;
  --fb-divider: #3E4042;
  --fb-hover-overlay: rgba(255, 255, 255, 0.05);
  --fb-active-overlay: rgba(255, 255, 255, 0.1);
  --fb-shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
  --fb-shadow-md: 0 2px 4px rgba(0, 0, 0, 0.3);
  --fb-shadow-lg: 0 12px 28px rgba(0, 0, 0, 0.4);
  
  /* Glass Effect for Dark Mode */
  --glass-bg: rgba(36, 37, 38, 0.85);
  --glass-border: rgba(255, 255, 255, 0.1);
}

/* ============================================
   TYPOGRAPHY
   ============================================ */
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  font-size: 15px;
  line-height: 1.5;
  color: var(--fb-text-primary);
  background-color: var(--fb-bg-primary);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

h1, h2, h3, h4, h5, h6 {
  font-weight: 600;
  line-height: 1.3;
  color: var(--fb-text-primary);
}

h1 { font-size: 28px; }
h2 { font-size: 24px; }
h3 { font-size: 20px; }
h4 { font-size: 17px; }
h5 { font-size: 15px; }
h6 { font-size: 13px; }

.text-secondary {
  color: var(--fb-text-secondary);
}

.text-small {
  font-size: 13px;
  color: var(--fb-text-tertiary);
}

/* ============================================
   BUTTONS
   ============================================ */
.btn {
  font-family: inherit;
  font-size: 15px;
  font-weight: 600;
  padding: 0 16px;
  height: 36px;
  border-radius: var(--radius-md);
  border: none;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: all var(--transition-fast);
  outline: none;
  position: relative;
  overflow: hidden;
}

.btn:focus-visible {
  box-shadow: 0 0 0 2px var(--fb-blue);
}

.btn-primary {
  background-color: var(--fb-blue);
  color: white;
}

.btn-primary:hover {
  background-color: var(--fb-blue-hover);
}

.btn-primary:active {
  background-color: var(--fb-blue-active);
  transform: scale(0.98);
}

.btn-secondary {
  background-color: var(--fb-bg-tertiary);
  color: var(--fb-text-primary);
  border: 1px solid var(--fb-border);
}

.btn-secondary:hover {
  background-color: var(--fb-hover-overlay);
}

.btn-success {
  background-color: var(--fb-green);
  color: white;
}

.btn-success:hover {
  background-color: var(--fb-green-hover);
}

.btn-danger {
  background-color: var(--fb-red);
  color: white;
}

.btn-danger:hover {
  background-color: var(--fb-red-hover);
}

.btn-large {
  height: 40px;
  padding: 0 24px;
  font-size: 17px;
}

.btn-small {
  height: 32px;
  padding: 0 12px;
  font-size: 13px;
}

/* ============================================
   CARDS & CONTAINERS
   ============================================ */
.card {
  background-color: var(--fb-bg-secondary);
  border-radius: var(--radius-lg);
  box-shadow: var(--fb-shadow-sm);
  border: 1px solid var(--fb-border);
  overflow: hidden;
  transition: all var(--transition-base);
}

.card:hover {
  box-shadow: var(--fb-shadow-md);
}

.card-header {
  padding: 16px;
  border-bottom: 1px solid var(--fb-divider);
  background-color: var(--fb-bg-secondary);
}

.card-body {
  padding: 16px;
}

.card-footer {
  padding: 12px 16px;
  border-top: 1px solid var(--fb-divider);
  background-color: var(--fb-bg-tertiary);
}

/* Glass Morphism Effect */
.glass {
  background: var(--glass-bg);
  backdrop-filter: blur(var(--glass-blur));
  -webkit-backdrop-filter: blur(var(--glass-blur));
  border: 1px solid var(--glass-border);
}

.glass:hover {
  background: var(--glass-bg);
  box-shadow: var(--fb-shadow-lg);
}

/* ============================================
   FORM ELEMENTS
   ============================================ */
input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
textarea,
select {
  font-family: inherit;
  font-size: 15px;
  padding: 8px 12px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--fb-border);
  background-color: var(--fb-bg-tertiary);
  color: var(--fb-text-primary);
  transition: all var(--transition-fast);
  outline: none;
  width: 100%;
}

input:focus,
textarea:focus,
select:focus {
  border-color: var(--fb-blue);
  box-shadow: 0 0 0 3px rgba(24, 119, 242, 0.1);
}

input::placeholder,
textarea::placeholder {
  color: var(--fb-text-tertiary);
}

/* Search Input */
.search-input {
  background-color: var(--fb-bg-tertiary);
  border-radius: var(--radius-pill);
  padding: 8px 12px 8px 40px;
  border: none;
}

/* Checkbox and Radio */
input[type="checkbox"],
input[type="radio"] {
  width: 20px;
  height: 20px;
  cursor: pointer;
}

/* ============================================
   NAVIGATION
   ============================================ */
.nav {
  background-color: var(--fb-bg-secondary);
  box-shadow: var(--fb-shadow-sm);
  border-bottom: 1px solid var(--fb-divider);
}

.nav-item {
  padding: 8px 16px;
  color: var(--fb-text-secondary);
  text-decoration: none;
  font-weight: 500;
  border-radius: var(--radius-md);
  transition: all var(--transition-fast);
  cursor: pointer;
  position: relative;
}

.nav-item:hover {
  background-color: var(--fb-hover-overlay);
  color: var(--fb-text-primary);
}

.nav-item.active {
  color: var(--fb-blue);
}

.nav-item.active::after {
  content: '';
  position: absolute;
  bottom: -1px;
  left: 0;
  right: 0;
  height: 3px;
  background-color: var(--fb-blue);
  border-radius: 3px 3px 0 0;
}

/* ============================================
   BADGES
   ============================================ */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: var(--radius-pill);
  font-size: 12px;
  font-weight: 600;
  line-height: 1;
}

.badge-primary {
  background-color: var(--fb-blue);
  color: white;
}

.badge-success {
  background-color: var(--fb-green);
  color: white;
}

.badge-danger {
  background-color: var(--fb-red);
  color: white;
}

.badge-secondary {
  background-color: var(--fb-bg-tertiary);
  color: var(--fb-text-secondary);
}

/* ============================================
   MODALS
   ============================================ */
.modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: rgba(0, 0, 0, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  opacity: 0;
  visibility: hidden;
  transition: all var(--transition-base);
}

.modal.show {
  opacity: 1;
  visibility: visible;
}

.modal-content {
  background-color: var(--fb-bg-secondary);
  border-radius: var(--radius-xl);
  box-shadow: var(--fb-shadow-lg);
  max-width: 500px;
  width: 90%;
  max-height: 90vh;
  overflow-y: auto;
  transform: scale(0.9);
  transition: transform var(--transition-base);
}

.modal.show .modal-content {
  transform: scale(1);
}

.modal-header {
  padding: 16px 24px;
  border-bottom: 1px solid var(--fb-divider);
}

.modal-body {
  padding: 24px;
}

.modal-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--fb-divider);
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

/* ============================================
   LOADING & ANIMATIONS
   ============================================ */
.spinner {
  width: 32px;
  height: 32px;
  border: 3px solid var(--fb-border);
  border-top-color: var(--fb-blue);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

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

.skeleton {
  background: linear-gradient(90deg, 
    var(--fb-bg-tertiary) 25%, 
    var(--fb-hover-overlay) 50%, 
    var(--fb-bg-tertiary) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
}

@keyframes shimmer {
  0% { background-position: -200% 0; }
  100% { background-position: 200% 0; }
}

/* ============================================
   UTILITIES
   ============================================ */
.text-center { text-align: center; }
.text-left { text-align: left; }
.text-right { text-align: right; }

.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; }

.p-1 { padding: 8px; }
.p-2 { padding: 16px; }
.p-3 { padding: 24px; }

.shadow-sm { box-shadow: var(--fb-shadow-sm); }
.shadow-md { box-shadow: var(--fb-shadow-md); }
.shadow-lg { box-shadow: var(--fb-shadow-lg); }

.hidden { display: none !important; }
.flex { display: flex; }
.flex-center { display: flex; align-items: center; justify-content: center; }
.flex-between { display: flex; justify-content: space-between; align-items: center; }

/* ============================================
   RESPONSIVE
   ============================================ */
@media (max-width: 768px) {
  body { font-size: 14px; }
  h1 { font-size: 24px; }
  h2 { font-size: 20px; }
  h3 { font-size: 18px; }
  
  .btn { height: 32px; font-size: 14px; }
  .btn-large { height: 36px; font-size: 15px; }
  
  .card { border-radius: var(--radius-md); }
}

/* ============================================
   TRANSITIONS & HOVER EFFECTS
   ============================================ */
* {
  transition: background-color var(--transition-fast),
              border-color var(--transition-fast),
              box-shadow var(--transition-fast),
              transform var(--transition-fast);
}

/* Micro-interactions */
button:active,
.btn:active {
  transform: scale(0.98);
}

.card {
  transition: transform var(--transition-base), box-shadow var(--transition-base);
}

.card:hover {
  transform: translateY(-2px);
}

/* Smooth hover for interactive elements */
a, button, .btn, .nav-item, input, textarea, select {
  transition: all var(--transition-fast);
}

/* Icon animations */
svg {
  transition: transform var(--transition-fast), color var(--transition-fast);
}

button:hover svg,
.btn:hover svg {
  transform: translateX(2px);
}

/* Pulse animation for notifications */
@keyframes pulse {
  0% { transform: scale(1); }
  50% { transform: scale(1.05); }
  100% { transform: scale(1); }
}

.notification-badge {
  animation: pulse 2s infinite;
}

/* Fade in animation */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

.fade-in {
  animation: fadeIn var(--transition-base) ease-out;
}

/* Slide animations */
@keyframes slideInLeft {
  from { transform: translateX(-100%); }
  to { transform: translateX(0); }
}

@keyframes slideInRight {
  from { transform: translateX(100%); }
  to { transform: translateX(0); }
}

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

.slide-in-left { animation: slideInLeft var(--transition-slow) ease-out; }
.slide-in-right { animation: slideInRight var(--transition-slow) ease-out; }
.slide-in-up { animation: slideInUp var(--transition-slow) ease-out; }

/* Input focus effects */
input:focus,
textarea:focus,
select:focus {
  transform: translateY(-1px);
}

/* Link hover effects */
a:not(.btn):hover {
  color: var(--fb-blue);
}

/* Checkbox and radio animations */
input[type="checkbox"],
input[type="radio"] {
  transition: transform var(--transition-fast);
}

input[type="checkbox"]:checked,
input[type="radio"]:checked {
  transform: scale(1.1);
}

/* Loading state animations */
.loading {
  position: relative;
  pointer-events: none;
  opacity: 0.7;
}

.loading::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 20px;
  height: 20px;
  margin: -10px 0 0 -10px;
  border: 2px solid var(--fb-blue);
  border-top-color: transparent;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

/* Ripple effect */
@keyframes ripple {
  0% {
    transform: scale(0);
    opacity: 1;
  }
  100% {
    transform: scale(4);
    opacity: 0;
  }
}

.ripple {
  position: relative;
  overflow: hidden;
}

.ripple::before {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 0;
  height: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.5);
  transform: translate(-50%, -50%);
  transition: width 0.6s, height 0.6s;
}

.ripple:active::before {
  width: 300px;
  height: 300px;
}

/* Preserve existing glass hover effect */
.glass-hover:hover {
  backdrop-filter: blur(15px);
  background: rgba(255, 255, 255, 0.95);
}

[data-theme="dark"] .glass-hover:hover,
body.dark-mode .glass-hover:hover {
  backdrop-filter: blur(15px);
  background: rgba(36, 37, 38, 0.95);
}

/* Dark Mode Specific Components */
[data-theme="dark"] .btn-primary,
body.dark-mode .btn-primary {
  background-color: var(--fb-blue);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
}

[data-theme="dark"] .btn-primary:hover,
body.dark-mode .btn-primary:hover {
  background-color: var(--fb-blue-hover);
  box-shadow: 0 2px 8px rgba(24, 119, 242, 0.2);
}

[data-theme="dark"] .card,
body.dark-mode .card {
  background-color: var(--fb-bg-secondary);
  border-color: var(--fb-border);
}

[data-theme="dark"] input,
[data-theme="dark"] textarea,
[data-theme="dark"] select,
body.dark-mode input,
body.dark-mode textarea,
body.dark-mode select {
  background-color: var(--fb-bg-tertiary);
  border-color: var(--fb-border);
  color: var(--fb-text-primary);
}

[data-theme="dark"] input:focus,
[data-theme="dark"] textarea:focus,
[data-theme="dark"] select:focus,
body.dark-mode input:focus,
body.dark-mode textarea:focus,
body.dark-mode select:focus {
  border-color: var(--fb-blue);
  box-shadow: 0 0 0 3px rgba(24, 119, 242, 0.15);
}

/* Dark Mode Scrollbar */
[data-theme="dark"]::-webkit-scrollbar,
body.dark-mode::-webkit-scrollbar {
  width: 12px;
  height: 12px;
}

[data-theme="dark"]::-webkit-scrollbar-track,
body.dark-mode::-webkit-scrollbar-track {
  background: var(--fb-bg-primary);
}

[data-theme="dark"]::-webkit-scrollbar-thumb,
body.dark-mode::-webkit-scrollbar-thumb {
  background: var(--fb-bg-tertiary);
  border-radius: 6px;
  border: 2px solid var(--fb-bg-primary);
}

[data-theme="dark"]::-webkit-scrollbar-thumb:hover,
body.dark-mode::-webkit-scrollbar-thumb:hover {
  background: var(--fb-border);
}