/* Design Tokens from design.md */
:root {
  /* Colors */
  --bg-app: #EAF2FF;
  --bg-canvas: #F9FAFB;
  --surface: #FFFFFF;
  --border: #E5E7EB;
  --text-primary: #111827;
  --text-secondary: #6B7280;
  --primary: #3B82F6;
  --primary-700: #2563EB;
  --success: #10B981;
  --danger: #EF4444;
  --toolbar: #111827;
  --toolbar-icon: #D1D5DB;
  --toolbar-icon-active: #FFFFFF;
  --focus: #93C5FD;

  /* Radii */
  --radius-lg: 16px;
  --radius-md: 12px;
  --radius-sm: 8px;
  --radius-pill: 999px;

  /* Shadows */
  --shadow-0: none;
  --shadow-1: 0 1px 2px rgba(0,0,0,0.06);
  --shadow-2: 0 8px 20px rgba(0,0,0,0.08);
  --shadow-focus: 0 0 0 3px var(--focus);

  /* Typography */
  --fs-title: 16px;
  --fs-label: 14px;
  --fs-ui: 13px;
  --line-height-title: 24px;
  --line-height-label: 20px;
  --line-height-ui: 18px;
}

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

body {
  font-family: 'Inter', ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, sans-serif;
  background-color: var(--bg-app);
  color: var(--text-primary);
  line-height: 1.5;
}

/* App Container */
.app {
    display: grid;
    grid-template-columns: 280px 1fr;
    grid-template-rows: 1fr;
    grid-template-areas: "sidebar main";
    height: 100vh;
    overflow: hidden;
}

.app.sidebar-hidden {
    grid-template-columns: 1fr;
    grid-template-areas: "main";
}

.sidebar {
    grid-area: sidebar;
    background-color: var(--surface);
    border-right: 1px solid var(--border);
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.sidebar-search {
    padding: 24px;
    background-color: #F9FAFB; /* Slightly darker background */
    border-bottom: 1px solid var(--border);
}

.sidebar-title {
    font-size: 20px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 16px;
}

.search-input-wrapper {
    position: relative;
}

.client-id-input {
    width: 100%;
    padding: 10px 40px 10px 16px;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    font-size: 14px;
    background-color: var(--surface);
    transition: all 0.2s ease;
}

.client-id-input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: var(--shadow-focus);
}

.search-icon-btn {
    position: absolute;
    right: 4px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    font-size: 18px;
    cursor: pointer;
    color: var(--text-secondary);
    padding: 6px;
}

.search-icon-btn:hover {
    color: var(--primary);
}

.sidebar-nav-content {
    overflow-y: auto;
    padding: 24px 32px;
    flex: 1;
}

.sidebar-nav {
    list-style: none;
    padding: 0;
    margin: 0;
}

.sidebar-item {
    margin-bottom: 8px;
}

.sidebar-link {
    text-decoration: none;
    color: var(--text-secondary);
    transition: color 0.2s ease;
    display: block;
    padding: 4px 0;
}

.sidebar-link:hover {
    color: var(--primary);
}

.sidebar-section-title {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 16px;
}

.pillar-link {
    font-weight: 600;
    color: var(--text-primary);
    font-size: var(--fs-label);
}

/* Header */
.header {
  display: none;
}

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

.header-title {
  font-size: 24px;
  font-weight: 600;
  color: var(--text-primary);
}

.header-actions {
  display: flex;
  gap: 12px;
  align-items: center;
}

.client-id-input {
  min-width: auto;
  width: 100%;
  transition: border-color 0.2s ease;
}

.client-id-input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: var(--shadow-focus);
}

.load-btn {
  padding: 8px 16px;
  background-color: var(--primary);
  color: white;
  border: none;
  border-radius: var(--radius-md);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: background-color 0.2s ease;
}

.load-btn:hover {
  background-color: var(--primary-700);
}

.load-btn:active {
  transform: translateY(1px);
}

/* Main Content */
.main-content {
  grid-area: main;
  overflow-y: auto;
  display: flex;
  justify-content: center;
  align-items: center;
}

.app.content-loaded .main-content {
  align-items: flex-start;
}

.main-content-inner {
    max-width: 1200px;
    margin: 0 auto;
    padding: 24px;
}

#initialState {
    text-align: center;
    max-width: 500px;
    padding: 40px;
    background-color: var(--surface);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-2);
    animation: fadeIn 0.5s ease-out;
}

