:root {
    --bg-main: #0a0e17;
    --bg-surface: rgba(18, 26, 43, 0.75);
    --bg-surface-hover: rgba(28, 40, 65, 0.85);
    --bg-card: rgba(23, 32, 54, 0.65);
    --bg-input: rgba(11, 16, 28, 0.8);
    --border-color: rgba(255, 255, 255, 0.08);
    --border-highlight: rgba(99, 102, 241, 0.35);
    
    --primary: #6366f1;
    --primary-hover: #4f46e5;
    --primary-glow: rgba(99, 102, 241, 0.35);
    --accent-emerald: #10b981;
    --accent-rose: #f43f5e;
    --accent-amber: #f59e0b;
    --accent-cyan: #06b6d4;
    --accent-purple: #a855f7;

    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    
    --radius-sm: 8px;
    --radius-md: 14px;
    --radius-lg: 20px;
    --radius-full: 9999px;
    
    --shadow-sm: 0 4px 12px rgba(0, 0, 0, 0.25);
    --shadow-md: 0 10px 30px -5px rgba(0, 0, 0, 0.4);
    --shadow-glow: 0 0 25px rgba(99, 102, 241, 0.25);
    
    --transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

[data-theme="light"] {
    --bg-main: #f1f5f9;
    --bg-surface: rgba(255, 255, 255, 0.9);
    --bg-surface-hover: rgba(248, 250, 252, 0.95);
    --bg-card: rgba(255, 255, 255, 0.85);
    --bg-input: #ffffff;
    --border-color: rgba(0, 0, 0, 0.08);
    --border-highlight: rgba(99, 102, 241, 0.4);
    
    --text-primary: #0f172a;
    --text-secondary: #475569;
    --text-muted: #94a3b8;
    
    --shadow-sm: 0 4px 12px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 10px 30px -5px rgba(0, 0, 0, 0.08);
    --shadow-glow: 0 0 25px rgba(99, 102, 241, 0.15);
}

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

body {
    font-family: 'Pretendard', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background-color: var(--bg-main);
    color: var(--text-primary);
    min-height: 100vh;
    line-height: 1.5;
    overflow-x: hidden;
    position: relative;
}

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

.ambient-glow-2 {
    position: fixed;
    bottom: -10%;
    right: 15%;
    width: 500px;
    height: 500px;
    background: radial-gradient(circle, rgba(168, 85, 247, 0.12) 0%, rgba(168, 85, 247, 0) 70%);
    pointer-events: none;
    z-index: 0;
}

/* Header */
.header {
    position: sticky;
    top: 0;
    z-index: 100;
    background: rgba(10, 14, 23, 0.82);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-bottom: 1px solid var(--border-color);
    padding: 0.85rem 2rem;
    transition: var(--transition);
}

[data-theme="light"] .header {
    background: rgba(255, 255, 255, 0.85);
}

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

.brand {
    display: flex;
    align-items: center;
    gap: 0.85rem;
    text-decoration: none;
    color: inherit;
}

.brand-icon {
    width: 42px;
    height: 42px;
    border-radius: var(--radius-md);
    background: linear-gradient(135deg, #6366f1, #a855f7);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 1.2rem;
    box-shadow: var(--shadow-glow);
}

.brand-info h1 {
    font-size: 1.15rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.brand-badge {
    font-size: 0.65rem;
    padding: 0.15rem 0.5rem;
    border-radius: var(--radius-full);
    background: rgba(99, 102, 241, 0.2);
    color: var(--primary);
    border: 1px solid rgba(99, 102, 241, 0.4);
    font-weight: 600;
    text-transform: uppercase;
}

.brand-sub {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

/* Header Right Actions */
.header-actions {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.balance-widget {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    padding: 0.45rem 0.9rem;
    border-radius: var(--radius-md);
    font-size: 0.82rem;
    box-shadow: var(--shadow-sm);
}

.balance-item {
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.balance-item .dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--accent-emerald);
    box-shadow: 0 0 8px var(--accent-emerald);
}

.balance-value {
    font-weight: 700;
    color: var(--accent-emerald);
    font-family: 'JetBrains Mono', monospace;
}

.btn-icon {
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    width: 38px;
    height: 38px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: var(--transition);
    text-decoration: none;
    font-size: 0.95rem;
}

.btn-icon:hover {
    background: var(--bg-surface-hover);
    color: var(--text-primary);
    border-color: var(--border-highlight);
    transform: translateY(-2px);
}

/* Main Container */
.main-wrapper {
    max-width: 1400px;
    margin: 1.5rem auto 3rem;
    padding: 0 1.5rem;
    position: relative;
    z-index: 1;
}

/* Nav Tabs */
.tabs-nav {
    display: flex;
    gap: 0.5rem;
    background: var(--bg-surface);
    padding: 0.4rem;
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-color);
    margin-bottom: 1.5rem;
    overflow-x: auto;
}

.tab-btn {
    display: flex;
    align-items: center;
    gap: 0.55rem;
    padding: 0.65rem 1.25rem;
    border-radius: var(--radius-md);
    border: none;
    background: transparent;
    color: var(--text-secondary);
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    white-space: nowrap;
}

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

.tab-btn.active {
    background: linear-gradient(135deg, var(--primary), #818cf8);
    color: #ffffff;
    box-shadow: 0 4px 14px var(--primary-glow);
}

/* Tab Panes */
.tab-content {
    display: none;
    animation: fadeIn 0.3s ease;
}

.tab-content.active {
    display: block;
}

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

/* Compose Grid Layout */
.compose-grid {
    display: grid;
    grid-template-columns: 1.35fr 0.9fr;
    gap: 1.5rem;
}

@media (max-width: 1024px) {
    .compose-grid {
        grid-template-columns: 1fr;
    }
}

/* Card Styles */
.card {
    background: var(--bg-surface);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    box-shadow: var(--shadow-md);
    position: relative;
}

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

.card-title {
    font-size: 1.05rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 0.6rem;
}

.card-title i {
    color: var(--primary);
}

/* Form Controls */
.form-group {
    margin-bottom: 1.2rem;
}

.form-label {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 0.45rem;
}

.form-label .badge-req {
    color: var(--accent-rose);
    font-size: 0.75rem;
}

.form-control {
    width: 100%;
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    padding: 0.75rem 1rem;
    border-radius: var(--radius-md);
    font-size: 0.92rem;
    font-family: inherit;
    transition: var(--transition);
    outline: none;
}

.form-control:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-glow);
}

.form-control::placeholder {
    color: var(--text-muted);
}

textarea.form-control {
    resize: vertical;
    min-height: 140px;
    font-family: inherit;
    line-height: 1.6;
}

/* Sub tabs for Single / Bulk */
.mode-toggle {
    display: inline-flex;
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    padding: 0.25rem;
    border-radius: var(--radius-md);
    margin-bottom: 1rem;
}

.mode-btn {
    border: none;
    background: transparent;
    color: var(--text-secondary);
    padding: 0.45rem 1rem;
    border-radius: var(--radius-sm);
    font-size: 0.82rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
}

.mode-btn.active {
    background: var(--primary);
    color: #ffffff;
    box-shadow: 0 2px 8px var(--primary-glow);
}

/* Byte Counter & Type Badge */
.msg-meta-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 0.5rem 0.85rem;
    margin-top: 0.5rem;
    font-size: 0.82rem;
}

.type-indicator {
    display: flex;
    align-items: center;
    gap: 0.45rem;
    font-weight: 700;
}

.type-indicator.sms {
    color: var(--accent-emerald);
}

.type-indicator.lms {
    color: var(--accent-amber);
}

.byte-counter {
    font-family: 'JetBrains Mono', monospace;
    color: var(--text-secondary);
}

.byte-counter .current-bytes {
    font-weight: 700;
    color: var(--text-primary);
}

/* Quick Tools Toolbar */
.quick-tools {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-top: 0.5rem;
    flex-wrap: wrap;
}

.btn-tool {
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    padding: 0.35rem 0.65rem;
    border-radius: var(--radius-sm);
    font-size: 0.78rem;
    cursor: pointer;
    transition: var(--transition);
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
}

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

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.55rem;
    padding: 0.8rem 1.6rem;
    border-radius: var(--radius-md);
    font-size: 0.92rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    border: none;
    text-decoration: none;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary), #4f46e5);
    color: #ffffff;
    box-shadow: 0 4px 16px var(--primary-glow);
}

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

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

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

