@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&family=Outfit:wght@300;400;500;600;700;800&display=swap');

:root {
  --bg-color: #040d1a;
  --panel-bg: rgba(11, 35, 65, 0.4);
  --panel-border: rgba(255, 255, 255, 0.08);
  --primary-color: #0b2341;
  --accent-color: #00b4d8;
  --accent-glow: rgba(0, 180, 216, 0.4);
  --text-primary: #ffffff;
  --text-secondary: #94a3b8;
  --success-color: #25d366;
  --success-glow: rgba(37, 211, 102, 0.3);
  --error-color: #ef4444;
  --input-bg: rgba(4, 13, 26, 0.6);
  --input-focus-border: #00b4d8;
}

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

body {
  font-family: 'Inter', 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  background-color: var(--bg-color);
  background-image: 
    radial-gradient(at 10% 10%, rgba(11, 35, 65, 0.5) 0px, transparent 50%),
    radial-gradient(at 90% 90%, rgba(0, 180, 216, 0.15) 0px, transparent 50%);
  background-attachment: fixed;
  color: var(--text-primary);
  min-height: 100vh;
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 20px;
}

.container {
  width: 100%;
  max-width: 1000px;
  background: var(--panel-bg);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--panel-border);
  border-radius: 24px;
  padding: 40px;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.3);
  animation: fadeIn 0.6s ease-out;
}

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

header {
  text-align: center;
  margin-bottom: 35px;
}

header h1 {
  font-family: 'Outfit', sans-serif;
  font-size: 2.2rem;
  font-weight: 800;
  letter-spacing: -0.5px;
  background: linear-gradient(135deg, #ffffff 30%, var(--accent-color) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  margin-bottom: 8px;
}

header p {
  color: var(--text-secondary);
  font-size: 0.95rem;
  font-weight: 400;
}

.template-section {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.05);
  border-radius: 14px;
  padding: 16px;
  margin-bottom: 25px;
}

.form-group {
  margin-bottom: 22px;
  display: flex;
  flex-direction: column;
}

label {
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 8px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

input, select, textarea {
  font-family: inherit;
  font-size: 0.95rem;
  background: var(--input-bg);
  border: 1px solid var(--panel-border);
  border-radius: 12px;
  padding: 14px 18px;
  color: var(--text-primary);
  outline: none;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  width: 100%;
  resize: vertical;
}

input:focus, select:focus, textarea:focus {
  border-color: var(--input-focus-border);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

select {
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%2394a3b8'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M19 9l-7 7-7-7'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 18px center;
  background-size: 18px;
  padding-right: 45px;
}

.btn-submit {
  font-family: 'Outfit', sans-serif;
  font-size: 1.05rem;
  font-weight: 700;
  color: #ffffff;
  background: linear-gradient(135deg, var(--accent-color) 0%, #0077b6 100%);
  border: none;
  border-radius: 14px;
  padding: 16px;
  cursor: pointer;
  transition: all 0.3s ease;
  box-shadow: 0 4px 15px var(--accent-glow);
  margin-top: 10px;
}

.btn-submit:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(0, 180, 216, 0.6);
}

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

.btn-submit:disabled {
  background: #1e293b;
  color: #64748b;
  cursor: not-allowed;
  box-shadow: none;
  transform: none;
}

.status-card {
  margin-top: 25px;
  border-radius: 14px;
  padding: 18px;
  font-size: 0.95rem;
  display: none;
  animation: slideDown 0.4s ease-out;
}

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

.status-card.success {
  display: flex;
  align-items: center;
  background: rgba(37, 211, 102, 0.1);
  border: 1px solid rgba(37, 211, 102, 0.2);
  color: #a7f3d0;
  box-shadow: 0 4px 12px var(--success-glow);
}

.status-card.error {
  display: flex;
  align-items: center;
  background: rgba(239, 68, 68, 0.1);
  border: 1px solid rgba(239, 68, 68, 0.2);
  color: #fca5a5;
}

.status-card .icon {
  margin-right: 12px;
  font-size: 1.25rem;
  flex-shrink: 0;
}

.loader {
  display: none;
  width: 22px;
  height: 22px;
  border: 3px solid rgba(255, 255, 255, 0.3);
  border-radius: 50%;
  border-top-color: #ffffff;
  animation: spin 1s ease-in-out infinite;
  margin: 0 auto;
}

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

/* RTL support for arabic inputs */
input[dir="rtl"] {
  text-align: right;
}

.footer {
  text-align: center;
  margin-top: 30px;
  font-size: 0.8rem;
  color: var(--text-secondary);
}

/* Hub View & Cards Grid */
.view-panel {
  animation: fadeIn 0.4s ease-out;
}

.cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 20px;
  margin-top: 30px;
  margin-bottom: 10px;
}

.bot-card {
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--panel-border);
  border-radius: 18px;
  padding: 24px;
  text-align: center;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.bot-card:hover {
  transform: translateY(-5px);
  background: rgba(255, 255, 255, 0.04);
  border-color: rgba(0, 180, 216, 0.3);
  box-shadow: 0 12px 30px rgba(0, 180, 216, 0.15);
}

.card-icon {
  font-size: 3rem;
  margin-bottom: 15px;
}

.bot-card h3 {
  font-family: 'Outfit', sans-serif;
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 10px;
}

.bot-card p {
  font-size: 0.88rem;
  color: var(--text-secondary);
  line-height: 1.6;
  margin-bottom: 20px;
  flex-grow: 1;
}

.card-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: 100%;
}