#initialState h1 {
    font-size: 24px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 8px;
}

#initialState p {
    font-size: var(--fs-label);
    color: var(--text-secondary);
    margin-bottom: 24px;
}

/* Client Info */
.client-info {
  margin-bottom: 24px;
}

.client-card {
  background-color: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  box-shadow: var(--shadow-1);
}

.client-name {
  font-size: var(--fs-title);
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 8px;
}

.client-meta {
  font-size: var(--fs-label);
  color: var(--text-secondary);
}

/* Loading State */
.loading-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 48px;
  gap: 16px;
}

.loading-spinner {
  width: 40px;
  height: 40px;
  border: 3px solid var(--border);
  border-top: 3px solid var(--primary);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

/* Error State */
.error-state {
  text-align: center;
  padding: 48px;
}

.error-icon {
  font-size: 48px;
  margin-bottom: 16px;
}

.error-state h3 {
  font-size: 20px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 8px;
}

.error-state p {
  color: var(--text-secondary);
}

/* Content Dashboard */
.pillars-container {
  display: grid;
  gap: 24px;
}

/* Pillar Card */
.pillar-card {
  background-color: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  box-shadow: var(--shadow-1);
}

.pillar-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 16px;
}

.pillar-title {
  font-size: var(--fs-title);
  font-weight: 600;
  color: var(--text-primary);
}

.pillar-description {
  font-size: var(--fs-label);
  color: var(--text-secondary);
  margin-top: 4px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 16px;
}

/* Lead Magnet Card */
.lead-magnet-card {
  background-color: var(--bg-canvas);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 16px;
  margin-bottom: 12px;
}

.lead-magnet-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 8px;
  margin-bottom: 8px;
}

.lead-magnet-title {
  font-size: var(--fs-label);
  font-weight: 600;
  color: var(--text-primary);
  flex: 1;
  margin: 0;
}

.status-icons {
  display: flex;
  gap: 8px;
  padding-top: 2px;
}

.status-tag {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  font-weight: 500;
  padding: 2px 8px;
  border-radius: var(--radius-pill);
  white-space: nowrap;
  line-height: 1.4;
}

.status-success {
  color: var(--success);
}

.status-danger {
  color: var(--danger);
}

.status-success-bg {
    background-color: #D1FAE5;
    color: #065F46;
    border-color: #A7F3D0;
}

.status-danger-bg {
    background-color: #FEE2E2;
    color: #991B1B;
    border-color: #FECACA;
}

.lead-magnet-description {
  font-size: var(--fs-ui);
  color: var(--text-secondary);
  margin-bottom: 12px;
}

.lead-magnet-detail {
  font-size: var(--fs-ui);
  color: var(--text-secondary);
  margin-top: 12px;
}

.lead-magnet-detail .detail-label {
  font-weight: 600;
  color: var(--text-primary);
  display: block;
  margin-bottom: 4px;
}

.lead-magnet-detail p {
  margin: 0;
  padding: 0;
  line-height: 1.5;
}

.lead-magnet-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.emails-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.email-btn {
  padding: 6px 12px;
  background-color: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: var(--fs-ui);
  color: var(--text-primary);
  cursor: pointer;
  transition: all 0.2s ease;
}

.email-btn:hover {
  background-color: var(--primary);
  color: white;
  border-color: var(--primary);
}

/* Modal */
.modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.5);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 1000;
}

.modal-content {
  background-color: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-2);
  max-width: 900px; /* Increased width */
  max-height: 90vh;
  width: 90%;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

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

.modal-title {
  font-size: var(--fs-title);
  font-weight: 600;
  color: var(--text-primary);
}

.copy-btn {
  margin-left: auto;
  margin-right: 16px;
  padding: 6px 12px;
  background-color: var(--bg-canvas);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: var(--fs-ui);
  color: var(--text-primary);
  cursor: pointer;
  transition: all 0.2s ease;
}

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

.close-modal-btn {
  background: none;
  border: none;
  font-size: 24px;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 4px;
  border-radius: var(--radius-sm);
  transition: background-color 0.2s ease;
}

.close-modal-btn:hover {
  background-color: var(--bg-canvas);
  color: var(--text-primary);
}

.modal-body {
    padding: 24px;
    overflow-y: auto;
    flex: 1;
}

.markdown-content {
    padding: 0;
}

