/* ============ Microsoft Fluent UI Inspired Design ============ */
:root {
    /* Fluent UI Colors */
    --bg-app: #1a1a1a;
    --bg-sidebar: #202020;
    --bg-surface: #2d2d2d;
    --bg-surface-hover: #383838;
    --bg-elevated: #3d3d3d;

    --text-primary: #ffffff;
    --text-secondary: #b3b3b3;
    --text-tertiary: #8a8a8a;

    --accent-brand: #0078d4;
    --accent-brand-hover: #1a86d9;
    --accent-brand-light: rgba(0, 120, 212, 0.15);
    --accent-success: #0f7b0f;
    --accent-warning: #d83b01;
    --accent-danger: #d13438;

    --border-subtle: rgba(255, 255, 255, 0.08);
    --border-normal: rgba(255, 255, 255, 0.12);

    --shadow-elevation-1: 0 2px 4px rgba(0, 0, 0, 0.14), 0 0 2px rgba(0, 0, 0, 0.12);
    --shadow-elevation-2: 0 4px 8px rgba(0, 0, 0, 0.14), 0 0 2px rgba(0, 0, 0, 0.12);

    --radius-sm: 4px;
    --radius-md: 6px;
    --radius-lg: 8px;

    --transition: 0.1s ease;
}

/* ============ Dark Scrollbar ============ */
::-webkit-scrollbar {
    width: 10px;
    height: 10px;
}

::-webkit-scrollbar-track {
    background: var(--bg-app);
}

::-webkit-scrollbar-thumb {
    background: var(--bg-elevated);
    border-radius: 5px;
    border: 2px solid var(--bg-app);
}

::-webkit-scrollbar-thumb:hover {
    background: var(--bg-surface-hover);
}

::-webkit-scrollbar-corner {
    background: var(--bg-app);
}

/* Firefox scrollbar */
* {
    scrollbar-width: thin;
    scrollbar-color: var(--bg-elevated) var(--bg-app);
}

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

body {
    font-family: 'Inter', 'Segoe UI', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg-app);
    color: var(--text-primary);
    line-height: 1.5;
    min-height: 100vh;
    font-size: 14px;
}

/* ============ App Layout ============ */
.app {
    display: flex;
    min-height: 100vh;
}

/* ============ Sidebar ============ */
.sidebar {
    width: 240px;
    background: var(--bg-sidebar);
    border-right: 1px solid var(--border-subtle);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
}

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

.sidebar-logo {
    display: flex;
    align-items: center;
    gap: 10px;
}

.sidebar-logo-icon {
    width: 32px;
    height: 32px;
    background: var(--accent-brand);
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
}

.sidebar-logo h1 {
    font-size: 16px;
    font-weight: 600;
}

.sidebar-nav {
    padding: 12px 8px;
    flex: 1;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    cursor: pointer;
    transition: all var(--transition);
    border: none;
    background: none;
    width: 100%;
    text-align: left;
    font-size: 14px;
}

.nav-item:hover {
    background: var(--bg-surface);
    color: var(--text-primary);
}

.nav-item.active {
    background: var(--accent-brand-light);
    color: var(--accent-brand);
}

.nav-item-icon {
    width: 20px;
    text-align: center;
    font-size: 16px;
}

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

.status-indicator {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    color: var(--text-tertiary);
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--accent-danger);
}

.status-dot.online {
    background: var(--accent-success);
}

/* ============ Main Content ============ */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

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

.content-header h2 {
    font-size: 20px;
    font-weight: 600;
}

.content-body {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
}

.tab-content {
    display: none;
}

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

/* ============ Cards ============ */
.card {
    background: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    overflow: hidden;
}

.card+.card {
    margin-top: 16px;
}

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

.card-header h3 {
    font-size: 14px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
}

.card-body {
    padding: 20px;
}

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

.card-section:last-child {
    margin-bottom: 0;
}

/* ============ Grid Layout ============ */
.grid-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

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

/* ============ Buttons ============ */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 8px 16px;
    font-size: 14px;
    font-weight: 500;
    font-family: inherit;
    border: none;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all var(--transition);
    white-space: nowrap;
}

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

