/* ============================================
   JVision AI Admin Panel — Complete Stylesheet
   ============================================ */

/* --- CSS Reset --- */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    font-size: 16px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    scroll-behavior: smooth;
}

::-webkit-scrollbar { width: 3px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(26,63,255,0.4); border-radius: 2px; }

body {
    font-family: 'Rajdhani', 'Noto Sans TC', sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    min-height: 100vh;
}

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

img { max-width: 100%; display: block; }

ul, ol { list-style: none; }

h1, h2, h3, h4, h5, h6 {
    font-family: 'Orbitron', 'Noto Sans TC', sans-serif;
    font-weight: 700;
    color: var(--text);
    line-height: 1.3;
}

/* --- CSS Variables --- */
:root {
    --bg: #080e1c;
    --surface: #1d253a;
    --sidebar-bg: #12192a;
    --primary: #1a3fff;
    --primary-hover: #1533d4;
    --accent: #3eb7ff;
    --green: #00d278;
    --red: #ff6b6b;
    --red-hover: #e04545;
    --yellow: #ffb347;
    --text: #e3e7fc;
    --text-secondary: rgba(165, 170, 190, 1);
    --border: rgba(255, 255, 255, 0.06);
    --border-light: rgba(255, 255, 255, 0.1);
    --glass-bg: rgba(29, 37, 58, 0.7);
    --glass-blur: blur(12px);
    --radius-card: 12px;
    --radius-input: 8px;
    --sidebar-width: 240px;
    --transition: 0.25s ease;
}

/* --- Layout: Sidebar + Main --- */
.admin-layout {
    display: flex;
    min-height: 100vh;
}

/* --- Sidebar --- */
.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: var(--sidebar-width);
    height: 100vh;
    background: var(--sidebar-bg);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    z-index: 100;
    transition: transform var(--transition);
}

.sidebar-header {
    padding: 24px 20px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 12px;
}

.sidebar-header .logo-img {
    width: 44px;
    height: 44px;
    object-fit: contain;
    flex-shrink: 0;
    filter: brightness(0) invert(1);
}

.sidebar-header .brand {
    font-family: 'Noto Sans TC', 'Rajdhani', sans-serif;
    font-size: 14px;
    font-weight: 700;
    color: var(--text);
    line-height: 1.4;
}

.sidebar-header .brand .brand-en {
    font-family: 'Orbitron', sans-serif;
    font-size: 12px;
    letter-spacing: 1px;
    color: var(--accent);
}

.sidebar-header .brand small {
    display: block;
    font-family: 'Rajdhani', sans-serif;
    font-size: 11px;
    color: var(--text-secondary);
    font-weight: 400;
    letter-spacing: 0;
    margin-top: 2px;
}

.sidebar-nav {
    flex: 1;
    padding: 16px 0;
    overflow-y: auto;
}

.sidebar-nav a {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 20px;
    color: var(--text-secondary);
    font-size: 15px;
    font-weight: 500;
    transition: all var(--transition);
    border-left: 3px solid transparent;
    text-decoration: none;
}

.sidebar-nav a:hover {
    color: var(--text);
    background: rgba(255, 255, 255, 0.04);
    text-decoration: none;
}

.sidebar-nav a.active {
    color: var(--accent);
    background: rgba(62, 183, 255, 0.08);
    border-left-color: var(--accent);
}

.nav-icon {
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    flex-shrink: 0;
}

.nav-icon svg {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
}

.sidebar-nav a .badge {
    margin-left: auto;
    background: var(--red);
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    padding: 2px 7px;
    border-radius: 10px;
    min-width: 20px;
    text-align: center;
}

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

.sidebar-admin-label {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--text-secondary);
    font-size: 13px;
}

.sidebar-admin-label svg {
    opacity: 0.6;
    flex-shrink: 0;
}

.sidebar-admin-label .logout-link {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 6px;
    color: var(--text-secondary);
    font-size: 13px;
    text-decoration: none;
    transition: color var(--transition);
}