.btn-success {
    background: linear-gradient(135deg, var(--accent-emerald), #059669);
    color: #ffffff;
    box-shadow: 0 4px 14px rgba(16, 185, 129, 0.3);
}

.btn-test {
    background: rgba(99, 102, 241, 0.12);
    color: #818cf8;
    border: 1px solid rgba(99, 102, 241, 0.3);
    font-size: 0.8rem;
    padding: 0.35rem 0.75rem;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: var(--transition);
}

.btn-test:hover {
    background: rgba(99, 102, 241, 0.25);
    color: #ffffff;
}

.btn-block {
    width: 100%;
}

/* Phone Mockup Preview */
.phone-mockup {
    width: 100%;
    max-width: 340px;
    margin: 0 auto;
    background: #020617;
    border-radius: 40px;
    border: 8px solid #1e293b;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.7), 0 0 25px rgba(99, 102, 241, 0.15);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    min-height: 520px;
}

.phone-notch {
    height: 24px;
    background: #1e293b;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    border-bottom-left-radius: 12px;
    border-bottom-right-radius: 12px;
    width: 130px;
    margin: 0 auto;
}

.phone-speaker {
    width: 45px;
    height: 4px;
    background: #475569;
    border-radius: 2px;
}

.phone-camera {
    width: 8px;
    height: 8px;
    background: #334155;
    border-radius: 50%;
}

.phone-screen {
    flex: 1;
    background: linear-gradient(to bottom, #0f172a, #0b1120);
    padding: 1rem;
    display: flex;
    flex-direction: column;
    color: #f8fafc;
}

.phone-header {
    text-align: center;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    margin-bottom: 1rem;
}

.phone-contact-name {
    font-size: 0.85rem;
    font-weight: 700;
}

.phone-contact-num {
    font-size: 0.72rem;
    color: var(--text-muted);
}

.phone-chat-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    overflow-y: auto;
}

.chat-bubble {
    align-self: flex-start;
    background: #1e293b;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 16px;
    border-top-left-radius: 4px;
    padding: 0.85rem 1rem;
    max-width: 90%;
    font-size: 0.85rem;
    line-height: 1.5;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
    word-break: break-word;
}

.chat-bubble .bubble-title {
    font-weight: 700;
    color: #818cf8;
    margin-bottom: 0.4rem;
    font-size: 0.88rem;
    border-bottom: 1px dashed rgba(255, 255, 255, 0.1);
    padding-bottom: 0.3rem;
}

.chat-bubble .bubble-text {
    white-space: pre-wrap;
    color: #e2e8f0;
}

.chat-bubble .bubble-time {
    font-size: 0.65rem;
    color: #64748b;
    margin-top: 0.4rem;
    text-align: right;
}

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

.stat-card {
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 1.25rem;
    display: flex;
    align-items: center;
    gap: 1.1rem;
    transition: var(--transition);
}

.stat-card:hover {
    transform: translateY(-3px);
    border-color: var(--border-highlight);
}

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

.stat-icon.primary { background: rgba(99, 102, 241, 0.15); color: var(--primary); }
.stat-icon.emerald { background: rgba(16, 185, 129, 0.15); color: var(--accent-emerald); }
.stat-icon.rose { background: rgba(244, 63, 94, 0.15); color: var(--accent-rose); }
.stat-icon.purple { background: rgba(168, 85, 247, 0.15); color: var(--accent-purple); }

.stat-label {
    font-size: 0.78rem;
    color: var(--text-secondary);
    font-weight: 600;
}

.stat-value {
    font-size: 1.45rem;
    font-weight: 800;
    letter-spacing: -0.02em;
    font-family: 'JetBrains Mono', monospace;
}

/* Filter Controls */
.filter-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1.2rem;
    flex-wrap: wrap;
}

