/* ===== RESET & BASE ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #0f1117;
  --bg-card: #1a1d27;
  --bg-input: #252836;
  --bg-hover: #2a2d3a;
  --border: #2e3144;
  --text: #e4e4e7;
  --text-dim: #9ca3af;
  --primary: #6366f1;
  --primary-hover: #818cf8;
  --danger: #ef4444;
  --success: #10b981;
  --warning: #f59e0b;
  --pink: #ec4899;
  --radius: 10px;
  --sidebar-w: 220px;
}

body {
  font-family: 'Segoe UI', Tahoma, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  direction: rtl;
}

a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--primary-hover); }

/* ===== SCREENS ===== */
.screen { display: none; }
.screen.active { display: flex; }

/* ===== LOGIN ===== */
#login-screen {
  justify-content: center;
  align-items: center;
  min-height: 100vh;
  background: linear-gradient(135deg, #0f1117 0%, #1e1b4b 100%);
}

.login-box {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 48px 40px;
  width: 380px;
  text-align: center;
}

.login-box h1 {
  font-size: 28px;
  margin-bottom: 4px;
  background: linear-gradient(135deg, var(--primary), var(--pink));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.login-box .subtitle {
  color: var(--text-dim);
  margin-bottom: 32px;
  font-size: 14px;
}

.login-box input {
  width: 100%;
  padding: 12px 16px;
  margin-bottom: 12px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 15px;
  direction: ltr;
  text-align: right;
}

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

.login-box button {
  width: 100%;
  padding: 12px;
  background: var(--primary);
  color: white;
  border: none;
  border-radius: var(--radius);
  font-size: 16px;
  cursor: pointer;
  margin-top: 8px;
  transition: background 0.2s;
}

.login-box button:hover { background: var(--primary-hover); }

.error { color: var(--danger); font-size: 13px; margin-top: 8px; }

/* ===== APP LAYOUT ===== */
#app-screen {
  min-height: 100vh;
}

#sidebar {
  position: fixed;
  right: 0;
  top: 0;
  bottom: 0;
  width: var(--sidebar-w);
  background: var(--bg-card);
  border-left: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  z-index: 100;
}

.sidebar-header {
  padding: 20px;
  border-bottom: 1px solid var(--border);
}

.sidebar-header h2 {
  font-size: 22px;
  background: linear-gradient(135deg, var(--primary), var(--pink));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

#user-badge {
  display: block;
  font-size: 12px;
  color: var(--text-dim);
  margin-top: 4px;
}

.nav-links {
  list-style: none;
  padding: 12px 0;
  flex: 1;
}

.nav-link {
  display: block;
  padding: 12px 20px;
  color: var(--text-dim);
  font-size: 14px;
  transition: all 0.2s;
  border-right: 3px solid transparent;
}

.nav-link:hover { background: var(--bg-hover); color: var(--text); }
.nav-link.active {
  color: var(--primary);
  background: rgba(99, 102, 241, 0.1);
  border-right-color: var(--primary);
}

.sidebar-footer {
  padding: 16px 20px;
  border-top: 1px solid var(--border);
}

#btn-logout {
  width: 100%;
  padding: 8px;
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-dim);
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 13px;
}

#btn-logout:hover { border-color: var(--danger); color: var(--danger); }

#content {
  margin-right: var(--sidebar-w);
  padding: 24px 32px;
  min-height: 100vh;
}

/* ===== PAGES ===== */
.page { display: none; }
.page.active { display: block; }

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

.page-header h1 { font-size: 24px; }

/* ===== BUTTONS ===== */
.btn-primary {
  padding: 10px 20px;
  background: var(--primary);
  color: white;
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 14px;
  transition: background 0.2s;
}
.btn-primary:hover { background: var(--primary-hover); }

.btn-secondary {
  padding: 10px 20px;
  background: var(--bg-input);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 14px;
}
.btn-secondary:hover { background: var(--bg-hover); }

.btn-danger {
  padding: 10px 20px;
  background: var(--danger);
  color: white;
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 14px;
}

.btn-icon {
  padding: 6px 12px;
  background: var(--bg-input);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 16px;
}
.btn-icon:hover { background: var(--bg-hover); }

/* ===== BOARD ===== */
.board-filters {
  display: flex;
  gap: 12px;
  margin-bottom: 20px;
}

.board-filters select {
  padding: 8px 12px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: var(--radius);
  font-size: 13px;
}