.sidebar-admin-label .logout-link:hover {
    color: var(--red);
    text-decoration: none;
}

.sidebar-front-link {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--accent);
    font-size: 13px;
    text-decoration: none;
    padding: 8px 0;
    margin-bottom: 12px;
    font-family: 'Noto Sans TC', sans-serif;
    transition: color var(--transition);
}
.sidebar-front-link svg { opacity: 0.7; flex-shrink: 0; }
.sidebar-front-link:hover { color: var(--text); }

/* Mobile hamburger */
.mobile-header {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 56px;
    background: var(--sidebar-bg);
    border-bottom: 1px solid var(--border);
    z-index: 99;
    align-items: center;
    padding: 0 16px;
}

.hamburger {
    background: none;
    border: none;
    color: var(--text);
    font-size: 24px;
    cursor: pointer;
    padding: 4px;
}

.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 99;
}

/* --- Main Content --- */
.main-content {
    margin-left: var(--sidebar-width);
    flex: 1;
    min-height: 100vh;
}

.main-content iframe {
    width: 100%;
    height: 100vh;
    border: none;
}

/* Page content (used inside iframe pages) */
.page-content {
    padding: 32px;
    min-height: 100vh;
}

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

.page-header h1 {
    font-size: 22px;
    letter-spacing: 1px;
}

.page-header .subtitle {
    color: var(--text-secondary);
    font-size: 14px;
    margin-top: 4px;
    font-family: 'Rajdhani', sans-serif;
    font-weight: 400;
}

/* --- Stat Cards --- */
.stat-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 20px;
    margin-bottom: 32px;
}

.stat-card {
    background: var(--glass-bg);
    backdrop-filter: var(--glass-blur);
    border: 1px solid var(--border);
    border-radius: var(--radius-card);
    padding: 24px;
    display: flex;
    align-items: flex-start;
    gap: 16px;
    transition: transform var(--transition), border-color var(--transition);
}

.stat-card:hover {
    transform: translateY(-2px);
    border-color: rgba(62, 183, 255, 0.15);
    box-shadow: 0 4px 24px rgba(26, 63, 255, 0.1);
}

.stat-card .stat-icon {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    flex-shrink: 0;
}