.card-btn {
  font-family: 'Outfit', sans-serif;
  font-size: 0.92rem;
  font-weight: 700;
  padding: 12px;
  border-radius: 10px;
  cursor: pointer;
  transition: all 0.2s ease;
  width: 100%;
  text-decoration: none;
  text-align: center;
}

.card-btn.primary {
  background: linear-gradient(135deg, var(--accent-color) 0%, #0077b6 100%);
  color: #ffffff;
  border: none;
  box-shadow: 0 4px 12px var(--accent-glow);
}

.card-btn.primary:hover {
  box-shadow: 0 6px 15px rgba(0, 180, 216, 0.4);
  transform: translateY(-1px);
}

.card-btn.secondary {
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-primary);
  border: 1px solid var(--panel-border);
}

.card-btn.secondary:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.2);
}

/* Back Button Bar */
.back-bar {
  margin-bottom: 20px;
  display: flex;
  justify-content: flex-start;
}

.btn-back {
  background: none;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 0.95rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: 8px;
  transition: all 0.2s ease;
}

.btn-back:hover {
  color: var(--text-primary);
  background: rgba(255, 255, 255, 0.05);
}

.btn-back .arrow {
  transition: transform 0.2s ease;
}

.btn-back:hover .arrow {
  transform: translateX(-4px); /* Moves left in RTL */
}

/* Modal Popup */
.modal {
  display: none;
  position: fixed;
  z-index: 1000;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(4, 13, 26, 0.8);
  backdrop-filter: blur(8px);
  align-items: center;
  justify-content: center;
  padding: 20px;
  animation: fadeIn 0.3s ease-out;
}

