/* ==========================================================================
   STUDIO TABART - SMS & LMS Gateway Stylesheet
   Modern Glassmorphic Dark UI & Mobile Mockup
   ========================================================================== */

:root {
  --bg-base: #090d16;
  --bg-surface: #111827;
  --bg-card: rgba(17, 24, 39, 0.85);
  --bg-card-hover: rgba(30, 41, 59, 0.95);
  --border: rgba(255, 255, 255, 0.08);
  --border-hover: rgba(99, 102, 241, 0.4);
  
  --text-primary: #f8fafc;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;

  --accent-primary: #6366f1;
  --accent-primary-hover: #4f46e5;
  --accent-cyan: #0ea5e9;
  --accent-emerald: #10b981;
  --accent-amber: #f59e0b;
  --accent-rose: #f43f5e;
  --accent-glow: rgba(99, 102, 241, 0.35);

  --shadow-sm: 0 4px 6px -1px rgba(0, 0, 0, 0.2);
  --shadow-md: 0 10px 25px -3px rgba(0, 0, 0, 0.3);
  --shadow-lg: 0 20px 40px -5px rgba(0, 0, 0, 0.5);

  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 20px;
}

[data-theme="light"] {
  --bg-base: #f8fafc;
  --bg-surface: #ffffff;
  --bg-card: rgba(255, 255, 255, 0.92);
  --bg-card-hover: #f1f5f9;
  --border: rgba(0, 0, 0, 0.08);
  --border-hover: rgba(99, 102, 241, 0.4);
  
  --text-primary: #0f172a;
  --text-secondary: #475569;
  --text-muted: #94a3b8;

  --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.05);
  --shadow-md: 0 8px 16px rgba(0, 0, 0, 0.08);
  --shadow-lg: 0 16px 32px rgba(0, 0, 0, 0.12);
}

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

body {
  font-family: 'Pretendard', -apple-system, BlinkMacSystemFont, 'Inter', sans-serif;
  background-color: var(--bg-base);
  color: var(--text-primary);
  line-height: 1.5;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
}

/* Header */
.header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--bg-card);
  backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border);
}

.nav-container {
  max-width: 1400px;
  margin: 0 auto;
  padding: 0.85rem 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

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

.logo-icon {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-sm);
  background: linear-gradient(135deg, var(--accent-primary), var(--accent-cyan));
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  box-shadow: 0 4px 12px var(--accent-glow);
}
.logo-icon svg { width: 22px; height: 22px; }

.logo-text {
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
}

.brand-title {
  font-size: 1.25rem;
  font-weight: 800;
  letter-spacing: -0.5px;
  color: var(--text-primary);
}

.accent-dot { color: var(--accent-primary); }

.brand-badge {
  font-size: 0.68rem;
  font-weight: 700;
  padding: 0.2rem 0.5rem;
  border-radius: 4px;
  background: rgba(99, 102, 241, 0.15);
  border: 1px solid rgba(99, 102, 241, 0.3);
  color: var(--accent-primary);
  letter-spacing: 0.5px;
}

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

.sender-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.4rem 0.8rem;
  border-radius: 9999px;
  background: rgba(16, 185, 129, 0.12);
  border: 1px solid rgba(16, 185, 129, 0.3);
  color: var(--accent-emerald);
  font-size: 0.82rem;
}
.sender-badge svg { width: 15px; height: 15px; }

.balance-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.4rem 0.85rem;
  border-radius: 9999px;
  background: rgba(245, 158, 11, 0.12);
  border: 1px solid rgba(245, 158, 11, 0.3);
  color: var(--accent-amber);
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}
.balance-pill:hover {
  background: rgba(245, 158, 11, 0.22);
}
.balance-pill svg { width: 15px; height: 15px; }

.admin-auth-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.45rem 0.85rem;
  border-radius: var(--radius-sm);
  background: var(--bg-surface);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}
.admin-auth-btn:hover {
  color: var(--text-primary);
  border-color: var(--accent-primary);
}
.admin-auth-btn.authorized {
  background: rgba(16, 185, 129, 0.15);
  border-color: var(--accent-emerald);
  color: var(--accent-emerald);
}
.admin-auth-btn svg { width: 14px; height: 14px; }

.btn-icon, .theme-btn {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  background: var(--bg-surface);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
  cursor: pointer;
  text-decoration: none;
  transition: all 0.2s;
}
.btn-icon:hover, .theme-btn:hover {
  color: var(--text-primary);
  border-color: var(--accent-primary);
}
.btn-icon svg, .theme-btn svg { width: 18px; height: 18px; }

.sun-icon { display: none; }
.moon-icon { display: block; }
[data-theme="light"] .sun-icon { display: block; }
[data-theme="light"] .moon-icon { display: none; }

/* Main Container */
.main-container {
  max-width: 1400px;
  width: 100%;
  margin: 1.75rem auto;
  padding: 0 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1.75rem;
  flex: 1;
}

/* Card */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.75rem;
  backdrop-filter: blur(16px);
  box-shadow: var(--shadow-md);
}