.stat-card .stat-icon.blue { background: rgba(26, 63, 255, 0.15); color: var(--accent); }
.stat-card .stat-icon.green { background: rgba(0, 210, 120, 0.15); color: var(--green); }
.stat-card .stat-icon.purple { background: rgba(160, 100, 255, 0.15); color: #a064ff; }
.stat-card .stat-icon.red { background: rgba(255, 107, 107, 0.15); color: var(--red); }
.stat-card .stat-icon.yellow { background: rgba(255, 179, 71, 0.15); color: var(--yellow); }

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

.stat-card .stat-value {
    font-family: 'Orbitron', sans-serif;
    font-size: 28px;
    font-weight: 700;
    color: var(--text);
    line-height: 1;
}

.stat-card .stat-label {
    font-size: 14px;
    color: var(--text-secondary);
    margin-top: 6px;
}

/* --- Cards (Glass) --- */
.card {
    background: var(--glass-bg);
    backdrop-filter: var(--glass-blur);
    border: 1px solid var(--border);
    border-radius: var(--radius-card);
    padding: 24px;
    margin-bottom: 24px;
}

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

.card-header h2 {
    font-size: 16px;
    letter-spacing: 0.5px;
}

.card-header .card-actions {
    display: flex;
    gap: 8px;
}

/* --- Tables --- */
.table-wrapper {
    overflow-x: auto;
    border-radius: var(--radius-card);
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

table thead th {
    text-align: left;
    padding: 14px 16px;
    font-family: 'Rajdhani', sans-serif;
    font-weight: 600;
    font-size: 13px;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
    background: rgba(255, 255, 255, 0.02);
}

table tbody tr {
    border-bottom: 1px solid var(--border);
    transition: background var(--transition);
}

table tbody tr:hover {
    background: rgba(62, 183, 255, 0.04);
}

table tbody tr:last-child {
    border-bottom: none;
}

table tbody td {
    padding: 14px 16px;
    color: var(--text);
    vertical-align: middle;
}

table tbody td.secondary {
    color: var(--text-secondary);
}

table tbody td.truncate {
    max-width: 200px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* --- Buttons --- */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    border: none;
    border-radius: var(--radius-input);
    font-family: 'Rajdhani', 'Noto Sans TC', sans-serif;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition);
    text-decoration: none;
    white-space: nowrap;
    line-height: 1.4;
}

.btn:hover { text-decoration: none; }

.btn-primary {
    background: linear-gradient(135deg, var(--primary), var(--accent));
    color: #fff;
    box-shadow: 0 2px 12px rgba(26, 63, 255, 0.3);
}
.btn-primary:hover {
    box-shadow: 0 4px 20px rgba(26, 63, 255, 0.5);
    transform: translateY(-1px);
}

.btn-accent {
    background: var(--accent);
    color: #080e1c;
}
.btn-accent:hover {
    background: #2aa8f0;
}

.btn-success {
    background: var(--green);
    color: #080e1c;
}
.btn-success:hover {
    background: #00b866;
}

.btn-danger {
    background: var(--red);
    color: #fff;
}
.btn-danger:hover {
    background: var(--red-hover);
}

.btn-outline {
    background: transparent;
    border: 1px solid var(--border-light);
    color: var(--text);
}
.btn-outline:hover {
    background: rgba(255, 255, 255, 0.06);
    border-color: var(--accent);
    color: var(--accent);
}

.btn-sm {
    padding: 6px 14px;
    font-size: 13px;
}

.btn-lg {
    padding: 14px 28px;
    font-size: 16px;
}

.btn-icon {
    padding: 8px;
    min-width: 36px;
    justify-content: center;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none !important;
}

.btn-group {
    display: flex;
    gap: 8px;
}

/* --- Forms --- */
.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    font-size: 14px;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 6px;
    font-family: 'Rajdhani', 'Noto Sans TC', sans-serif;
}

.form-group label .required {
    color: var(--red);
    margin-left: 2px;
}

.form-group .help-text {
    font-size: 12px;
    color: var(--text-secondary);
    margin-top: 4px;
}

.form-input,
.form-select,
.form-textarea {
    width: 100%;
    padding: 10px 14px;
    background: rgba(8, 14, 28, 0.6);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-input);
    color: var(--text);
    font-family: 'Rajdhani', 'Noto Sans TC', sans-serif;
    font-size: 15px;
    transition: border-color var(--transition), box-shadow var(--transition);
    outline: none;
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(62, 183, 255, 0.1);
}

.form-input::placeholder,
.form-textarea::placeholder {
    color: rgba(165, 170, 190, 0.5);
}

.form-textarea {
    min-height: 100px;
    resize: vertical;
}

.form-select {
    appearance: none;
    -webkit-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='%23a5aabe' viewBox='0 0 16 16'%3E%3Cpath d='M8 11L3 6h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 36px;
    cursor: pointer;
}

.form-select:hover {
    border-color: rgba(62, 183, 255, 0.3);
}

.form-select option {
    background: #0c1323;
    color: var(--text);
    padding: 8px 12px;
}

.form-select option:checked {
    background: rgba(62, 183, 255, 0.2);
    color: #e3e7fc;
}

/* --- Custom Select (styled dropdown) --- */
.custom-select {
    position: relative;
    width: 100%;
}

.custom-select-trigger {
    width: 100%;
    padding: 10px 36px 10px 14px;
    background: rgba(8, 14, 28, 0.6);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-input);
    color: var(--text);
    font-family: 'Rajdhani', 'Noto Sans TC', sans-serif;
    font-size: 15px;
    cursor: pointer;
    transition: border-color var(--transition), box-shadow var(--transition);
    outline: none;
    display: flex;
    align-items: center;
    gap: 8px;
    user-select: none;
}