.modal-content {
  background: #081528;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 20px;
  max-width: 500px;
  width: 100%;
  padding: 30px;
  position: relative;
  box-shadow: 0 25px 50px rgba(0, 0, 0, 0.5);
  animation: scaleUp 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes scaleUp {
  from {
    transform: scale(0.9);
    opacity: 0;
  }
  to {
    transform: scale(1);
    opacity: 1;
  }
}

.close-modal {
  position: absolute;
  left: 20px;
  top: 15px;
  font-size: 1.8rem;
  font-weight: bold;
  color: var(--text-secondary);
  cursor: pointer;
  transition: color 0.2s ease;
}

.close-modal:hover {
  color: var(--text-primary);
}

.modal-content h2 {
  font-family: 'Outfit', sans-serif;
  font-size: 1.4rem;
  margin-bottom: 20px;
  background: linear-gradient(135deg, #ffffff 30%, var(--accent-color) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  padding-left: 20px; /* Space for close button */
}

.modal-body {
  font-size: 0.95rem;
  line-height: 1.7;
  color: #cbd5e1;
}

.modal-body ul {
  margin-top: 15px;
  padding-right: 20px;
  list-style-type: none;
}

.modal-body li {
  position: relative;
  margin-bottom: 12px;
}

.modal-body li::before {
  content: "•";
  color: var(--accent-color);
  font-size: 1.3rem;
  position: absolute;
  right: -15px;
  top: -1px;
}

.modal-body span {
  color: var(--accent-color);
  font-weight: 600;
}

/* Tabs & Results Styling */
.tabs-container {
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--panel-border);
  border-radius: 16px;
  overflow: hidden;
  margin-top: 30px;
  animation: fadeIn 0.4s ease-out;
}

.tabs-header {
  display: flex;
  background: rgba(4, 13, 26, 0.8);
  border-bottom: 1px solid var(--panel-border);
  overflow-x: auto;
  scrollbar-width: none;
}
.tabs-header::-webkit-scrollbar {
  display: none;
}

.tab-btn {
  flex: 1;
  min-width: 80px;
  padding: 14px 10px;
  background: none;
  border: none;
  color: var(--text-secondary);
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s ease;
  text-align: center;
  border-bottom: 2px solid transparent;
  white-space: nowrap;
}

.tab-btn.active {
  color: var(--accent-color);
  background: rgba(0, 180, 216, 0.05);
  border-bottom-color: var(--accent-color);
}

.tab-btn:hover:not(.active) {
  color: var(--text-primary);
  background: rgba(255, 255, 255, 0.02);
}

.tabs-content {
  padding: 24px;
}

.tab-panel {
  display: none;
  flex-direction: column;
  gap: 15px;
}

.tab-panel.active {
  display: flex;
}

.text-content {
  background: var(--input-bg);
  border: 1px solid var(--panel-border);
  border-radius: 12px;
  padding: 18px;
  font-size: 0.95rem;
  line-height: 1.7;
  color: #e2e8f0;
  white-space: pre-wrap;
  max-height: 350px;
  overflow-y: auto;
  text-align: right;
}

.btn-copy {
  align-self: flex-start;
  background: rgba(0, 180, 216, 0.1);
  border: 1px solid rgba(0, 180, 216, 0.3);
  color: var(--accent-color);
  font-family: inherit;
  font-size: 0.88rem;
  font-weight: 700;
  padding: 10px 18px;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 5px;
}

.btn-copy:hover {
  background: var(--accent-color);
  color: #ffffff;
  box-shadow: 0 4px 12px var(--accent-glow);
}

.btn-copy.success {
  background: rgba(37, 211, 102, 0.1);
  border-color: rgba(37, 211, 102, 0.3);
  color: var(--success-color);
  box-shadow: 0 4px 12px var(--success-glow);
}

/* Form views constraint for focused center layout */
#form-view, #ad-creator-view {
  max-width: 600px;
  margin: 0 auto;
}

/* 1. Header Banner Styles (Horizontal top-down layout) */
.hub-header-banner {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 30px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  padding-bottom: 25px;
  margin-bottom: 35px;
  text-align: right;
  direction: rtl;
}

.header-branding-info {
  display: flex;
  align-items: center;
  gap: 25px;
}

.header-logo-img {
  height: 80px;
  width: auto;
  object-fit: contain;
  filter: drop-shadow(0 0 10px rgba(0, 180, 216, 0.15));
}

.header-text-container {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
}

.header-text-container h1 {
  font-family: 'Outfit', sans-serif;
  font-size: 1.8rem;
  font-weight: 800;
  background: linear-gradient(135deg, #ffffff 40%, var(--accent-color) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  margin: 0;
  text-align: right;
}

.header-text-container p {
  color: var(--text-secondary);
  font-size: 0.95rem;
  margin: 0;
  text-align: right;
}

/* Building Card in Header */
.header-building-card {
  background: rgba(4, 13, 26, 0.4);
  border: 1px solid var(--panel-border);
  border-radius: 16px;
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: 220px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
}

.header-building-image-container {
  width: 100%;
  height: 105px;
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.05);
  background: #081220;
}