/* Top Workspace Grid */
.sms-workspace-grid {
  display: grid;
  grid-template-columns: 1.15fr 0.85fr;
  gap: 1.75rem;
}

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

.pane-title-wrap {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}
.pane-icon { width: 24px; height: 24px; color: var(--accent-primary); }
.pane-title { font-size: 1.2rem; font-weight: 800; color: var(--text-primary); }
.pane-desc { font-size: 0.8rem; color: var(--text-muted); }

.badge-sms {
  font-size: 0.75rem;
  font-weight: 800;
  padding: 0.3rem 0.75rem;
  border-radius: 9999px;
  background: rgba(16, 185, 129, 0.15);
  border: 1px solid rgba(16, 185, 129, 0.35);
  color: var(--accent-emerald);
  letter-spacing: 0.5px;
}
.badge-lms {
  font-size: 0.75rem;
  font-weight: 800;
  padding: 0.3rem 0.75rem;
  border-radius: 9999px;
  background: rgba(168, 85, 247, 0.15);
  border: 1px solid rgba(168, 85, 247, 0.35);
  color: #c084fc;
  letter-spacing: 0.5px;
}

/* Form Styles */
.form-row {
  display: flex;
  gap: 1rem;
}
.flex-1 { flex: 1; }

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

.form-label {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 0.4rem;
}
.form-label svg { width: 14px; height: 14px; color: var(--accent-primary); }

.form-input, .form-textarea {
  width: 100%;
  padding: 0.75rem 1rem;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 0.92rem;
  font-family: inherit;
  outline: none;
  transition: all 0.2s;
}
.form-input:focus, .form-textarea:focus {
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 3px var(--accent-glow);
}
.form-input.readonly {
  background: rgba(255, 255, 255, 0.03);
  color: var(--text-muted);
  cursor: not-allowed;
  border: none;
  padding-left: 0.5rem;
}

.input-readonly-box {
  display: flex;
  align-items: center;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0 0.75rem;
}

.count-pill {
  font-size: 0.72rem;
  font-weight: 700;
  padding: 0.15rem 0.5rem;
  border-radius: 9999px;
  background: rgba(99, 102, 241, 0.15);
  color: var(--accent-primary);
}

.byte-counter-wrap {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--text-muted);
}
.byte-counter-wrap span { color: var(--text-primary); }

.byte-progress-track {
  height: 5px;
  background: var(--border);
  border-radius: 9999px;
  overflow: hidden;
  margin-top: 0.4rem;
}
.byte-progress-fill {
  height: 100%;
  width: 0%;
  background: var(--accent-emerald);
  transition: width 0.15s ease, background-color 0.3s;
}
.byte-progress-fill.lms-mode {
  background: #a855f7;
}

/* Preset Tags */
.preset-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}
.preset-tag {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  font-size: 0.78rem;
  font-weight: 600;
  padding: 0.35rem 0.75rem;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s;
}
.preset-tag:hover {
  background: var(--bg-card-hover);
  border-color: var(--accent-primary);
  color: var(--accent-primary);
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.75rem 1.4rem;
  font-size: 0.9rem;
  font-weight: 700;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  border: 1px solid transparent;
}
.btn-sm {
  padding: 0.45rem 0.85rem;
  font-size: 0.8rem;
}
.btn svg { width: 16px; height: 16px; }

.btn-primary {
  background: linear-gradient(135deg, var(--accent-primary), #4338ca);
  color: #fff;
  box-shadow: 0 4px 14px var(--accent-glow);
}
.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 20px var(--accent-glow);
}

.btn-secondary {
  background: var(--bg-surface);
  color: var(--text-primary);
  border-color: var(--border);
}
.btn-secondary:hover {
  background: var(--bg-card-hover);
  border-color: var(--border-hover);
}

.form-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.75rem;
  margin-top: 1.5rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--border);
}
.btn-submit-send {
  flex: 1;
}

/* Right Smartphone Mockup */
.phone-mockup {
  width: 280px;
  height: 380px;
  margin: 0 auto 1.25rem auto;
  background: #000;
  border-radius: 36px;
  border: 4px solid #334155;
  box-shadow: 0 15px 35px rgba(0, 0, 0, 0.6);
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
.phone-notch {
  width: 100px;
  height: 18px;
  background: #334155;
  border-bottom-left-radius: 12px;
  border-bottom-right-radius: 12px;
  margin: 0 auto;
  position: absolute;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  z-index: 10;
}
.phone-screen {
  flex: 1;
  background: #0f172a;
  padding: 1.8rem 0.85rem 0.85rem 0.85rem;
  display: flex;
  flex-direction: column;
}
.phone-header-bar {
  text-align: center;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  margin-bottom: 0.85rem;
}
.phone-sender-name {
  display: block;
  font-size: 0.78rem;
  font-weight: 700;
  color: #f8fafc;
}
.phone-time {
  font-size: 0.65rem;
  color: #64748b;
}
.phone-chat-area {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
}
.phone-bubble {
  background: #1e293b;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 14px;
  border-bottom-left-radius: 2px;
  padding: 0.75rem 0.85rem;
  color: #f8fafc;
  font-size: 0.78rem;
  line-height: 1.45;
  word-break: break-word;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}
.phone-subject {
  font-weight: 800;
  color: #38bdf8;
  margin-bottom: 0.35rem;
  font-size: 0.8rem;
}
.phone-text {
  white-space: pre-wrap;
}
.phone-timestamp {
  display: block;
  text-align: right;
  font-size: 0.62rem;
  color: #64748b;
  margin-top: 0.35rem;
}

.preview-spec-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.85rem 1rem;
}
.spec-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.35rem 0;
  font-size: 0.8rem;
}
.spec-row:not(:last-child) { border-bottom: 1px solid var(--border); }
.spec-label { color: var(--text-muted); }
.spec-value { font-weight: 700; color: var(--text-primary); }
.spec-value.highlight { color: var(--accent-emerald); }