.custom-select-trigger::after {
    content: '';
    position: absolute;
    right: 14px;
    top: 50%;
    transform: translateY(-50%);
    border: 5px solid transparent;
    border-top: 6px solid var(--text-secondary);
    transition: transform 0.2s;
}

.custom-select.open .custom-select-trigger::after {
    transform: translateY(-50%) rotate(180deg);
}

.custom-select-trigger:hover {
    border-color: rgba(62, 183, 255, 0.3);
}

.custom-select.open .custom-select-trigger {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(62, 183, 255, 0.1);
}

.custom-select-dropdown {
    display: none;
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    right: 0;
    background: #0f1729;
    border: 1px solid rgba(62, 183, 255, 0.2);
    border-radius: var(--radius-input);
    overflow: hidden;
    z-index: 50;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
    animation: dropIn 0.15s ease;
}

.custom-select.open .custom-select-dropdown {
    display: block;
}

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

.custom-select-option {
    padding: 10px 14px;
    color: var(--text);
    font-family: 'Rajdhani', 'Noto Sans TC', sans-serif;
    font-size: 15px;
    cursor: pointer;
    transition: background 0.15s;
    display: flex;
    align-items: center;
    gap: 8px;
}

.custom-select-option:hover {
    background: rgba(62, 183, 255, 0.1);
}

.custom-select-option.selected {
    background: rgba(62, 183, 255, 0.15);
    color: var(--accent);
}

.custom-select-option .cs-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
}

/* Inline mini toggle (for feature card themes etc.) */
.mini-toggle {
    display: inline-flex;
    border: 1px solid var(--border-light);
    border-radius: 4px;
    overflow: hidden;
    font-size: 11px;
    height: 24px;
}

.mini-toggle-btn {
    padding: 0 8px;
    background: transparent;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    font-family: 'Rajdhani', sans-serif;
    font-size: 11px;
    transition: all 0.15s;
    white-space: nowrap;
}

.mini-toggle-btn:not(:last-child) {
    border-right: 1px solid var(--border-light);
}

.mini-toggle-btn.active {
    background: rgba(62, 183, 255, 0.15);
    color: var(--accent);
}

.mini-toggle-btn:hover:not(.active) {
    background: rgba(255, 255, 255, 0.04);
}

.form-check {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
}

.form-check input[type="checkbox"] {
    -webkit-appearance: none;
    appearance: none;
    width: 20px;
    height: 20px;
    border: 1.5px solid var(--border-light);
    border-radius: 5px;
    background: rgba(8, 14, 28, 0.6);
    cursor: pointer;
    position: relative;
    transition: all 0.2s;
    flex-shrink: 0;
}

.form-check input[type="checkbox"]:hover {
    border-color: rgba(62, 183, 255, 0.4);
}

.form-check input[type="checkbox"]:checked {
    background: var(--primary);
    border-color: var(--primary);
}

.form-check input[type="checkbox"]:checked::after {
    content: '';
    position: absolute;
    left: 6px;
    top: 2px;
    width: 6px;
    height: 10px;
    border: solid #fff;
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
}

.form-check input[type="checkbox"]:focus-visible {
    box-shadow: 0 0 0 3px rgba(62, 183, 255, 0.15);
    border-color: var(--accent);
}

.form-check label {
    margin-bottom: 0;
    cursor: pointer;
}

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

.form-row-3 {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 20px;
}

/* --- Collapsible Sections --- */
.collapsible {
    margin-bottom: 16px;
}

.collapsible-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 18px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border);
    border-radius: var(--radius-input);
    cursor: pointer;
    transition: all var(--transition);
    user-select: none;
}

.collapsible-header:hover {
    background: rgba(255, 255, 255, 0.05);
}

.collapsible-header h3 {
    font-size: 15px;
    font-weight: 600;
    letter-spacing: 0.5px;
}

.collapsible-header .toggle-icon {
    font-size: 12px;
    color: var(--text-secondary);
    transition: transform var(--transition);
}