.search-box {
    position: relative;
    flex: 1;
    min-width: 240px;
}

.search-box i {
    position: absolute;
    left: 1rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
}

.search-box input {
    padding-left: 2.6rem;
}

.filter-group {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    flex-wrap: wrap;
}

/* Table */
.table-responsive {
    overflow-x: auto;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
}

.custom-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
    text-align: left;
}

.custom-table th {
    background: rgba(0, 0, 0, 0.2);
    color: var(--text-secondary);
    font-weight: 600;
    padding: 0.85rem 1rem;
    border-bottom: 1px solid var(--border-color);
    white-space: nowrap;
}

.custom-table td {
    padding: 0.85rem 1rem;
    border-bottom: 1px solid var(--border-color);
    color: var(--text-primary);
    vertical-align: middle;
}

.custom-table tr:last-child td {
    border-bottom: none;
}

.custom-table tr:hover td {
    background: var(--bg-surface-hover);
}

/* Badges */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    font-size: 0.72rem;
    font-weight: 700;
    padding: 0.2rem 0.6rem;
    border-radius: var(--radius-full);
}

.badge-success {
    background: rgba(16, 185, 129, 0.15);
    color: var(--accent-emerald);
    border: 1px solid rgba(16, 185, 129, 0.3);
}

.badge-danger {
    background: rgba(244, 63, 94, 0.15);
    color: var(--accent-rose);
    border: 1px solid rgba(244, 63, 94, 0.3);
}

