:root {
  --primary-color: #3390ec;
  --primary-hover: #2883d9;
  --bg-color: #ffffff;
  --secondary-bg: #f4f4f5;
  --text-color: #000000;
  --text-secondary: #707579;
  --border-color: #dfe1e5;
  --input-bg: #ffffff;
  --input-focus-border: #3390ec;
  --danger-color: #e53935;
  --warning-color: #fb8c00;
  --success-color: #4caf50;
  --radius: 8px;
  --spacing: 16px;
}

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

body {
  font-family: "Vazirmatn", sans-serif;
  background-color: var(--bg-color);
  color: var(--text-color);
  direction: rtl;
  line-height: 1.5;
}

.app-container {
  max-width: 1200px;
  margin: 0 auto;
  padding-bottom: 50px;
}

/* Header */
.main-header {
  display: flex;
  justify-content: center;
  padding: 12px 20px;
  border-bottom: 1px solid var(--border-color);
  margin-bottom: 24px;
}

.header-content {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
  max-width: 1000px;
}

.logo-section {
  display: flex;
  align-items: center;
  gap: 10px;
}

.logo-icon {
  font-size: 24px;
  color: var(--primary-color);
}

.logo-section h1 {
  font-size: 16px;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 8px;
}

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

.current-page {
  font-weight: 700;
}

.user-section {
  display: flex;
  align-items: center;
  gap: 16px;
  font-size: 14px;
}

.budget {
  font-weight: 500;
}

.user-profile {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--primary-color);
  cursor: pointer;
}

.avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
}

/* Main Content */
.main-content {
  max-width: 1000px;
  margin: 0 auto;
  padding: 0 20px;
}

.page-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 30px;
}

.page-header h2 {
  font-size: 20px;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 8px;
}

.badge {
  font-size: 12px;
  background-color: var(--secondary-bg);
  color: var(--text-secondary);
  padding: 2px 6px;
  border-radius: 4px;
  font-weight: normal;
}

.target-selector {
  display: flex;
  align-items: center;
  gap: 10px;
}

.tabs {
  background-color: var(--secondary-bg);
  padding: 4px;
  border-radius: 20px;
  display: flex;
}

.tab-btn {
  border: none;
  background: none;
  padding: 6px 16px;
  border-radius: 16px;
  font-family: inherit;
  font-size: 14px;
  cursor: pointer;
  color: var(--text-secondary);
  transition: all 0.2s;
}

.tab-btn.active {
  background-color: var(--primary-color);
  color: white;
}

.tab-btn:disabled {
  cursor: not-allowed;
  opacity: 0.7;
}

/* Layout */
.creation-layout {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 40px;
}

/* Form Styles */
.form-group {
  margin-bottom: 24px;
}

label {
  display: block;
  margin-bottom: 8px;
  font-weight: 500;
  font-size: 14px;
  color: var(--text-color);
}

.info-icon {
  color: var(--text-secondary);
  cursor: help;
  font-size: 12px;
}

input[type="text"],
input[type="url"],
input[type="number"],
textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  font-family: inherit;
  font-size: 15px;
  transition: border-color 0.2s;
}

input:focus,
textarea:focus {
  outline: none;
  border-color: var(--input-focus-border);
}

.ltr-input {
  direction: ltr;
  text-align: left;
}

.helper-text {
  font-size: 13px;
  color: var(--text-secondary);
  margin-top: 6px;
}

.checkbox-group {
  display: flex;
  align-items: center;
  gap: 10px;
}

.checkbox-group input[type="checkbox"] {
  width: 18px;
  height: 18px;
}

.checkbox-group label {
  margin-bottom: 0;
  font-weight: normal;
}

.upload-btn {
  width: 100%;
  padding: 12px;
  background-color: var(--primary-color);
  color: white;
  border: none;
  border-radius: var(--radius);
  font-family: inherit;
  font-size: 15px;
  font-weight: 500;
  cursor: pointer;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 8px;
  transition: background-color 0.2s;
}

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

.input-with-icon {
  position: relative;
  display: flex;
  align-items: center;
}

.currency-icon {
  position: absolute;
  right: 12px;
  color: var(--text-secondary);
}

.input-with-icon input {
  padding-right: 36px;
}

.approx-value {
  position: absolute;
  left: 12px;
  color: var(--text-secondary);
  font-size: 13px;
}

.label-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

.link-action {
  color: var(--primary-color);
  text-decoration: none;
  font-size: 13px;
}

.link-action:hover {
  text-decoration: underline;
}

.segment-control {
  display: flex;
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  overflow: hidden;
}

.segment-control label {
  flex: 1;
  margin: 0;
  text-align: center;
  cursor: pointer;
  position: relative;
}