.btn-primary {
    background: var(--accent-brand);
    color: white;
}

.btn-primary:hover:not(:disabled) {
    background: var(--accent-brand-hover);
}

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

.btn-secondary:hover:not(:disabled) {
    background: var(--bg-surface-hover);
}

.btn-ghost {
    background: transparent;
    color: var(--text-secondary);
}

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

.btn-danger {
    background: var(--accent-danger);
    color: white;
}

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

.btn-lg {
    padding: 12px 24px;
    font-size: 14px;
}

.btn-block {
    width: 100%;
}

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

.form-group:last-child {
    margin-bottom: 0;
}

.form-label {
    display: block;
    font-size: 12px;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 6px;
}

.form-control {
    width: 100%;
    padding: 10px 12px;
    font-size: 14px;
    font-family: inherit;
    background: var(--bg-app);
    border: 1px solid var(--border-normal);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    transition: border-color var(--transition);
}

.form-control:focus {
    outline: none;
    border-color: var(--accent-brand);
}

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

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

select.form-control {
    cursor: pointer;
}

/* ============ Form Row ============ */
.form-row {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
}

/* ============ Checkbox & Radio ============ */
.form-check {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    font-size: 14px;
}

.form-check input {
    width: 16px;
    height: 16px;
    accent-color: var(--accent-brand);
}

.form-check-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 12px;
}

/* ============ Info Box ============ */
.info-box {
    background: var(--bg-app);
    border-radius: var(--radius-md);
    padding: 16px;
}

.info-row {
    display: flex;
    justify-content: space-between;
    padding: 8px 0;
    border-bottom: 1px solid var(--border-subtle);
}

.info-row:last-child {
    border-bottom: none;
}

.info-label {
    color: var(--text-tertiary);
    font-size: 13px;
}

.info-value {
    font-weight: 500;
    font-size: 13px;
}

/* ============ Steps/Instructions ============ */
.steps {
    background: var(--bg-app);
    border-radius: var(--radius-md);
    padding: 16px;
    margin-bottom: 16px;
}

.step {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 8px 0;
}

.step-number {
    width: 24px;
    height: 24px;
    background: var(--accent-brand-light);
    color: var(--accent-brand);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 600;
    flex-shrink: 0;
}

.step-text {
    color: var(--text-secondary);
    font-size: 13px;
    padding-top: 2px;
}

.step-text a {
    color: var(--accent-brand);
    text-decoration: none;
}

.step-text a:hover {
    text-decoration: underline;
}

/* ============ Copy Button ============ */
.copy-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    background: var(--accent-brand);
    color: white;
    border: none;
    border-radius: var(--radius-md);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition);
    margin-top: 12px;
}

.copy-btn:hover {
    background: var(--accent-brand-hover);
}

.copy-btn.copied {
    background: var(--accent-success);
}

/* ============ Progress ============ */
.progress-container {
    margin-bottom: 16px;
}

.progress-bar {
    height: 4px;
    background: var(--bg-app);
    border-radius: 2px;
    overflow: hidden;
    margin-bottom: 8px;
}

.progress-fill {
    height: 100%;
    background: var(--accent-brand);
    transition: width 0.3s ease;
    width: 0%;
}

.progress-text {
    font-size: 13px;
    color: var(--text-secondary);
}

/* ============ Results ============ */
.results-box {
    text-align: center;
    padding: 24px;
}

.results-number {
    font-size: 48px;
    font-weight: 600;
    color: var(--accent-brand);
}

.results-label {
    color: var(--text-secondary);
    font-size: 14px;
    margin-bottom: 16px;
}

/* ============ Batch Log ============ */
.batch-log {
    background: var(--bg-app);
    border-radius: var(--radius-md);
    padding: 12px;
    max-height: 200px;
    overflow-y: auto;
    font-family: 'Consolas', 'Monaco', monospace;
    font-size: 12px;
}

.batch-item {
    padding: 4px 0;
    color: var(--text-tertiary);
}

.batch-item.success {
    color: var(--accent-success);
}

.batch-item.error {
    color: var(--accent-danger);
}

/* ============ Complete State ============ */
.complete-state {
    text-align: center;
    padding: 32px;
}