.board-columns {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  overflow-x: auto;
}

.board-col {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  min-height: 300px;
}

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

.board-col-header h3 {
  font-size: 13px;
  color: var(--text-dim);
}

.col-count {
  background: var(--bg-input);
  padding: 2px 8px;
  border-radius: 12px;
  font-size: 11px;
  color: var(--text-dim);
}

.task-card {
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px;
  margin-bottom: 8px;
  cursor: pointer;
  transition: border-color 0.2s;
}

.task-card:hover { border-color: var(--primary); }

.task-card-title {
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 8px;
}

.task-card-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 11px;
  color: var(--text-dim);
}

.platform-badge {
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
}

.platform-instagram { background: #e1306c22; color: #e1306c; }
.platform-tiktok { background: #00f2ea22; color: #00f2ea; }
.platform-youtube { background: #ff000022; color: #ff4444; }

.type-badge {
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 10px;
  background: var(--bg-hover);
}

.assignee-dot {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 9px;
  color: white;
  font-weight: bold;
}

/* ===== CALENDAR ===== */
.calendar-nav {
  display: flex;
  align-items: center;
  gap: 16px;
}

#cal-title {
  font-size: 18px;
  font-weight: 600;
  min-width: 160px;
  text-align: center;
}

.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 2px;
}

.cal-day-header {
  padding: 10px;
  text-align: center;
  font-size: 12px;
  color: var(--text-dim);
  font-weight: 600;
}

.cal-day {
  background: var(--bg-card);
  border: 1px solid var(--border);
  min-height: 100px;
  padding: 8px;
  border-radius: 6px;
}

.cal-day.other-month { opacity: 0.3; }
.cal-day.today { border-color: var(--primary); }

.cal-day-num {
  font-size: 12px;
  color: var(--text-dim);
  margin-bottom: 6px;
}

.cal-task {
  padding: 3px 6px;
  margin-bottom: 3px;
  border-radius: 4px;
  font-size: 10px;
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  border-right: 3px solid;
}

.cal-task:hover { opacity: 0.8; }

/* ===== DASHBOARD / STATS ===== */
.stats-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
}

.stat-card .stat-value {
  font-size: 32px;
  font-weight: 700;
  margin-bottom: 4px;
}

.stat-card .stat-label {
  font-size: 13px;
  color: var(--text-dim);
}

.stats-details {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 16px;
}

.stats-section {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
}

.stats-section h3 {
  font-size: 14px;
  color: var(--text-dim);
  margin-bottom: 16px;
}

.stat-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 10px;
}

.stat-bar-label {
  font-size: 13px;
  min-width: 100px;
}

.stat-bar-fill {
  flex: 1;
  height: 24px;
  background: var(--bg-input);
  border-radius: 4px;
  overflow: hidden;
}

.stat-bar-fill > div {
  height: 100%;
  border-radius: 4px;
  display: flex;
  align-items: center;
  padding-right: 8px;
  font-size: 11px;
  color: white;
  min-width: 30px;
  transition: width 0.3s;
}

/* ===== MODALS ===== */
.modal {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  z-index: 1000;
  justify-content: center;
  align-items: flex-start;
  padding-top: 40px;
  overflow-y: auto;
}

.modal.active { display: flex; }

.modal-content {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 16px;
  width: 520px;
  max-width: 95%;
  padding: 0;
  animation: slideUp 0.2s ease;
}

.modal-wide { width: 800px; }

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

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

.modal-header h2 { font-size: 18px; }

.modal-close {
  background: none;
  border: none;
  color: var(--text-dim);
  font-size: 24px;
  cursor: pointer;
}

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

/* Form inside modal */
#task-form, .detail-body, .detail-footer {
  padding: 20px 24px;
}

.form-row { margin-bottom: 16px; }

.form-row.two-cols {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.form-group label {
  display: block;
  font-size: 13px;
  color: var(--text-dim);
  margin-bottom: 6px;
}

.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  padding: 10px 12px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-size: 14px;
  font-family: inherit;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  outline: none;
  border-color: var(--primary);
}

.form-actions {
  display: flex;
  gap: 12px;
  margin-top: 8px;
}

/* ===== TASK DETAIL ===== */
.detail-body {
  display: grid;
  grid-template-columns: 1fr 300px;
  gap: 24px;
}

.detail-meta {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 20px;
}

.meta-item {
  font-size: 13px;
}

.meta-item .meta-label {
  color: var(--text-dim);
  font-size: 11px;
  display: block;
  margin-bottom: 2px;
}

