/* ==========================================================================
   Cloud MySQL Studio - Modern Dark Glassmorphism UI
   ========================================================================== */

:root {
  --bg-main: #0a0d14;
  --bg-surface: #111726;
  --bg-surface-elevated: #182238;
  --bg-card: rgba(17, 24, 39, 0.75);
  --bg-card-hover: rgba(30, 41, 59, 0.85);
  --border-color: rgba(255, 255, 255, 0.08);
  --border-focus: #6366f1;
  
  --text-main: #f3f4f6;
  --text-muted: #9ca3af;
  --text-dim: #6b7280;
  
  --primary: #6366f1;
  --primary-hover: #4f46e5;
  --primary-glow: rgba(99, 102, 241, 0.25);
  --accent-cyan: #06b6d4;
  --accent-emerald: #10b981;
  --accent-amber: #f59e0b;
  --accent-rose: #f43f5e;
  --accent-purple: #a855f7;

  --font-sans: 'Pretendard', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', Menlo, Monaco, Consolas, monospace;

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --radius-xl: 20px;
  
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.3), 0 2px 4px -2px rgba(0, 0, 0, 0.3);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.4), 0 4px 6px -4px rgba(0, 0, 0, 0.4);
  --shadow-glow: 0 0 25px rgba(99, 102, 241, 0.2);

  --header-height: 56px;
  --sidebar-width: 280px;
}

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

body {
  font-family: var(--font-sans);
  background-color: var(--bg-main);
  color: var(--text-main);
  min-height: 100vh;
  overflow: hidden;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* Background ambient glows */
.ambient-glow-1 {
  position: fixed;
  top: -10%;
  left: 20%;
  width: 500px;
  height: 500px;
  background: radial-gradient(circle, rgba(99, 102, 241, 0.12) 0%, rgba(0, 0, 0, 0) 70%);
  pointer-events: none;
  z-index: 0;
}

.ambient-glow-2 {
  position: fixed;
  bottom: -10%;
  right: 10%;
  width: 600px;
  height: 600px;
  background: radial-gradient(circle, rgba(6, 182, 212, 0.08) 0%, rgba(0, 0, 0, 0) 70%);
  pointer-events: none;
  z-index: 0;
}

/* Custom Scrollbar */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
::-webkit-scrollbar-track {
  background: rgba(0, 0, 0, 0.2);
}
::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.15);
  border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.25);
}

/* Layout */
#app {
  display: flex;
  flex-direction: column;
  height: 100vh;
  position: relative;
  z-index: 1;
}

/* Header */
.app-header {
  height: var(--header-height);
  background: rgba(17, 23, 38, 0.85);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1.25rem;
  z-index: 20;
}

.header-brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.brand-logo {
  width: 32px;
  height: 32px;
  background: linear-gradient(135deg, var(--primary), var(--accent-cyan));
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-glow);
  color: white;
}