.complete-icon {
    font-size: 48px;
    margin-bottom: 16px;
}

.complete-stats {
    display: flex;
    justify-content: center;
    gap: 32px;
    margin: 16px 0 24px;
    font-size: 16px;
}

/* ============ Template Grid ============ */
.template-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 16px;
}

.template-card {
    background: var(--bg-app);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    padding: 16px;
    transition: all var(--transition);
}

.template-card:hover {
    border-color: var(--accent-brand);
}

.template-name {
    font-weight: 600;
    margin-bottom: 4px;
}

.template-type {
    display: inline-block;
    padding: 2px 8px;
    background: var(--accent-brand-light);
    color: var(--accent-brand);
    border-radius: 4px;
    font-size: 11px;
    text-transform: uppercase;
    margin-bottom: 12px;
}

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

/* ============ Settings ============ */
.settings-section {
    background: var(--bg-app);
    border-radius: var(--radius-md);
    padding: 20px;
    margin-bottom: 16px;
}

.settings-section:last-child {
    margin-bottom: 0;
}

.settings-title {
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    gap: 8px;
}

/* ============ Modal ============ */
.modal {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    z-index: 1000;
    align-items: center;
    justify-content: center;
    padding: 24px;
}

.modal.active {
    display: flex;
}

.modal-content {
    background: var(--bg-surface);
    border-radius: var(--radius-lg);
    width: 100%;
    max-width: 640px;
    max-height: 80vh;
    overflow: hidden;
    box-shadow: var(--shadow-elevation-2);
}

.modal-large {
    max-width: 900px;
}

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

.modal-header h3 {
    font-size: 16px;
    font-weight: 600;
}

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

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

.modal-body {
    padding: 20px;
    overflow-y: auto;
    max-height: calc(80vh - 120px);
}

.modal-body iframe {
    width: 100%;
    height: 450px;
    border: none;
    background: white;
    border-radius: var(--radius-md);
}

.modal-footer {
    padding: 16px 20px;
    border-top: 1px solid var(--border-subtle);
    display: flex;
    justify-content: flex-end;
    gap: 8px;
}

/* ============ Toast ============ */
.toast-container {
    position: fixed;
    bottom: 24px;
    right: 24px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    z-index: 1001;
}

.toast {
    padding: 12px 16px;
    background: var(--bg-elevated);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-elevation-2);
    font-size: 13px;
    animation: slideIn 0.2s ease;
    display: flex;
    align-items: center;
    gap: 8px;
}

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

.toast.error {
    border-left: 3px solid var(--accent-danger);
}

@keyframes slideIn {
    from {
        transform: translateX(100%);
        opacity: 0;
    }

    to {
        transform: translateX(0);
        opacity: 1;
    }
}

/* ============ Select Wrapper ============ */
.select-row {
    display: flex;
    gap: 8px;
}

.select-row select {
    flex: 1;
}

/* ============ Checkbox Row ============ */
.checkbox-row {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
}

/* ============ File Upload ============ */
.file-upload {
    margin-bottom: 12px;
}

.file-name {
    margin-left: 8px;
    color: var(--text-secondary);
    font-size: 13px;
}

/* ============ Recipient Count ============ */
.recipient-count {
    font-size: 12px;
    color: var(--text-tertiary);
    margin-top: 6px;
}

/* ============ Code ============ */
code {
    background: var(--bg-app);
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 12px;
    color: var(--accent-brand);
}

/* ============ Responsive ============ */
@media (max-width: 768px) {
    .sidebar {
        width: 60px;
    }

    .sidebar-logo h1,
    .nav-item span,
    .status-indicator span {
        display: none;
    }

    .nav-item {
        justify-content: center;
    }

    .content-body {
        padding: 16px;
    }
}

/* ============ Stats Grid ============ */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 12px;
    text-align: center;
}

.stat-item {
    background: var(--bg-app);
    border-radius: var(--radius-md);
    padding: 16px 8px;
}

.stat-value {
    display: block;
    font-size: 24px;
    font-weight: 600;
    margin-bottom: 4px;
}

.stat-label {
    font-size: 12px;
    text-transform: uppercase;
}