/* ===== CSS Variables & Reset ===== */
:root {
  --primary: #53F6D2;
  --primary-dark: #2BB5C1;
  --secondary: #0B0E14;
  --background: #0B0E14;
  --surface: #0F1520;
  --surface-light: #161E2E;
  --surface-hover: #1E2840;
  --text-primary: #ffffff;
  --text-secondary: #8E95A2;
  --text-muted: #5A6170;
  --border: #1E2A3A;
  --success: #10B981;
  --error: #EF4444;
  --warning: #F59E0B;
  --linkedin: #0077B5;
  --linkedin-dark: #005885;
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --radius-xl: 24px;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.5);
  --transition: 0.2s ease;
}

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

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--background);
  color: var(--text-primary);
  line-height: 1.6;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

::-webkit-scrollbar { width: 8px; }
::-webkit-scrollbar-track { background: var(--surface); }
::-webkit-scrollbar-thumb { background: var(--surface-light); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--surface-hover); }
::selection { background: var(--primary); color: var(--secondary); }

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

.main {
  flex: 1;
  padding: 2rem 0 4rem;
}

.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 1.5rem;
}

.footer {
  background: var(--surface);
  border-top: 1px solid var(--border);
  padding: 1.5rem;
  text-align: center;
}

.footer p {
  color: var(--text-muted);
  font-size: 0.875rem;
}

/* ===== Header ===== */
.header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
}

.header-container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0.875rem 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.logo {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.logo-icon {
  width: 36px;
  height: 36px;
  background: var(--primary);
  color: var(--secondary);
  font-weight: 700;
  font-size: 0.875rem;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-md);
}

.logo-text {
  font-weight: 600;
  font-size: 1.125rem;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 1.5rem;
}

.user-info {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--text-secondary);
  font-size: 0.875rem;
}

.btn-logout {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-secondary);
  padding: 0.5rem 1rem;
  border-radius: var(--radius-md);
  cursor: pointer;
  font-size: 0.875rem;
  text-decoration: none;
  font-family: inherit;
  transition: var(--transition);
}

.btn-logout:hover {
  background: var(--surface-light);
  color: var(--text-primary);
  border-color: var(--surface-hover);
}

/* ===== Hero ===== */
.hero {
  text-align: center;
  padding: 2rem 1.5rem 3rem;
}

.hero-content {
  max-width: 600px;
  margin: 0 auto;
}