/* History Section */
.history-section {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}
.history-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 1rem;
}
.history-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}
.search-box {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.45rem 0.85rem;
}
.search-box svg { width: 15px; height: 15px; color: var(--text-muted); }
.search-box input {
  background: transparent;
  border: none;
  color: var(--text-primary);
  font-size: 0.82rem;
  outline: none;
  width: 180px;
}

/* Data Table */
.table-responsive {
  width: 100%;
  overflow-x: auto;
}
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.84rem;
  text-align: left;
}
.data-table th {
  background: var(--bg-surface);
  padding: 0.75rem 1rem;
  font-weight: 700;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.data-table td {
  padding: 0.85rem 1rem;
  border-bottom: 1px solid var(--border);
  color: var(--text-secondary);
}
.data-table tr:hover td {
  background: var(--bg-card-hover);
  color: var(--text-primary);
}

.table-loading {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--text-muted);
}
.spin-icon {
  width: 24px;
  height: 24px;
  animation: spin 1s infinite linear;
  margin-bottom: 0.4rem;
  color: var(--accent-primary);
}
@keyframes spin { 100% { transform: rotate(360deg); } }

.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.2rem 0.55rem;
  border-radius: 4px;
  font-size: 0.72rem;
  font-weight: 700;
}
.status-badge.success {
  background: rgba(16, 185, 129, 0.15);
  color: var(--accent-emerald);
  border: 1px solid rgba(16, 185, 129, 0.3);
}
.status-badge.fail {
  background: rgba(244, 63, 94, 0.15);
  color: var(--accent-rose);
  border: 1px solid rgba(244, 63, 94, 0.3);
}

.table-pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: 0.5rem;
  font-size: 0.82rem;
  color: var(--text-muted);
}
.pagination-btns { display: flex; gap: 0.35rem; }
.page-btn {
  padding: 0.3rem 0.65rem;
  border-radius: 4px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  color: var(--text-primary);
  cursor: pointer;
}
.page-btn.active {
  background: var(--accent-primary);
  color: #fff;
  border-color: transparent;
}

/* Modal */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.8);
  backdrop-filter: blur(8px);
  z-index: 10000;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}
.modal-overlay.active { display: flex; }

.modal-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  width: 100%;
  max-width: 420px;
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  animation: popIn 0.2s ease;
}
@keyframes popIn { from { opacity: 0; transform: scale(0.95); } to { opacity: 1; transform: scale(1); } }

.modal-header {
  padding: 1.2rem 1.5rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.modal-badge-icon {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--accent-amber), #ea580c);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
}
.modal-badge-icon svg { width: 18px; height: 18px; }
.modal-head-title { font-size: 1.05rem; font-weight: 700; color: var(--text-primary); }
.modal-head-desc { font-size: 0.78rem; color: var(--text-muted); }
.modal-close {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
}
.modal-body { padding: 1.5rem; }
.modal-footer {
  padding: 1rem 1.5rem;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: 0.75rem;
}
.error-text { color: var(--accent-rose); font-size: 0.8rem; margin-top: 0.4rem; }

/* Toast */
.toast {
  position: fixed;
  bottom: 2rem;
  right: 2rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  padding: 0.85rem 1.25rem;
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-lg);
  font-size: 0.88rem;
  font-weight: 600;
  z-index: 20000;
  display: none;
  animation: slideToast 0.3s ease;
}
@keyframes slideToast { from { transform: translateY(20px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }

/* Footer */
.footer {
  background: var(--bg-surface);
  border-top: 1px solid var(--border);
  padding: 1.5rem;
  margin-top: auto;
  font-size: 0.8rem;
  color: var(--text-muted);
}
.footer-inner {
  max-width: 1400px;
  margin: 0 auto;
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 1rem;
}

@media (max-width: 900px) {
  .sms-workspace-grid { grid-template-columns: 1fr; }
  .form-row { flex-direction: column; }
  .phone-mockup { width: 100%; max-width: 320px; }
}