.segment-control input {
  position: absolute;
  opacity: 0;
  cursor: pointer;
}

.segment-control span {
  display: block;
  padding: 10px;
  background: var(--bg-color);
  border-left: 1px solid var(--border-color);
  transition: background-color 0.2s;
}

.segment-control label:last-child span {
  border-left: none;
}

.segment-control input:checked + span {
  background-color: var(--primary-color);
  color: white;
}

.radio-group {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.radio-group label {
  font-weight: normal;
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 0;
}

.indented {
  margin-right: 24px;
  display: block;
  margin-top: 4px;
}

/* Tag Input Styles */
.input-tag-wrapper {
  display: flex;
  gap: 8px;
  align-items: flex-start;
}

.tags-input-container {
  flex-grow: 1;
  min-height: 42px;
  padding: 4px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  background-color: var(--input-bg);
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  align-items: center;
  transition: border-color 0.2s;
}

.tags-input-container:focus-within {
  border-color: var(--input-focus-border);
}

.tag-item {
  background-color: var(--primary-color);
  color: white;
  padding: 4px 8px;
  border-radius: 4px;
  font-size: 14px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.tag-remove {
  cursor: pointer;
  font-weight: bold;
  font-size: 16px;
  line-height: 1;
  opacity: 0.8;
}

.tag-remove:hover {
  opacity: 1;
}

.tag-input {
  border: none !important;
  padding: 6px 8px !important;
  flex-grow: 1;
  min-width: 150px;
  background: transparent;
  height: 32px;
}

.tag-input:focus {
  box-shadow: none;
}

.add-tag-btn {
  padding: 0 16px;
  height: 42px;
  background-color: var(--secondary-bg);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  color: var(--text-color);
  cursor: pointer;
  font-family: inherit;
  font-size: 14px;
  transition: all 0.2s;
  white-space: nowrap;
}

.add-tag-btn:hover {
  background-color: #e4e4e5;
}

.dynamic-summary {
  margin-top: 12px;
  font-size: 13px;
  display: flex;
  align-items: flex-start;
  gap: 8px;
  color: var(--text-color);
}

.dynamic-summary .icon {
  font-size: 18px;
  line-height: 1.2;
}

.icon.green {
  color: var(--success-color);
}

/* Preview Section */
.preview-section {
  padding-top: 20px;
}

.preview-container h3 {
  font-size: 16px;
  margin-bottom: 12px;
}

.preview-card-wrapper {
  background-image: url("assets/images/telegram-bg.png"); /* Local background */
  background-color: #99ba92; /* Fallback color */
  background-size: cover;
  padding: 20px;
  border-radius: 12px;
  margin-bottom: 24px;
}

.preview-card {
  background: white;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
  max-width: 320px;
  margin: 0 auto;
}

.preview-header {
  padding: 8px 12px;
  display: flex;
  align-items: center;
}

.preview-channel-info {
  display: flex;
  align-items: center;
  gap: 10px;
}

.channel-avatar {
  width: 36px;
  height: 36px;
  background-color: #ccc;
  border-radius: 50%;
}

.channel-text {
  line-height: 1.2;
}

.channel-name {
  font-weight: 600;
  font-size: 14px;
}

.post-meta {
  font-size: 12px;
  color: var(--text-secondary);
}

.preview-content {
  padding: 0 12px 12px;
}

.preview-image-placeholder {
  width: 100%;
  height: 150px;
  background-color: #f0f2f5;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
  margin-bottom: 8px;
  font-size: 14px;
}

#previewText {
  font-size: 15px;
  white-space: pre-wrap;
}

.preview-footer {
  padding: 8px 12px;
  border-top: 1px solid #f0f2f5;
}

.preview-cta-btn {
  width: 100%;
  background-color: #f5fcfeb5; /* Light blueish tint */
  color: var(--primary-color);
  border: none;
  padding: 8px;
  border-radius: 4px;
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
}

/* Warnings */
.warnings {
  margin-top: 16px;
  font-size: 13px;
}

.warning-item {
  display: flex;
  gap: 10px;
  margin-bottom: 8px;
  align-items: flex-start;
}

.warning-item .icon {
  font-size: 16px;
  flex-shrink: 0;
}

.warning-item .icon.red {
  color: var(--danger-color);
}
.warning-item .icon.orange {
  color: var(--warning-color);
}

/* Bottom Actions */
.bottom-actions {
  border-top: 1px solid var(--border-color);
  margin-top: 40px;
  padding-top: 24px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.terms-checkbox {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
}

.terms-checkbox a {
  color: var(--primary-color);
  text-decoration: none;
}

.action-buttons {
  display: flex;
  gap: 16px;
}

.btn-text {
  background: none;
  border: none;
  color: var(--primary-color);
  font-weight: 500;
  cursor: pointer;
  font-family: inherit;
  font-size: 15px;
}

.btn-primary {
  background-color: var(--primary-color);
  color: white;
  border: none;
  padding: 10px 24px;
  border-radius: var(--radius);
  font-weight: 500;
  cursor: pointer;
  font-family: inherit;
  font-size: 15px;
  transition: background-color 0.2s;
}

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

/* Search Preview Styles */
.preview-card-search {
    background: white;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    width: 100%;
    max-width: 320px;
    margin: 0 auto;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    direction: ltr; /* Telegram UI is usually LTR even for Persian content in search lists sometimes, but let's keep it consistent. */
}

.search-header {
    background-color: #f5f5f5; /* Light gray like Telegram */
    padding: 8px 16px;
    display: flex;
    align-items: center;
    gap: 8px;
    color: #707579;
}

.search-icon {
    font-size: 16px;
    color: #707579;
}

.search-text {
    font-size: 14px;
    font-weight: 500;
    color: #707579;
}

.search-results {
    padding: 0;
    background: white;
}

.global-search-label {
    background-color: #f4f4f5;
    color: #707579;
    font-size: 13px;
    padding: 8px 16px;
    font-weight: 500;
    text-transform: uppercase;
}

.search-item {
    display: flex;
    align-items: center;
    padding: 8px 12px;
    gap: 12px;
    background: white;
    cursor: default;
}

.search-avatar {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    overflow: hidden;
    background-color: #5ea6e9; /* Telegram blue avatar bg */
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 20px;
    font-weight: 600;
    flex-shrink: 0;
}

.search-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.search-info {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    min-width: 0; /* Text truncation fix */
}

.search-title {
    font-weight: 600;
    font-size: 16px;
    color: #000;
    margin-bottom: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.search-subtitle {
    font-size: 14px;
    color: #8e959b; /* Muted gray */
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.search-ad-badge {
    background-color: #ebf5fa; /* Light blue badge bg */
    color: #2481cc; /* Telegram blue */
    font-size: 12px;
    padding: 2px 6px;
    border-radius: 4px;
    font-weight: 500;
    flex-shrink: 0;
}

/* Empty State */
.preview-card-empty {
    width: 100%;
    height: 200px;
    background-color: #f5f5f5;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #999;
    text-align: center;
    padding: 20px;
    border: 1px dashed #ccc;
    font-size: 14px;
}

.search-placeholder-lines {
    padding: 10px 16px;
    opacity: 0.5;
}

.line {
    height: 10px;
    background-color: #f0f2f5;
    border-radius: 5px;
    margin-bottom: 10px;
}

.line.long { width: 85%; }
.line.medium { width: 65%; }
.line.short { width: 45%; }
/* Bot Preview Styles */
.preview-card-bot {
    background: white;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    width: 100%;
    max-width: 320px;
    margin: 0 auto;
    font-family: 'Vazirmatn', sans-serif !important; /* Ensure Vazirmatn is applied */
    direction: ltr; /* Reset to LTR for layout structure */
}

.bot-preview-ad-area {
    padding: 12px 16px;
    background: white;
    border-bottom: 1px solid #f0f0f0;
}

.bot-ad-badge {
    color: #3390ec;
    font-weight: 600;
    font-size: 13px;
    margin-bottom: 8px;
    display: inline-flex; /* Use inline-flex for better alignment */
    align-items: center; /* Center content vertically */
}

.bot-ad-badge::after {
    content: "what's this?";
    color: #aeb4b9;
    font-weight: 400;
    font-size: 11px;
    margin-left: 6px;
    background: #ebf3f8;
    padding: 1px 5px;
    border-radius: 4px;
    display: inline-block;
    white-space: nowrap; /* Prevent breaking */
}

.bot-ad-content {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
}

.bot-ad-text {
    font-size: 15px;
    color: #000;
    line-height: 1.4;
    flex-grow: 1;
    margin-right: 12px;
    white-space: pre-wrap;
    text-align: right; /* Right align Persian text */
    direction: rtl; /* Set text direction to RTL */
}

.bot-ad-info {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    min-width: 60px;
}

.bot-ad-avatar {
    width: 40px;
    height: 40px;
    border-radius: 8px;
    background-color: #e15f41;
    overflow: hidden;
}

.bot-ad-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.bot-ad-title {
    font-size: 13px;
    font-weight: 600;
    color: #000;
    text-align: center;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 80px;
}

.bot-preview-chat-area {
    background-color: #90bd71;
    background-image: url("assets/images/telegram-bg.png");
    background-size: cover;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    direction: ltr; /* Chat area is LTR structurally */
}

.bot-chat-bubble {
    background: white;
    padding: 8px 12px;
    border-radius: 12px 12px 12px 0;
    position: relative;
    align-self: flex-start;
    max-width: 85%;
    box-shadow: 0 1px 1px rgba(0,0,0,0.1);
}

.bot-chat-text {
    font-size: 15px;
    color: #000;
    line-height: 1.4;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif; /* Keep English font for system message */
}

.bot-chat-time {
    font-size: 11px;
    color: #aeb4b9;
    text-align: right;
    margin-top: 2px;
}

.bot-start-btn {
    background-color: rgba(0, 0, 0, 0.2);
    color: white;
    border: none;
    padding: 12px;
    border-radius: 8px;
    font-weight: 600;
    font-size: 16px;
    width: 100%;
    cursor: default;
    backdrop-filter: blur(5px);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

/* Responsive Design */
@media (max-width: 900px) {
    .creation-layout {
        grid-template-columns: 1fr;
        gap: 24px;
    }

    .preview-section {
        order: -1; /* Preview on top for mobile */
        margin-bottom: 20px;
        padding-top: 0;
    }
    
    .preview-card-wrapper {
        padding: 16px;
        margin-bottom: 0;
    }
}

@media (max-width: 600px) {
    .app-container {
        padding-bottom: 80px;
    }

    .main-header {
        padding: 12px 16px;
        margin-bottom: 20px;
    }

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

    .logo-section {
        justify-content: center;
    }

    .user-section {
        justify-content: space-between;
        width: 100%;
        border-top: 1px solid var(--secondary-bg);
        padding-top: 12px;
    }

    .page-header {
        flex-direction: column;
        align-items: stretch;
        gap: 20px;
        margin-bottom: 24px;
    }

    .page-header h2 {
        justify-content: center;
    }

    .target-selector {
        flex-direction: column;
        align-items: stretch;
        gap: 12px;
    }
    
    .target-selector .label {
        text-align: center;
        display: none; /* Hide label to save space if clear enough */
    }

    .tabs {
        width: 100%;
        display: flex;
    }
    
    .tab-btn {
        flex: 1;
        padding: 8px 4px;
        font-size: 13px;
        white-space: nowrap;
        text-align: center;
    }

    /* Form Elements */
    .form-group {
        margin-bottom: 20px;
    }
    
    input[type="text"],
    input[type="url"],
    input[type="number"],
    textarea {
        font-size: 16px; /* Prevent iOS zoom */
        padding: 12px;
    }

    .segment-control label span {
        padding: 12px 4px;
        font-size: 13px;
    }

    /* Bottom Actions */
    .bottom-actions {
        flex-direction: column;
        gap: 24px;
        align-items: stretch;
        margin-top: 32px;
    }

    .terms-checkbox {
        justify-content: center;
    }

    .action-buttons {
        flex-direction: column-reverse;
        gap: 12px;
        width: 100%;
    }

    .btn-primary, .btn-text {
        width: 100%;
        height: 48px;
        display: flex;
        align-items: center;
        justify-content: center;
        font-size: 16px;
    }
    
    .btn-text {
        color: var(--text-secondary);
    }
}

/* Pricing Tooltip and Badge Styles */
.price-info-container {
    position: absolute;
    left: 12px;
    display: flex;
    align-items: center;
    gap: 8px;
    height: 100%;
}

.approx-value {
    position: static; /* Reset absolute positioning */
    color: var(--text-secondary);
    font-size: 13px;
}

.multiplier-badge {
    background-color: #fff3e0; /* Light orange bg */
    color: #e65100; /* Dark orange text */
    border-radius: 4px;
    padding: 2px 6px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    position: relative;
    display: flex;
    align-items: center;
}

.multiplier-badge:hover .tooltip {
    visibility: visible;
    opacity: 1;
    transform: translateX(-50%) translateY(-10px);
}

.tooltip {
    visibility: hidden;
    width: 200px;
    background-color: #333;
    color: #fff;
    text-align: center;
    border-radius: 6px;
    padding: 8px;
    position: absolute;
    z-index: 100;
    bottom: 125%; /* Position above */
    left: 50%;
    transform: translateX(-50%) translateY(0);
    opacity: 0;
    transition: opacity 0.3s, transform 0.3s;
    font-size: 12px;
    line-height: 1.4;
    box-shadow: 0 4px 6px rgba(0,0,0,0.2);
    pointer-events: none;
}

.tooltip::after {
    content: "";
    position: absolute;
    top: 100%; /* At the bottom of the tooltip */
    left: 50%;
    margin-left: -5px;
    border-width: 5px;
    border-style: solid;
    border-color: #333 transparent transparent transparent;
}