.hero-title {
  font-size: 2.5rem;
  font-weight: 700;
  margin-bottom: 0.75rem;
  background: linear-gradient(135deg, var(--text-primary) 0%, var(--primary) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.hero-subtitle {
  font-size: 1.125rem;
  color: var(--text-secondary);
  max-width: 480px;
  margin: 0 auto;
}

.invite-badge {
  margin-top: 1rem;
  font-size: 0.9375rem;
  color: var(--text-muted);
}

.invite-badge strong {
  color: var(--primary);
}

/* ===== Error Banner ===== */
.error-banner {
  background: rgba(239, 68, 68, 0.1);
  border: 1px solid var(--error);
  border-radius: var(--radius-md);
  padding: 0.875rem 1.25rem;
  margin-bottom: 1.5rem;
  color: var(--error);
  font-size: 0.9375rem;
}

/* ===== Login Card ===== */
.login-card {
  max-width: 420px;
  margin: 0 auto;
  background: var(--surface);
  border-radius: var(--radius-xl);
  border: 1px solid var(--border);
  overflow: hidden;
}

.login-content {
  padding: 3rem 2.5rem;
  text-align: center;
}

.login-icon {
  width: 64px;
  height: 64px;
  background: var(--linkedin);
  color: white;
  border-radius: var(--radius-lg);
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 1.5rem;
}

.login-content h2 {
  font-size: 1.5rem;
  font-weight: 600;
  margin-bottom: 0.5rem;
}

.login-content p {
  color: var(--text-secondary);
  margin-bottom: 2rem;
  font-size: 0.9375rem;
}

/* ===== Buttons ===== */
.btn-primary {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  width: 100%;
  padding: 0.875rem 1.5rem;
  background: var(--primary);
  color: var(--secondary);
  border: none;
  border-radius: var(--radius-md);
  font-weight: 600;
  font-size: 0.9375rem;
  cursor: pointer;
  transition: var(--transition);
  font-family: inherit;
}

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

.btn-primary:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-secondary {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  width: 100%;
  padding: 0.875rem 1.5rem;
  background: var(--surface-light);
  color: var(--text-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  font-weight: 500;
  font-size: 0.9375rem;
  cursor: pointer;
  transition: var(--transition);
  font-family: inherit;
}

.btn-secondary:hover:not(:disabled) {
  background: var(--surface-hover);
}

.btn-secondary:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-linkedin {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  width: 100%;
  padding: 0.875rem 2rem;
  background: var(--linkedin);
  color: white;
  border: none;
  border-radius: var(--radius-md);
  font-weight: 500;
  font-size: 1rem;
  cursor: pointer;
  text-decoration: none;
  transition: var(--transition);
  font-family: inherit;
}

.btn-linkedin:hover:not(:disabled) {
  background: var(--linkedin-dark);
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}

.btn-linkedin:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-icon {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 0.5rem;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
}

.btn-icon:hover {
  background: var(--surface-light);
  color: var(--text-primary);
}

.btn-generate { margin-top: 1.5rem; }
.btn-post { margin-top: 1rem; }

/* Spinner */
.spinner {
  width: 40px;
  height: 40px;
  border: 3px solid var(--surface-light);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

.spinner-small {
  display: inline-block;
  width: 20px;
  height: 20px;
  border: 2px solid rgba(0, 0, 0, 0.2);
  border-top-color: var(--secondary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

.loading-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--background);
}

/* ===== Dashboard ===== */
.dashboard { margin-top: 1rem; }

.dashboard-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  overflow: hidden;
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--border);
}

.panel-header h3 {
  font-size: 1rem;
  font-weight: 600;
}

.panel-content { padding: 1.5rem; }

/* Source Tabs */
.source-tabs {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1.5rem;
}

.source-tab {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.75rem;
  background: var(--surface-light);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 0.875rem;
  font-family: inherit;
  transition: var(--transition);
}

.source-tab:hover { background: var(--surface-hover); color: var(--text-primary); }

.source-tab.active {
  background: var(--primary);
  border-color: var(--primary);
  color: var(--secondary);
  font-weight: 500;
}

/* Upload Zone */
.upload-zone {
  border: 2px dashed var(--border);
  border-radius: var(--radius-lg);
  padding: 2rem;
  text-align: center;
  cursor: pointer;
  transition: var(--transition);
  min-height: 200px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.upload-zone:hover, .upload-zone.drag-active {
  border-color: var(--primary);
  background: rgba(83, 246, 210, 0.03);
}

.upload-placeholder { color: var(--text-muted); }
.upload-placeholder svg { margin-bottom: 1rem; opacity: 0.5; }
.upload-placeholder p { margin-bottom: 0.25rem; color: var(--text-secondary); }
.upload-placeholder span { font-size: 0.8125rem; }
.upload-preview { max-width: 100%; max-height: 200px; border-radius: var(--radius-md); object-fit: contain; }

/* Profile Section */
.profile-section { text-align: center; }
.profile-hint { color: var(--text-secondary); margin-bottom: 1.5rem; font-size: 0.9375rem; }
.profile-preview { display: block; margin: 1.5rem auto 0; max-width: 150px; border-radius: 50%; }

/* Brochure Preview */
.brochure-preview-container {
  background: var(--surface-light);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  min-height: 250px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.brochure-preview { max-width: 100%; max-height: 300px; border-radius: var(--radius-md); object-fit: contain; }

.preview-placeholder { text-align: center; color: var(--text-muted); }
.preview-placeholder svg { margin-bottom: 1rem; opacity: 0.3; }
.preview-placeholder p { font-size: 0.9375rem; }

/* Post Section */
.post-section { margin-top: 1.5rem; }
.post-section label { display: block; font-size: 0.875rem; font-weight: 500; margin-bottom: 0.5rem; color: var(--text-secondary); }

.post-section textarea {
  width: 100%;
  padding: 0.875rem;
  background: var(--surface-light);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-family: inherit;
  font-size: 0.9375rem;
  resize: vertical;
  transition: var(--transition);
}

.post-section textarea:focus { outline: none; border-color: var(--primary); }
.post-section textarea::placeholder { color: var(--text-muted); }

/* ===== Toast ===== */
.toast {
  position: fixed;
  bottom: 2rem;
  right: 2rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 1rem 1.25rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  animation: slideIn 0.3s ease;
  z-index: 1000;
}

.toast.toast-success { border-left: 3px solid var(--success); }
.toast.toast-error { border-left: 3px solid var(--error); }
.toast span { font-size: 0.9375rem; }

.toast-close {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 0.25rem;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-left: 0.5rem;
  border-radius: var(--radius-sm);
  transition: var(--transition);
}

.toast-close:hover { background: var(--surface-light); color: var(--text-primary); }

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

/* ===== Admin Styles ===== */
.admin-logo-icon {
  background: var(--primary) !important;
  color: var(--secondary) !important;
}

/* Admin Login */
.admin-login-wrapper {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 60vh;
}

.admin-login-card {
  max-width: 420px;
  width: 100%;
  background: var(--surface);
  border-radius: var(--radius-xl);
  border: 1px solid var(--border);
  overflow: hidden;
}

.admin-login-header {
  padding: 2.5rem 2.5rem 0;
  text-align: center;
}

.admin-login-icon {
  width: 64px;
  height: 64px;
  background: var(--primary);
  color: var(--secondary);
  border-radius: var(--radius-lg);
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 1.5rem;
}

.admin-login-header h2 { font-size: 1.5rem; font-weight: 600; margin-bottom: 0.5rem; color: var(--text-primary); }
.admin-login-header p { color: var(--text-secondary); font-size: 0.9375rem; }

/* Forms */
.admin-login-form { padding: 2rem 2.5rem; }

.form-group { margin-bottom: 1.25rem; }

.form-group label {
  display: block;
  font-size: 0.875rem;
  font-weight: 500;
  margin-bottom: 0.5rem;
  color: var(--text-secondary);
}

.form-group input,
.form-group select {
  width: 100%;
  padding: 0.75rem 1rem;
  background: var(--surface-light);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-family: inherit;
  font-size: 0.9375rem;
  transition: var(--transition);
}

.form-group input:focus,
.form-group select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(83, 246, 210, 0.1);
}

.form-group input::placeholder { color: var(--text-muted); }

.form-group select {
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg width='12' height='8' viewBox='0 0 12 8' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 1L6 6L11 1' stroke='%239ca3af' stroke-width='2' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 1rem center;
  padding-right: 2.5rem;
}

.form-group select option { background: var(--surface); color: var(--text-primary); }

.btn-admin-submit { margin-top: 0.5rem; }

.admin-login-toggle {
  padding: 1.5rem 2.5rem;
  text-align: center;
  border-top: 1px solid var(--border);
}

.admin-login-toggle p { color: var(--text-secondary); font-size: 0.875rem; }

.admin-login-toggle button {
  background: none;
  border: none;
  color: var(--primary);
  font-weight: 600;
  cursor: pointer;
  font-size: 0.875rem;
  padding: 0;
  font-family: inherit;
  transition: var(--transition);
}

.admin-login-toggle button:hover { color: var(--primary-dark); text-decoration: underline; }

/* Admin Dashboard */
.admin-welcome { text-align: center; margin-bottom: 2rem; }

.admin-welcome h2 {
  font-size: 1.75rem;
  font-weight: 700;
  background: linear-gradient(135deg, var(--text-primary), var(--primary));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.admin-welcome p { color: var(--text-secondary); margin-top: 0.25rem; }

.admin-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
  margin-bottom: 1.5rem;
}

.admin-list-panel { margin-bottom: 1.5rem; }

.empty-state { text-align: center; padding: 2rem 1rem; color: var(--text-muted); }
.empty-state svg { margin-bottom: 1rem; opacity: 0.3; }
.empty-state p { font-size: 0.9375rem; }

/* Admin Table */
.admin-table-wrapper { overflow-x: auto; }

.admin-table { width: 100%; border-collapse: collapse; }

.admin-table th {
  text-align: left;
  padding: 0.75rem 1rem;
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border-bottom: 1px solid var(--border);
}

.admin-table td {
  padding: 0.75rem 1rem;
  font-size: 0.9375rem;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

.admin-table tbody tr:last-child td { border-bottom: none; }
.admin-table tbody tr:hover { background: var(--surface-light); }

.template-thumb { width: 60px; height: 40px; object-fit: cover; border-radius: var(--radius-sm); border: 1px solid var(--border); }
.template-name { font-weight: 500; }
.template-date { color: var(--text-secondary); font-size: 0.875rem; }
.link-label { font-weight: 500; }
.link-uses { color: var(--text-secondary); text-align: center; }

.link-url-cell { display: flex; align-items: center; gap: 0.5rem; }

.link-url {
  font-size: 0.75rem;
  color: var(--text-secondary);
  background: var(--surface-light);
  padding: 0.25rem 0.5rem;
  border-radius: var(--radius-sm);
  max-width: 280px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  display: block;
}

.btn-copy {
  background: var(--surface-light);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  cursor: pointer;
  padding: 0.375rem;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
  flex-shrink: 0;
}

.btn-copy:hover { background: var(--primary); border-color: var(--primary); color: var(--secondary); }

.btn-delete {
  background: transparent;
  border: 1px solid transparent;
  color: var(--text-muted);
  cursor: pointer;
  padding: 0.375rem;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
}

.btn-delete:hover { background: rgba(239, 68, 68, 0.1); border-color: var(--error); color: var(--error); }

/* ===== Responsive ===== */
@media (max-width: 900px) {
  .dashboard-grid, .admin-grid { grid-template-columns: 1fr; }
}

@media (max-width: 768px) {
  .container { padding: 0 1rem; }
  .main { padding: 1.5rem 0 3rem; }
}

@media (max-width: 640px) {
  .logo-text { display: none; }
  .btn-logout span { display: none; }
  .btn-logout { padding: 0.5rem; }
  .hero-title { font-size: 1.75rem; }
  .hero-subtitle { font-size: 1rem; }
  .hero { padding: 1.5rem 1rem 2rem; }
}

@media (max-width: 600px) {
  .admin-login-form { padding: 1.5rem; }
  .admin-login-header { padding: 2rem 1.5rem 0; }
  .admin-login-toggle { padding: 1.25rem 1.5rem; }
  .admin-table th, .admin-table td { padding: 0.5rem 0.75rem; font-size: 0.8125rem; }
  .link-url { max-width: 150px; }
}

@media (max-width: 480px) {
  .panel-content { padding: 1rem; }
  .source-tab { padding: 0.625rem; font-size: 0.8125rem; }
  .upload-zone { min-height: 160px; padding: 1.5rem; }
  .login-content { padding: 2rem 1.5rem; }
  .toast { left: 1rem; right: 1rem; bottom: 1rem; }
}

/* Utility */
.text-center { text-align: center; }
.text-muted { color: var(--text-muted); }
.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.mt-4 { margin-top: 2rem; }