.collapsible.open .collapsible-header {
    border-bottom-left-radius: 0;
    border-bottom-right-radius: 0;
    border-color: var(--accent);
}

.collapsible.open .toggle-icon {
    transform: rotate(180deg);
}

.collapsible-body {
    display: none;
    padding: 20px 18px;
    border: 1px solid var(--border);
    border-top: none;
    border-radius: 0 0 var(--radius-input) var(--radius-input);
    background: rgba(255, 255, 255, 0.01);
}

.collapsible.open .collapsible-body {
    display: block;
}

/* --- Status Badges --- */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.3px;
}

.badge-active {
    background: rgba(0, 210, 120, 0.15);
    color: var(--green);
}

.badge-inactive {
    background: rgba(165, 170, 190, 0.15);
    color: var(--text-secondary);
}

.badge-read {
    background: rgba(165, 170, 190, 0.1);
    color: var(--text-secondary);
}

.badge-unread {
    background: rgba(62, 183, 255, 0.15);
    color: var(--accent);
}

.badge-blue {
    background: rgba(26, 63, 255, 0.15);
    color: var(--accent);
}

.badge-purple {
    background: rgba(160, 100, 255, 0.15);
    color: #a064ff;
}

.badge-green {
    background: rgba(0, 210, 120, 0.15);
    color: var(--green);
}

.badge-red {
    background: rgba(255, 107, 107, 0.15);
    color: var(--red);
}

.badge-yellow {
    background: rgba(255, 179, 71, 0.15);
    color: var(--yellow);
}

/* --- Modal --- */
.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    z-index: 1000;
    align-items: center;
    justify-content: center;
}

.modal-overlay.show {
    display: flex;
}

.modal {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-card);
    padding: 28px;
    max-width: 520px;
    width: 90%;
    max-height: 80vh;
    overflow-y: auto;
    animation: modalIn 0.25s ease;
}

@keyframes modalIn {
    from { opacity: 0; transform: scale(0.95) translateY(10px); }
    to { opacity: 1; transform: scale(1) translateY(0); }
}

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

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

.modal-close {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 22px;
    cursor: pointer;
    padding: 4px;
    transition: color var(--transition);
}

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

.modal-body {
    margin-bottom: 24px;
    color: var(--text-secondary);
    font-size: 15px;
    line-height: 1.6;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
}

/* --- Toast Notifications --- */
.toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 2000;
    display: flex;
    flex-direction: column;
    gap: 10px;
    pointer-events: none;
}

.toast {
    pointer-events: auto;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 20px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-input);
    color: var(--text);
    font-size: 14px;
    min-width: 280px;
    max-width: 420px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
    animation: toastIn 0.3s ease;
    backdrop-filter: var(--glass-blur);
}

.toast.toast-out {
    animation: toastOut 0.3s ease forwards;
}

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

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

.toast .toast-icon {
    font-size: 18px;
    flex-shrink: 0;
}

.toast.toast-success { border-left: 3px solid var(--green); }
.toast.toast-success .toast-icon { color: var(--green); }

.toast.toast-error { border-left: 3px solid var(--red); }
.toast.toast-error .toast-icon { color: var(--red); }

.toast.toast-info { border-left: 3px solid var(--accent); }
.toast.toast-info .toast-icon { color: var(--accent); }

.toast.toast-warning { border-left: 3px solid var(--yellow); }
.toast.toast-warning .toast-icon { color: var(--yellow); }

.toast-close {
    margin-left: auto;
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 16px;
    padding: 2px;
}

/* --- Dynamic List (add/remove rows) --- */
.dynamic-list .dynamic-row {
    display: flex;
    gap: 10px;
    align-items: center;
    margin-bottom: 10px;
}

.dynamic-list .dynamic-row .form-input {
    flex: 1;
}

.dynamic-list .btn-remove-row {
    background: rgba(255, 107, 107, 0.15);
    color: var(--red);
    border: none;
    width: 32px;
    height: 32px;
    border-radius: 6px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    flex-shrink: 0;
    transition: background var(--transition);
}