.markdown-content h1,
.markdown-content h2,
.markdown-content h3,
.markdown-content h4,
.markdown-content h5,
.markdown-content h6 {
  margin-top: 24px;
  margin-bottom: 16px;
  font-weight: 600;
  line-height: 1.3;
}

.markdown-content h1 { font-size: 28px; }
.markdown-content h2 { font-size: 24px; }
.markdown-content h3 { font-size: 20px; }
.markdown-content h4 { font-size: 18px; }

.markdown-content p {
  margin-bottom: 16px;
  line-height: 1.6;
}

.markdown-content ul,
.markdown-content ol {
  margin-bottom: 16px;
  padding-left: 24px;
}

.markdown-content li {
  margin-bottom: 8px;
}

.markdown-content blockquote {
  border-left: 4px solid var(--primary);
  padding-left: 16px;
  margin: 24px 0;
  font-style: italic;
  color: var(--text-secondary);
}

.markdown-content code {
  background-color: var(--bg-canvas);
  padding: 3px 6px;
  border-radius: var(--radius-sm);
  font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
  font-size: 14px;
  border: 1px solid var(--border);
}

.markdown-content pre {
  background-color: var(--bg-canvas);
  padding: 16px;
  border-radius: var(--radius-md);
  overflow-x: auto;
  margin: 24px 0;
  border: 1px solid var(--border);
}

.markdown-content pre code {
  background: none;
  padding: 0;
  border: none;
}

/* Email Content */
.email-content {
  line-height: 1.6;
}

.email-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
}

.email-subject {
  font-size: var(--fs-title);
  font-weight: 600;
  color: var(--text-primary);
  margin: 0;
  padding: 0;
  border: none;
}

.email-preheader {
  font-size: var(--fs-label);
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 16px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border);
}

.email-body {
    margin-top: 1em;
    padding-top: 1em;
    border-top: 1px solid #e5e7eb;
}

/* LinkedIn Post Modal */
.linkedin-posts-container {
    display: flex;
    flex-direction: column;
    gap: 2em;
}

.linkedin-post-wrapper {
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    overflow: hidden;
}

.linkedin-post {
    background: #fff;
    padding: 1.5em;
    font-family: -apple-system, system-ui, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", "Fira Sans", Ubuntu, Oxygen, "Oxygen Sans", Cantarell, "Droid Sans", "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Lucida Grande", Helvetica, Arial, sans-serif;
    color: rgba(0, 0, 0, 0.9);
}

.linkedin-post-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    margin-bottom: 8px;
}

.linkedin-post-author-info {
    display: flex;
    align-items: center;
}

.linkedin-post-avatar {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background-color: #e1e9ee;
    margin-right: 12px;
    /* In a real app, you'd use an <img> tag with a src */
}

.linkedin-author-name {
    font-weight: 600;
    font-size: 1rem;
}

.linkedin-author-headline {
    font-size: 0.875rem;
    color: rgba(0, 0, 0, 0.6);
}

.linkedin-post-content {
    margin-bottom: 8px;
    font-size: 1rem;
    line-height: 1.4;
}

.linkedin-post-content p {
    margin-bottom: 1em;
    line-height: 1.6;
}

.linkedin-post-content ul {
    padding-left: 18px;
    margin-bottom: 8px;
}

.linkedin-post-stats {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.875rem;
    color: rgba(0, 0, 0, 0.6);
    padding: 8px 0;
    border-bottom: 1px solid #e5e7eb;
}

.linkedin-post-likes {
    display: flex;
    align-items: center;
    gap: 4px;
}

.linkedin-post-comments-reposts {
    display: flex;
    gap: 12px;
}

.linkedin-post-actions {
    padding: 4px 0;
    display: flex;
    justify-content: flex-end;
    align-items: center;
}

.linkedin-action-btn {
    background: none;
    border: none;
    color: rgba(0, 0, 0, 0.6);
    font-weight: 600;
    font-size: 0.875rem;
    cursor: pointer;
    padding: 8px;
    border-radius: 4px;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: background-color 0.2s;
}

.linkedin-action-btn:hover {
    background-color: rgba(0, 0, 0, 0.05);
}

.linkedin-action-icon {
    font-size: 1.2em;
}

.copy-btn-single-post {
    background: none;
    border: 1px solid #0a66c2;
    color: #0a66c2;
    padding: 6px 12px;
    border-radius: 16px;
    cursor: pointer;
    font-weight: 600;
    transition: background-color 0.2s, color 0.2s;
}