.detail-section {
  margin-bottom: 16px;
}

.detail-section h3 {
  font-size: 13px;
  color: var(--text-dim);
  margin-bottom: 8px;
}

.detail-section pre {
  white-space: pre-wrap;
  font-family: inherit;
  font-size: 14px;
  background: var(--bg-input);
  padding: 12px;
  border-radius: 8px;
}

.detail-section p {
  font-size: 14px;
}

.material-link {
  display: block;
  padding: 6px 0;
  font-size: 13px;
  word-break: break-all;
}

.detail-status-actions {
  margin-top: 16px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.status-btn {
  padding: 8px 16px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg-input);
  color: var(--text);
  cursor: pointer;
  font-size: 13px;
  transition: all 0.2s;
}

.status-btn:hover { border-color: var(--primary); background: rgba(99,102,241,0.1); }
.status-btn.approve { border-color: var(--success); color: var(--success); }
.status-btn.approve:hover { background: rgba(16,185,129,0.15); }

/* Comments */
.detail-comments {
  border-right: 1px solid var(--border);
  padding-right: 24px;
}

.detail-comments h3 {
  font-size: 14px;
  margin-bottom: 12px;
  color: var(--text-dim);
}

#comments-list {
  max-height: 300px;
  overflow-y: auto;
  margin-bottom: 12px;
}

.comment {
  background: var(--bg-input);
  border-radius: 8px;
  padding: 10px 12px;
  margin-bottom: 8px;
}

.comment-header {
  display: flex;
  justify-content: space-between;
  margin-bottom: 4px;
}

.comment-author {
  font-size: 12px;
  font-weight: 600;
}

.comment-time {
  font-size: 10px;
  color: var(--text-dim);
}

.comment-text {
  font-size: 13px;
  line-height: 1.5;
}

#comment-form {
  display: flex;
  gap: 8px;
}

#comment-form textarea {
  flex: 1;
  padding: 8px 12px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-family: inherit;
  font-size: 13px;
  resize: none;
}

#comment-form textarea:focus { outline: none; border-color: var(--primary); }

#comment-form button {
  padding: 8px 16px;
  font-size: 13px;
}

.detail-footer {
  border-top: 1px solid var(--border);
  display: flex;
  gap: 12px;
}

/* Status colors */
.status-brief_ready { color: var(--text-dim); }
.status-in_progress { color: var(--warning); }
.status-first_version { color: #3b82f6; }
.status-team_review { color: var(--pink); }
.status-revision { color: #f97316; }
.status-manager_review { color: var(--primary); }
.status-final_revision { color: #f97316; }
.status-approved { color: var(--success); }
.status-published { color: #06b6d4; }

/* ===== CHECKBOX GROUP ===== */
/* ===== TOGGLE SWITCH ===== */
.toggle-label {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  color: var(--text);
  padding: 10px 14px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 10px;
  transition: all 0.3s;
}

.toggle-label:has(input:checked) {
  border-color: var(--primary);
  background: rgba(99,102,241,0.1);
}

.toggle-label input[type="checkbox"] {
  display: none;
}

.toggle-switch {
  position: relative;
  width: 42px;
  height: 24px;
  background: var(--border);
  border-radius: 12px;
  flex-shrink: 0;
  transition: background 0.3s;
}

.toggle-switch::after {
  content: '';
  position: absolute;
  top: 3px;
  right: 3px;
  width: 18px;
  height: 18px;
  background: var(--text-dim);
  border-radius: 50%;
  transition: all 0.3s;
}

.toggle-label input:checked + .toggle-switch {
  background: var(--primary);
}

.toggle-label input:checked + .toggle-switch::after {
  right: 21px;
  background: #fff;
}

.toggle-hint {
  display: block;
  font-size: 12px;
  color: var(--text-dim);
  margin-top: 6px;
  padding-right: 4px;
}

.toggle-hint.direct-publish {
  color: var(--success);
}

.checkbox-group {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  padding: 8px 0;
}

.checkbox-label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px !important;
  color: var(--text) !important;
  cursor: pointer;
  padding: 6px 12px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 8px;
  transition: all 0.2s;
}

.checkbox-label:has(input:checked) {
  border-color: var(--primary);
  background: rgba(99,102,241,0.15);
}

.checkbox-label input[type="checkbox"] {
  width: auto;
  accent-color: var(--primary);
}

/* ===== PUBLISH PAGE ===== */
.publish-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 20px;
}

.publish-tab {
  padding: 10px 24px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-dim);
  cursor: pointer;
  font-size: 14px;
  transition: all 0.2s;
}

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

.publish-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 20px;
  margin-bottom: 12px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
}