.dynamic-list .btn-remove-row:hover {
    background: rgba(255, 107, 107, 0.3);
}

.btn-add-row {
    background: rgba(62, 183, 255, 0.1);
    color: var(--accent);
    border: 1px dashed rgba(62, 183, 255, 0.3);
    border-radius: var(--radius-input);
    padding: 8px 16px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition);
    font-family: 'Rajdhani', 'Noto Sans TC', sans-serif;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.btn-add-row:hover {
    background: rgba(62, 183, 255, 0.2);
    border-color: var(--accent);
}

/* --- Contact expanded row --- */
.contact-detail {
    background: rgba(255, 255, 255, 0.02);
    padding: 16px 20px;
    border-radius: var(--radius-input);
    margin-top: 8px;
}

.contact-detail p {
    margin-bottom: 8px;
    color: var(--text-secondary);
    font-size: 14px;
}

.contact-detail p strong {
    color: var(--text);
}

/* --- Loading Spinner --- */
.loading {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 60px;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

/* --- Empty State --- */
.empty-state {
    text-align: center;
    padding: 48px 20px;
    color: var(--text-secondary);
}

.empty-state .empty-icon {
    font-size: 48px;
    margin-bottom: 16px;
    opacity: 0.5;
}

.empty-state p {
    font-size: 15px;
}

/* --- Quill Editor Overrides --- */
.ql-toolbar.ql-snow {
    background: rgba(8, 14, 28, 0.6) !important;
    border-color: var(--border-light) !important;
    border-radius: var(--radius-input) var(--radius-input) 0 0 !important;
}

.ql-container.ql-snow {
    background: rgba(8, 14, 28, 0.6) !important;
    border-color: var(--border-light) !important;
    border-radius: 0 0 var(--radius-input) var(--radius-input) !important;
    color: var(--text) !important;
    font-family: 'Rajdhani', 'Noto Sans TC', sans-serif !important;
    font-size: 15px !important;
    min-height: 250px;
}

.ql-editor {
    min-height: 250px;
}

.ql-snow .ql-stroke {
    stroke: var(--text-secondary) !important;
}

.ql-snow .ql-fill {
    fill: var(--text-secondary) !important;
}

.ql-snow .ql-picker-label {
    color: var(--text-secondary) !important;
}

.ql-snow .ql-picker-options {
    background: var(--surface) !important;
    border-color: var(--border-light) !important;
}

.ql-snow .ql-picker-item {
    color: var(--text) !important;
}

.ql-editor.ql-blank::before {
    color: rgba(165, 170, 190, 0.5) !important;
    font-style: normal !important;
}

/* --- Login Page --- */
.login-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: var(--bg);
    padding: 20px;
}

.login-card {
    background: var(--glass-bg);
    backdrop-filter: var(--glass-blur);
    border: 1px solid var(--border);
    border-radius: var(--radius-card);
    padding: 40px;
    width: 100%;
    max-width: 400px;
}

.login-card .login-logo {
    text-align: center;
    margin-bottom: 32px;
}

.login-card .login-logo .logo-img {
    height: 48px;
    width: auto;
    filter: brightness(0) invert(1);
    margin: 0 auto 16px;
    display: block;
}

.login-card .login-front-link {
    display: block;
    text-align: center;
    margin-top: 24px;
    font-size: 13px;
    color: var(--accent);
    text-decoration: none;
    font-family: 'Noto Sans TC', sans-serif;
    transition: color 0.2s;
}
.login-card .login-front-link:hover {
    color: var(--text);
}

.login-card .login-logo h1 {
    font-size: 20px;
    letter-spacing: 0;
}

.login-card .login-logo p {
    font-size: 14px;
    color: var(--text-secondary);
    margin-top: 4px;
}

.login-card .form-group {
    margin-bottom: 24px;
}

.login-card .btn-primary {
    width: 100%;
    justify-content: center;
    padding: 12px;
    font-size: 16px;
}