.header-building-image {
  width: 100%;
  height: 100%;
  object-fit: cover;
  filter: grayscale(100%) contrast(1.15) brightness(0.95);
  transition: all 0.5s ease;
}

.header-building-card:hover .header-building-image {
  filter: grayscale(0%) contrast(1.05) brightness(1);
}

.header-building-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 4px;
  font-size: 0.72rem;
}

.header-building-since {
  font-family: 'Outfit', sans-serif;
  color: #ffffff;
  font-weight: 700;
}

.header-building-tagline {
  color: var(--accent-color);
  font-weight: 600;
}

/* 2. Departments 3-Column Grid (Bottom Layout) */
.departments-container {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 20px;
  align-items: stretch;
  text-align: right;
  direction: rtl;
}

.department-card {
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--panel-border);
  border-radius: 20px;
  padding: 24px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 20px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.15);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.department-card:hover:not(.coming-soon) {
  background: rgba(255, 255, 255, 0.035);
  border-color: rgba(0, 180, 216, 0.25);
  transform: translateY(-4px);
  box-shadow: 0 12px 35px rgba(0, 180, 216, 0.08);
}

.department-header {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.department-title-wrapper {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 2px;
}

.department-icon {
  width: 34px;
  height: 34px;
  background: rgba(0, 180, 216, 0.08);
  border: 1px solid rgba(0, 180, 216, 0.2);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
}

.department-title {
  font-size: 1.3rem;
  font-weight: 800;
  color: #ffffff;
  margin: 0;
}

.department-desc {
  font-size: 0.85rem;
  color: var(--text-secondary);
  line-height: 1.55;
  margin: 0;
}

/* Bots List inside columns */
.department-bots-list {
  display: flex;
  flex-direction: column;
  gap: 16px;
  flex-grow: 1;
}

.bot-item {
  background: rgba(4, 13, 26, 0.4);
  border: 1px solid rgba(255, 255, 255, 0.03);
  border-radius: 14px;
  padding: 18px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 14px;
  height: 100%;
}

.bot-item h4 {
  font-size: 0.95rem;
  font-weight: 700;
  color: #ffffff;
  margin: 0;
}

.bot-item p {
  font-size: 0.8rem;
  color: var(--text-secondary);
  line-height: 1.5;
  margin: 0;
}

.department-card.coming-soon {
  opacity: 0.6;
  background: rgba(255, 255, 255, 0.005);
  border-style: dashed;
}

.bot-item.style-disabled {
  opacity: 0.6;
}

/* Action Buttons inside Bot Item */
.action-buttons {
  display: flex;
  gap: 8px;
  margin-top: 4px;
}

.action-btn {
  font-family: inherit;
  font-size: 0.78rem;
  font-weight: 700;
  padding: 10px 14px;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s ease;
  text-align: center;
  text-decoration: none;
  width: 100%;
}

.action-btn.primary {
  background: linear-gradient(135deg, var(--accent-color) 0%, #0077b6 100%);
  color: #ffffff;
  border: none;
  box-shadow: 0 4px 10px rgba(0, 180, 216, 0.15);
}

.action-btn.primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 14px rgba(0, 180, 216, 0.35);
}

.action-btn.secondary {
  background: rgba(255, 255, 255, 0.04);
  color: var(--text-primary);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.action-btn.secondary:hover {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.15);
}

.action-btn:disabled {
  background: #1e293b;
  color: #64748b;
  border: none;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

/* Responsive Overrides */
@media (max-width: 900px) {
  .departments-container {
    grid-template-columns: 1fr;
    gap: 20px;
  }
  
  .hub-header-banner {
    flex-direction: column-reverse;
    align-items: flex-start;
    gap: 20px;
  }
  
  .header-building-card {
    width: 100%;
  }
  
  .header-building-image-container {
    aspect-ratio: 2.2 / 1;
    height: auto;
  }

  .header-branding-info {
    flex-direction: column;
    align-items: flex-start;
    gap: 15px;
  }
}