.publish-card-info {
  flex: 1;
}

.publish-card-title {
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 6px;
}

.publish-card-meta {
  display: flex;
  gap: 12px;
  align-items: center;
  font-size: 12px;
  color: var(--text-dim);
}

.publish-card-actions {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-shrink: 0;
}

.publish-link-input {
  padding: 8px 12px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-size: 13px;
  width: 240px;
  direction: ltr;
}

.publish-link-input:focus { outline: none; border-color: var(--primary); }

.btn-publish {
  padding: 8px 20px;
  background: #06b6d4;
  color: white;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  font-size: 13px;
  white-space: nowrap;
}

.btn-publish:hover { background: #0891b2; }

.published-badge {
  color: #06b6d4;
  font-size: 13px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.publish-empty {
  text-align: center;
  color: var(--text-dim);
  padding: 48px 0;
  font-size: 14px;
}

/* Publish card - clickable */
.publish-card {
  cursor: pointer;
  transition: border-color 0.2s;
}
.publish-card:hover { border-color: var(--primary); }

.publish-card-status {
  display: flex;
  gap: 6px;
  margin-top: 6px;
}

.pub-platform-chip {
  padding: 2px 10px;
  border-radius: 12px;
  font-size: 10px;
  font-weight: 600;
}

.pub-chip-ready { background: rgba(245,158,11,0.15); color: #f59e0b; }
.pub-chip-done { background: rgba(6,182,212,0.15); color: #06b6d4; }

/* ===== PUBLISH DETAIL MODAL ===== */
.pub-modal-body {
  padding: 20px 24px;
  max-height: 75vh;
  overflow-y: auto;
}

.pub-summary {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  align-items: center;
  margin-bottom: 20px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border);
}

.pub-section {
  margin-bottom: 20px;
}

.pub-section h3 {
  font-size: 14px;
  color: var(--text-dim);
  margin-bottom: 10px;
}

.pub-section textarea,
.pub-section input[type="text"],
.pub-section input[type="datetime-local"] {
  width: 100%;
  padding: 10px 12px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-size: 14px;
  font-family: inherit;
}

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

/* Per-platform block */
.pub-platform-block {
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 16px;
  overflow: hidden;
}

.pub-platform-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  background: var(--bg-hover);
  border-bottom: 1px solid var(--border);
}

.pub-platform-header h4 {
  font-size: 14px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.pub-platform-fields {
  padding: 16px;
  display: grid;
  gap: 12px;
}

.pub-field label {
  display: block;
  font-size: 12px;
  color: var(--text-dim);
  margin-bottom: 4px;
}

.pub-field textarea,
.pub-field input {
  width: 100%;
  padding: 8px 12px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-size: 13px;
  font-family: inherit;
}

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

.pub-field-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

/* Published toggle */
.pub-toggle {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 0;
}

.pub-toggle label {
  font-size: 13px;
  color: var(--text);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
}

.pub-toggle input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: #06b6d4;
}

.pub-actions {
  display: flex;
  gap: 12px;
  margin-top: 8px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

/* Platform-specific colors for headers */
.pub-platform-header.instagram { border-right: 4px solid #e1306c; }
.pub-platform-header.tiktok { border-right: 4px solid #00f2ea; }
.pub-platform-header.youtube { border-right: 4px solid #ff4444; }

/* ===== RESPONSIVE ===== */
@media (max-width: 1100px) {
  .board-columns { grid-template-columns: repeat(2, 1fr); }
  .detail-body { grid-template-columns: 1fr; }
  .detail-comments { border-right: none; padding-right: 0; border-top: 1px solid var(--border); padding-top: 16px; }
}

@media (max-width: 768px) {
  #sidebar { width: 60px; }
  .sidebar-header h2 { font-size: 16px; }
  #user-badge, .nav-link { font-size: 12px; }
  .nav-link { padding: 12px 8px; text-align: center; }
  #content { margin-right: 60px; padding: 16px; }
  .board-columns { grid-template-columns: 1fr; }
  .form-row.two-cols { grid-template-columns: 1fr; }
  .calendar-grid { font-size: 11px; }
  .cal-day { min-height: 60px; padding: 4px; }
}