.login-error {
    background: rgba(255, 107, 107, 0.1);
    border: 1px solid rgba(255, 107, 107, 0.3);
    border-radius: var(--radius-input);
    padding: 10px 14px;
    color: var(--red);
    font-size: 14px;
    margin-bottom: 20px;
    display: none;
}

/* --- Section grid for dashboard --- */
.dashboard-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
}

/* --- Feature list within service form --- */
.feature-item {
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid var(--border);
    border-radius: var(--radius-input);
    padding: 16px;
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.feature-item .feature-info {
    flex: 1;
}

.feature-item .feature-info h4 {
    font-size: 14px;
    font-family: 'Rajdhani', sans-serif;
    font-weight: 600;
}

.feature-item .feature-info p {
    font-size: 13px;
    color: var(--text-secondary);
    margin-top: 2px;
}

.feature-item .feature-actions {
    display: flex;
    gap: 6px;
}

/* --- Utility --- */
.text-center { text-align: center; }
.text-right { text-align: right; }
.text-accent { color: var(--accent); }
.text-green { color: var(--green); }
.text-red { color: var(--red); }
.text-secondary { color: var(--text-secondary); }
.mt-8 { margin-top: 8px; }
.mt-16 { margin-top: 16px; }
.mt-24 { margin-top: 24px; }
.mb-8 { margin-bottom: 8px; }
.mb-16 { margin-bottom: 16px; }
.mb-24 { margin-bottom: 24px; }
.flex { display: flex; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-8 { gap: 8px; }
.gap-16 { gap: 16px; }
.hidden { display: none !important; }
.cursor-pointer { cursor: pointer; }
.w-full { width: 100%; }

/* --- Responsive --- */
@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
    }

    .sidebar.open {
        transform: translateX(0);
    }

    .sidebar-overlay.show {
        display: block;
    }

    .mobile-header {
        display: flex;
    }

    .main-content {
        margin-left: 0;
    }

    .main-content iframe {
        height: calc(100vh - 56px);
        margin-top: 56px;
    }

    .page-content {
        padding: 20px 16px;
    }

    .stat-cards {
        grid-template-columns: 1fr;
    }

    .dashboard-grid {
        grid-template-columns: 1fr;
    }

    .form-row,
    .form-row-3 {
        grid-template-columns: 1fr;
    }

    .page-header {
        flex-direction: column;
        align-items: flex-start;
    }
}

@media (max-width: 480px) {
    .page-content {
        padding: 16px 12px;
    }

    .card {
        padding: 16px;
    }

    .login-card {
        padding: 28px 20px;
    }
}


/* --- Pagination --- */
.pagination {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    border-top: 1px solid var(--border);
    gap: 12px;
}

.pagination-pages {
    display: flex;
    align-items: center;
    gap: 4px;
}

.pagination-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 32px;
    height: 32px;
    padding: 0 8px;
    background: transparent;
    color: var(--text-secondary);
    border: 1px solid transparent;
    border-radius: var(--radius);
    font-size: 13px;
    font-family: 'Rajdhani', sans-serif;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.pagination-btn:hover:not(:disabled):not(.active) {
    background: rgba(255,255,255,0.04);
    color: var(--text);
}

.pagination-btn.active {
    background: rgba(62,183,255,0.12);
    border-color: rgba(62,183,255,0.25);
    color: var(--accent);
}

.pagination-btn:disabled {
    opacity: 0.25;
    cursor: not-allowed;
}

.pagination-btn.pagination-arrow {
    border: 1px solid var(--border);
}

.pagination-btn.pagination-arrow:hover:not(:disabled) {
    border-color: var(--accent);
    background: rgba(62,183,255,0.06);
}

.pagination-ellipsis {
    color: var(--text-secondary);
    font-size: 13px;
    padding: 0 4px;
    font-family: 'Rajdhani', sans-serif;
    user-select: none;
}

.pagination-info {
    font-size: 12px;
    color: var(--text-secondary);
    font-family: 'Noto Sans TC', sans-serif;
    white-space: nowrap;
}