.brand-title {
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  background: linear-gradient(90deg, #ffffff, #cbd5e1);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.brand-badge {
  font-size: 0.65rem;
  font-weight: 600;
  padding: 2px 6px;
  background: rgba(99, 102, 241, 0.15);
  color: #a5b4fc;
  border: 1px solid rgba(99, 102, 241, 0.3);
  border-radius: 9999px;
  text-transform: uppercase;
}

.header-breadcrumbs {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.crumb-db {
  font-weight: 600;
  color: #818cf8;
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.crumb-table {
  font-weight: 600;
  color: #38bdf8;
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

/* App Body (Sidebar + Content) */
.app-body {
  display: flex;
  flex: 1;
  overflow: hidden;
}

/* Sidebar */
.app-sidebar {
  width: var(--sidebar-width);
  background: rgba(15, 21, 37, 0.7);
  backdrop-filter: blur(16px);
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  user-select: none;
}

.sidebar-search-box {
  padding: 0.85rem;
  border-bottom: 1px solid var(--border-color);
}

.search-input-wrapper {
  position: relative;
  display: flex;
  align-items: center;
}

.search-input-wrapper i {
  position: absolute;
  left: 0.65rem;
  color: var(--text-dim);
  font-size: 0.85rem;
}

.search-input-wrapper input {
  width: 100%;
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 0.4rem 0.65rem 0.4rem 2rem;
  color: var(--text-main);
  font-size: 0.8rem;
  outline: none;
  transition: border-color 0.2s;
}

.search-input-wrapper input:focus {
  border-color: var(--border-focus);
}

.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  padding: 0.5rem;
}

.db-group {
  margin-bottom: 0.4rem;
}

.db-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.45rem 0.6rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  color: var(--text-muted);
  font-size: 0.82rem;
  font-weight: 600;
  transition: all 0.15s ease;
}

.db-header:hover {
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-main);
}

.db-header.active {
  background: rgba(99, 102, 241, 0.15);
  color: #c7d2fe;
}

.db-header .db-title {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.db-header .db-badge {
  font-size: 0.7rem;
  background: rgba(255, 255, 255, 0.06);
  padding: 1px 6px;
  border-radius: 9999px;
  color: var(--text-dim);
}

.table-list {
  padding-left: 0.9rem;
  margin-top: 0.2rem;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.table-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.35rem 0.6rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  color: #94a3b8;
  font-size: 0.78rem;
  transition: all 0.15s ease;
}

.table-item:hover {
  background: rgba(255, 255, 255, 0.04);
  color: var(--text-main);
}

.table-item.active {
  background: linear-gradient(90deg, rgba(99, 102, 241, 0.25), rgba(6, 182, 212, 0.1));
  color: #ffffff;
  font-weight: 600;
  border-left: 2px solid var(--primary);
}

.table-item .tbl-name {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.table-item .tbl-rows {
  font-size: 0.7rem;
  color: var(--text-dim);
}

/* Main Content Area */
.app-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: rgba(10, 13, 20, 0.6);
}

/* Tabs Bar */
.main-tabs-bar {
  background: rgba(17, 24, 39, 0.5);
  border-bottom: 1px solid var(--border-color);
  padding: 0 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.tab-nav {
  display: flex;
  gap: 0.25rem;
}

.tab-btn {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.75rem 1rem;
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--text-muted);
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
}

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

.tab-btn.active {
  color: #818cf8;
  border-bottom-color: var(--primary);
  font-weight: 600;
}

.tab-content-container {
  flex: 1;
  overflow-y: auto;
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
}

/* Toolbars */
.data-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-bottom: 1rem;
  background: rgba(17, 24, 39, 0.6);
  padding: 0.65rem 1rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
}

.toolbar-left, .toolbar-right {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.45rem 0.85rem;
  border-radius: var(--radius-sm);
  font-size: 0.82rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s ease;
  border: 1px solid transparent;
  outline: none;
}

.btn-primary {
  background: linear-gradient(135deg, var(--primary), #4338ca);
  color: #ffffff;
  box-shadow: 0 2px 4px rgba(99, 102, 241, 0.3);
}
.btn-primary:hover {
  background: linear-gradient(135deg, #4f46e5, #3730a3);
  transform: translateY(-1px);
}

.btn-secondary {
  background: rgba(255, 255, 255, 0.06);
  border-color: var(--border-color);
  color: var(--text-main);
}
.btn-secondary:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.15);
}

.btn-danger {
  background: rgba(244, 63, 94, 0.15);
  border-color: rgba(244, 63, 94, 0.3);
  color: #fb7185;
}
.btn-danger:hover {
  background: rgba(244, 63, 94, 0.25);
  color: #ffffff;
}

.btn-sm {
  padding: 0.25rem 0.5rem;
  font-size: 0.75rem;
}

.btn-icon {
  padding: 0.45rem;
  border-radius: var(--radius-sm);
}

/* Form Controls */
.input-control {
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 0.4rem 0.65rem;
  color: var(--text-main);
  font-size: 0.82rem;
  outline: none;
  transition: border-color 0.2s;
}

.input-control:focus {
  border-color: var(--border-focus);
}

select.input-control {
  cursor: pointer;
}

/* Data Table Wrapper */
.table-responsive {
  flex: 1;
  overflow: auto;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  background: rgba(17, 24, 39, 0.4);
  position: relative;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.8rem;
  white-space: nowrap;
}

.data-table th {
  position: sticky;
  top: 0;
  background: #161f36;
  color: #94a3b8;
  font-weight: 600;
  text-align: left;
  padding: 0.6rem 0.85rem;
  border-bottom: 1px solid var(--border-color);
  border-right: 1px solid rgba(255, 255, 255, 0.04);
  z-index: 10;
  user-select: none;
}

.data-table th.sortable {
  cursor: pointer;
}
.data-table th.sortable:hover {
  color: #ffffff;
  background: #1c2744;
}

.data-table td {
  padding: 0.5rem 0.85rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
  border-right: 1px solid rgba(255, 255, 255, 0.02);
  color: #e2e8f0;
  max-width: 300px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.data-table tr:hover td {
  background: rgba(255, 255, 255, 0.03);
}

.cell-null {
  color: #64748b;
  font-style: italic;
  font-size: 0.72rem;
}

.cell-pk {
  font-weight: 600;
  color: #38bdf8;
}

.cell-actions {
  display: flex;
  gap: 4px;
}

/* Pagination Bar */
.pagination-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 0.85rem;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.pagination-controls {
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

/* SQL Console */
.sql-console-container {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  flex: 1;
}

.sql-editor-card {
  background: rgba(17, 24, 39, 0.7);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.sql-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.5rem 0.85rem;
  background: rgba(15, 23, 42, 0.8);
  border-bottom: 1px solid var(--border-color);
}

.sql-textarea {
  width: 100%;
  min-height: 140px;
  background: #0d1117;
  color: #58a6ff;
  border: none;
  padding: 0.85rem;
  font-family: var(--font-mono);
  font-size: 0.85rem;
  line-height: 1.5;
  resize: vertical;
  outline: none;
}

.sql-results-card {
  flex: 1;
  display: flex;
  flex-direction: column;
  background: rgba(17, 24, 39, 0.6);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 0.85rem;
  overflow: hidden;
}

/* Cards & Stats Grid */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1rem;
  margin-bottom: 1.25rem;
}

.stat-card {
  background: rgba(17, 24, 39, 0.7);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1rem;
  display: flex;
  align-items: center;
  gap: 0.85rem;
}

.stat-icon {
  width: 42px;
  height: 42px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
}

.stat-icon.blue { background: rgba(56, 189, 248, 0.15); color: #38bdf8; }
.stat-icon.purple { background: rgba(168, 85, 247, 0.15); color: #a855f7; }
.stat-icon.green { background: rgba(16, 185, 129, 0.15); color: #10b981; }
.stat-icon.amber { background: rgba(245, 158, 11, 0.15); color: #f59e0b; }

.stat-info .stat-label {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.stat-info .stat-value {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text-main);
}

/* Code Snippet Box */
.code-box {
  background: #0d1117;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1rem;
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: #c9d1d9;
  overflow-x: auto;
  position: relative;
  white-space: pre-wrap;
}

.btn-copy-code {
  position: absolute;
  top: 0.5rem;
  right: 0.5rem;
}

/* Modals */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}

.modal-backdrop.show {
  opacity: 1;
  pointer-events: auto;
}

.modal-dialog {
  background: #131b2e;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: var(--radius-lg);
  width: 90%;
  max-width: 650px;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-lg), 0 0 30px rgba(0, 0, 0, 0.5);
  transform: translateY(20px);
  transition: transform 0.2s ease;
}

.modal-backdrop.show .modal-dialog {
  transform: translateY(0);
}

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

.modal-title {
  font-size: 1rem;
  font-weight: 600;
  color: #ffffff;
}

.modal-body {
  padding: 1.25rem;
  overflow-y: auto;
  flex: 1;
}

.modal-footer {
  padding: 0.85rem 1.25rem;
  border-top: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.5rem;
}

/* Form Styles */
.form-group {
  margin-bottom: 0.85rem;
}

.form-label {
  display: block;
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--text-muted);
  margin-bottom: 0.35rem;
}

.form-control {
  width: 100%;
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 0.5rem 0.75rem;
  color: var(--text-main);
  font-size: 0.82rem;
  outline: none;
}

.form-control:focus {
  border-color: var(--border-focus);
}

/* Toast Notifications */
#toast-container {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  z-index: 999;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.toast {
  background: #1e293b;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 0.75rem 1rem;
  color: #ffffff;
  font-size: 0.82rem;
  display: flex;
  align-items: center;
  gap: 0.65rem;
  box-shadow: var(--shadow-lg);
  animation: slideIn 0.25s ease forwards;
  min-width: 260px;
}

.toast.success { border-left: 3px solid var(--accent-emerald); }
.toast.error { border-left: 3px solid var(--accent-rose); }
.toast.info { border-left: 3px solid var(--accent-cyan); }

@keyframes slideIn {
  from { opacity: 0; transform: translateX(50px); }
  to { opacity: 1; transform: translateX(0); }
}

/* Login Screen View */
.login-screen {
  position: fixed;
  inset: 0;
  background: #090d16;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 500;
}

.login-card {
  width: 100%;
  max-width: 400px;
  background: rgba(17, 24, 39, 0.85);
  backdrop-filter: blur(20px);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: var(--radius-xl);
  padding: 2.25rem 2rem;
  box-shadow: var(--shadow-lg), 0 0 50px rgba(99, 102, 241, 0.15);
  text-align: center;
}

.login-logo {
  width: 52px;
  height: 52px;
  margin: 0 auto 1.25rem auto;
  background: linear-gradient(135deg, var(--primary), var(--accent-cyan));
  border-radius: var(--radius-lg);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  color: white;
  box-shadow: var(--shadow-glow);
}

.login-title {
  font-size: 1.25rem;
  font-weight: 700;
  color: #ffffff;
  margin-bottom: 0.35rem;
}

.login-subtitle {
  font-size: 0.82rem;
  color: var(--text-muted);
  margin-bottom: 1.75rem;
}

/* ==========================================================================
   Email Report Management & Live Preview Styles
   ========================================================================== */
.email-report-layout {
  display: grid;
  grid-template-columns: 380px 1fr;
  gap: 1.25rem;
  height: calc(100vh - var(--header-height) - 75px);
  overflow: hidden;
}

@media (max-width: 1024px) {
  .email-report-layout {
    grid-template-columns: 1fr;
    height: auto;
    overflow-y: auto;
  }
}

.email-settings-panel {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  overflow-y: auto;
  padding-right: 0.35rem;
}

.email-card {
  background: rgba(17, 24, 39, 0.7);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}

.email-card-title {
  font-size: 0.9rem;
  font-weight: 600;
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.email-preview-panel {
  display: flex;
  flex-direction: column;
  background: rgba(17, 24, 39, 0.6);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  overflow: hidden;
}

.email-preview-header {
  padding: 0.65rem 1rem;
  background: rgba(15, 23, 42, 0.85);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.device-switcher {
  display: flex;
  align-items: center;
  gap: 4px;
  background: rgba(0, 0, 0, 0.3);
  padding: 2px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
}

.device-btn {
  padding: 3px 8px;
  border: none;
  background: transparent;
  color: var(--text-dim);
  border-radius: 4px;
  cursor: pointer;
  font-size: 0.75rem;
  transition: all 0.15s;
}

.device-btn.active {
  background: var(--primary);
  color: #ffffff;
}

.email-preview-body {
  flex: 1;
  background: #cbd5e1;
  overflow: auto;
  display: flex;
  justify-content: center;
  padding: 1.5rem;
  transition: all 0.25s ease;
}

.email-preview-frame {
  width: 100%;
  max-width: 680px;
  background: #ffffff;
  border-radius: 12px;
  box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.3), 0 8px 10px -6px rgba(0, 0, 0, 0.3);
  border: none;
  height: 100%;
  min-height: 520px;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.email-preview-frame.mobile-view {
  max-width: 375px;
  border-radius: 24px;
  border: 8px solid #1e293b;
}

/* Switch Toggle */
.switch-toggle {
  position: relative;
  display: inline-block;
  width: 34px;
  height: 18px;
}

.switch-toggle input {
  opacity: 0;
  width: 0;
  height: 0;
}

.switch-slider {
  position: absolute;
  cursor: pointer;
  inset: 0;
  background-color: rgba(255, 255, 255, 0.15);
  transition: .2s;
  border-radius: 34px;
}

.switch-slider:before {
  position: absolute;
  content: "";
  height: 12px;
  width: 12px;
  left: 3px;
  bottom: 3px;
  background-color: white;
  transition: .2s;
  border-radius: 50%;
}

input:checked + .switch-slider {
  background-color: var(--accent-emerald);
}

input:checked + .switch-slider:before {
  transform: translateX(16px);
}