.badge-sms {
    background: rgba(99, 102, 241, 0.15);
    color: #818cf8;
    border: 1px solid rgba(99, 102, 241, 0.3);
}

.badge-lms {
    background: rgba(245, 158, 11, 0.15);
    color: var(--accent-amber);
    border: 1px solid rgba(245, 158, 11, 0.3);
}

/* Pagination */
.pagination {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 0.4rem;
    margin-top: 1.2rem;
}

.page-btn {
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    padding: 0.45rem 0.85rem;
    border-radius: var(--radius-sm);
    font-size: 0.82rem;
    cursor: pointer;
    transition: var(--transition);
}

.page-btn:hover:not(:disabled) {
    background: var(--bg-surface-hover);
    color: var(--text-primary);
}

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

.page-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

/* Templates Grid */
.templates-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 1.2rem;
}

.template-card {
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 1.25rem;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    transition: var(--transition);
}

.template-card:hover {
    border-color: var(--border-highlight);
    transform: translateY(-2px);
}

.template-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    margin-bottom: 0.75rem;
}

.template-title {
    font-size: 0.95rem;
    font-weight: 700;
}

.template-body {
    font-size: 0.85rem;
    color: var(--text-secondary);
    line-height: 1.6;
    margin-bottom: 1.2rem;
    white-space: pre-wrap;
    background: var(--bg-input);
    padding: 0.75rem;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-color);
    max-height: 120px;
    overflow-y: auto;
}

.template-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

/* Modal */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(8px);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 1.5rem;
}

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

.modal-box {
    background: var(--bg-main);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    width: 100%;
    max-width: 540px;
    max-height: 90vh;
    overflow-y: auto;
    padding: 1.75rem;
    box-shadow: 0 25px 60px rgba(0, 0, 0, 0.6);
    position: relative;
    animation: modalIn 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

@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: 1.25rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid var(--border-color);
}

.modal-title {
    font-size: 1.1rem;
    font-weight: 700;
}

.btn-close {
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 1.2rem;
    cursor: pointer;
    transition: var(--transition);
}

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

/* Toast Notifications */
.toast-container {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    z-index: 2000;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.toast {
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    backdrop-filter: blur(12px);
    border-radius: var(--radius-md);
    padding: 0.85rem 1.25rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-size: 0.88rem;
    box-shadow: var(--shadow-md);
    animation: toastIn 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    min-width: 280px;
}

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

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

/* Loading Spinner */
.spinner {
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    border-top-color: #ffffff;
    animation: spin 0.8s linear infinite;
}

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