.copy-btn-single-post:hover {
    background-color: rgba(112, 181, 249, 0.2);
    color: #0a66c2;
}

.linkedin-post-details {
    padding: 1em;
    font-size: 0.9em;
    color: #6b7280;
    background-color: #F9FAFB;
}

.linkedin-post-details p {
    margin: 0.5em 0;
}

.linkedin-post-details strong {
    color: #111827;
}

/* Facebook Ad Modal */
.facebook-ads-container {
    display: flex;
    flex-direction: column;
    gap: 2em;
}

.facebook-post-wrapper {
    border: 1px solid #dddfe2;
    border-radius: 8px;
    background-color: #fff;
}

.facebook-post {
    padding: 12px 16px;
}

.facebook-post-header {
    display: flex;
    align-items: center;
    margin-bottom: 12px;
}

.facebook-post-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background-color: #e1e9ee;
    margin-right: 12px;
}

.facebook-author-name {
    font-weight: 600;
    font-size: 15px;
    color: #050505;
}

.facebook-post-meta {
    font-size: 13px;
    color: #65676b;
}

.facebook-post-body {
    margin-bottom: 12px;
}

.facebook-post-body p {
    font-size: 15px;
    line-height: 1.7;
    color: #050505;
}

.facebook-post-footer {
    border-top: 1px solid #dddfe2;
    margin: 0 -16px -12px -16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.facebook-ad-preview {
    padding: 12px 16px;
    background-color: #f0f2f5;
    flex-grow: 1;
}

.facebook-ad-url {
    text-transform: uppercase;
    font-size: 12px;
    color: #65676b;
    margin-bottom: 8px;
}

.facebook-ad-headline {
    font-weight: 600;
    font-size: 17px;
    color: #050505;
    line-height: 1.4;
}

.facebook-ad-cta {
    font-weight: 600;
    font-size: 15px;
    color: #1877f2;
    text-decoration: none;
    padding: 12px 16px;
    border-left: 1px solid #dddfe2;
    transition: background-color 0.2s;
}

.facebook-ad-cta:hover {
    background-color: #f0f2f5;
}

.facebook-post-actions {
    padding: 8px 16px;
    text-align: right;
    border-top: 1px solid #dddfe2;
}

.copy-btn-single-ad {
    background: none;
    border: 1px solid #1877f2;
    color: #1877f2;
    padding: 6px 12px;
    border-radius: 4px;
    cursor: pointer;
    font-weight: 600;
    transition: background-color 0.2s, color 0.2s;
}

.copy-btn-single-ad:hover {
    background-color: rgba(24, 119, 242, 0.1);
}

/* Status Tags */
.status-tag {
    display: inline-flex;
}

.email-body h1,
.email-body h2,
.email-body h3,
.email-body h4,
.email-body h5,
.email-body h6 {
  margin-top: 20px;
  margin-bottom: 10px;
  font-weight: 600;
}

.email-body h1 { font-size: 24px; }
.email-body h2 { font-size: 20px; }
.email-body h3 { font-size: 18px; }
.email-body h4 { font-size: 16px; }
.email-body h5 { font-size: 14px; }
.email-body h6 { font-size: 12px; }

.email-body p {
  margin-bottom: 12px;
}

.email-body ul,
.email-body ol {
  margin-bottom: 12px;
  padding-left: 20px;
}

.email-body li {
  margin-bottom: 4px;
}

.email-body blockquote {
  border-left: 4px solid var(--primary);
  padding-left: 16px;
  margin: 16px 0;
  font-style: italic;
  color: var(--text-secondary);
}

.email-body code {
  background-color: var(--bg-canvas);
  padding: 2px 6px;
  border-radius: var(--radius-sm);
  font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
  font-size: 14px;
}

.email-body pre {
  background-color: var(--bg-canvas);
  padding: 12px;
  border-radius: var(--radius-sm);
  overflow-x: auto;
  margin: 12px 0;
}

.email-body pre code {
  background: none;
  padding: 0;
}

/* Responsive Design */
@media (max-width: 768px) {
  .header-content {
    flex-direction: column;
    align-items: stretch;
  }

  .client-id-input {
    min-width: auto;
    width: 100%;
  }

  .main-content {
    padding: 16px;
  }

  .pillar-card,
  .client-card {
    padding: 16px;
  }

  .modal-content {
    width: 95%;
    max-height: 90vh;
  }
}
