/* ============================================================
   Techsend — Design System
   Color palette from specification
   ============================================================ */
:root {
    --bg: #EAE2DC;
    --panel: #F3ECE6;
    --panel-soft: #F8F3EE;
    --sidebar: #111113;
    --accent: #E97A45;
    --accent-hover: #d46835;
    --text: #2B2420;
    --muted: #8A7C74;
    --success: #49A05A;
    --warning: #E5B647;
    --danger: #E05252;
    --white: #FFFFFF;
    --border: #D8CFC8;
    --sidebar-text: #A8A3A0;
    --sidebar-active: #FFFFFF;
    --radius: 12px;
    --radius-sm: 8px;
    --shadow: 0 1px 3px rgba(43,36,32,0.08), 0 4px 12px rgba(43,36,32,0.04);
    --shadow-lg: 0 4px 16px rgba(43,36,32,0.12), 0 12px 40px rgba(43,36,32,0.06);
    --transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

* { margin: 0; padding: 0; box-sizing: border-box; }
body {
    font-family: 'Inter', -apple-system, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    overflow: hidden;
    height: 100vh;
}

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

/* Sidebar */
.sidebar {
    width: 260px;
    background: var(--sidebar);
    display: flex;
    flex-direction: column;
    padding: 0;
    flex-shrink: 0;
    transition: var(--transition);
}
.sidebar-header {
    padding: 24px 20px 20px;
    border-bottom: 1px solid rgba(255,255,255,0.06);
    display: flex;
    align-items: center;
    gap: 12px;
}
.sidebar-header img {
    width: 40px;
    height: 40px;
    border-radius: 10px;
}
.sidebar-header h1 {
    font-size: 18px;
    font-weight: 700;
    color: var(--white);
    letter-spacing: -0.3px;
}
.sidebar-header span {
    display: block;
    font-size: 11px;
    color: var(--sidebar-text);
    font-weight: 400;
    margin-top: 1px;
}
.sidebar-nav {
    flex: 1;
    padding: 12px 10px;
    overflow-y: auto;
}
.nav-section-title {
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--muted);
    padding: 16px 12px 6px;
}
.nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    color: var(--sidebar-text);
    cursor: pointer;
    transition: var(--transition);
    font-size: 13.5px;
    font-weight: 500;
    margin-bottom: 2px;
    user-select: none;
}
.nav-item:hover {
    background: rgba(255,255,255,0.06);
    color: var(--white);
}
.nav-item.active {
    background: var(--accent);
    color: var(--white);
}
.nav-item i { width: 18px; height: 18px; opacity: 0.85; }
.nav-item.active i { opacity: 1; }

.sidebar-footer {
    padding: 16px 14px;
    border-top: 1px solid rgba(255,255,255,0.06);
}
.user-info {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px;
    border-radius: var(--radius-sm);
}
.user-avatar {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: var(--accent);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    color: var(--white);
    font-size: 13px;
    flex-shrink: 0;
}
.user-name {
    font-size: 13px;
    font-weight: 600;
    color: var(--white);
    line-height: 1.2;
}
.user-email {
    font-size: 11px;
    color: var(--sidebar-text);
}
.btn-logout {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    border: none;
    background: rgba(255,255,255,0.04);
    color: var(--sidebar-text);
    font-size: 12px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    width: 100%;
    margin-top: 8px;
    transition: var(--transition);
}
.btn-logout:hover { background: rgba(224,82,82,0.15); color: var(--danger); }

/* Main content */
.main {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}
.topbar {
    padding: 18px 32px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--border);
    background: var(--panel-soft);
}
.topbar h2 {
    font-size: 20px;
    font-weight: 700;
    letter-spacing: -0.3px;
}
.topbar-actions { display: flex; gap: 10px; }

.content {
    flex: 1;
    overflow-y: auto;
    padding: 28px 32px;
}

/* ============================================================
   Login Screen
   ============================================================ */
.login-screen {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100vh;
    background: var(--bg);
}
.login-card {
    background: var(--white);
    border-radius: 20px;
    padding: 48px 40px;
    width: 100%;
    max-width: 420px;
    box-shadow: var(--shadow-lg);
    text-align: center;
}
.login-card img {
    width: 72px;
    height: 72px;
    border-radius: 16px;
    margin-bottom: 20px;
}
.login-card h1 {
    font-size: 24px;
    font-weight: 800;
    margin-bottom: 4px;
    letter-spacing: -0.5px;
}
.login-card p {
    color: var(--muted);
    font-size: 14px;
    margin-bottom: 28px;
}
.login-card .form-group {
    text-align: left;
    margin-bottom: 18px;
}
.login-card label {
    font-size: 13px;
    font-weight: 600;
    color: var(--text);
    display: block;
    margin-bottom: 6px;
}
.login-card input {
    width: 100%;
    padding: 12px 14px;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-family: inherit;
    transition: var(--transition);
    background: var(--panel-soft);
}
.login-card input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(233,122,69,0.12);
}
.login-error {
    background: rgba(224,82,82,0.08);
    color: var(--danger);
    padding: 10px 14px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    margin-bottom: 14px;
    display: none;
}

/* ============================================================
   Buttons
   ============================================================ */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    border-radius: var(--radius-sm);
    font-size: 13.5px;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: var(--transition);
    border: none;
    user-select: none;
}
.btn-primary {
    background: var(--accent);
    color: var(--white);
}
.btn-primary:hover { background: var(--accent-hover); transform: translateY(-1px); }
.btn-secondary {
    background: var(--panel);
    color: var(--text);
    border: 1.5px solid var(--border);
}
.btn-secondary:hover { background: var(--bg); }
.btn-danger {
    background: rgba(224,82,82,0.1);
    color: var(--danger);
}
.btn-danger:hover { background: rgba(224,82,82,0.2); }
.btn-success {
    background: var(--success);
    color: var(--white);
}
.btn-success:hover { opacity: 0.9; }
.btn-sm { padding: 7px 14px; font-size: 12.5px; }
.btn-block { width: 100%; justify-content: center; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }

/* ============================================================
   Cards & Panels
   ============================================================ */
.card {
    background: var(--white);
    border-radius: var(--radius);
    padding: 24px;
    box-shadow: var(--shadow);
    margin-bottom: 20px;
}
.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 18px;
}
.card-title {
    font-size: 16px;
    font-weight: 700;
    letter-spacing: -0.2px;
}

/* Stats grid */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}
.stat-card {
    background: var(--white);
    border-radius: var(--radius);
    padding: 20px;
    box-shadow: var(--shadow);
}
.stat-icon {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 12px;
}
.stat-icon.orange { background: rgba(233,122,69,0.12); color: var(--accent); }
.stat-icon.green { background: rgba(73,160,90,0.12); color: var(--success); }
.stat-icon.yellow { background: rgba(229,182,71,0.12); color: var(--warning); }
.stat-icon.red { background: rgba(224,82,82,0.12); color: var(--danger); }
.stat-value {
    font-size: 28px;
    font-weight: 800;
    letter-spacing: -1px;
    line-height: 1;
    margin-bottom: 4px;
}
.stat-label {
    font-size: 13px;
    color: var(--muted);
    font-weight: 500;
}

/* ============================================================
   Tables
   ============================================================ */
.table-wrap { overflow-x: auto; }
table {
    width: 100%;
    border-collapse: collapse;
}
th {
    text-align: left;
    font-size: 11.5px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--muted);
    padding: 10px 14px;
    border-bottom: 1.5px solid var(--border);
}
td {
    padding: 12px 14px;
    font-size: 13.5px;
    border-bottom: 1px solid var(--border);
}
tr:hover td { background: var(--panel-soft); }

.badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 11.5px;
    font-weight: 600;
}
.badge-success { background: rgba(73,160,90,0.12); color: var(--success); }
.badge-warning { background: rgba(229,182,71,0.12); color: #b8922e; }
.badge-danger { background: rgba(224,82,82,0.1); color: var(--danger); }
.badge-info { background: rgba(233,122,69,0.1); color: var(--accent); }
.badge-muted { background: rgba(138,124,116,0.1); color: var(--muted); }

/* ============================================================
   Forms / Modals
   ============================================================ */
.form-group { margin-bottom: 18px; }
.form-group label {
    font-size: 13px;
    font-weight: 600;
    display: block;
    margin-bottom: 6px;
}
.form-control {
    width: 100%;
    padding: 10px 14px;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-family: inherit;
    transition: var(--transition);
    background: var(--panel-soft);
}
.form-control:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(233,122,69,0.12);
}
textarea.form-control { min-height: 100px; resize: vertical; }
select.form-control {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='%238A7C74' viewBox='0 0 16 16'%3E%3Cpath d='M8 11L3 6h10l-5 5z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 36px;
}

.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(17,17,19,0.5);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s;
}
.modal-overlay.active { opacity: 1; pointer-events: all; }
.modal {
    background: var(--white);
    border-radius: 16px;
    padding: 32px;
    width: 90%;
    max-width: 560px;
    max-height: 85vh;
    overflow-y: auto;
    box-shadow: var(--shadow-lg);
    transform: translateY(20px);
    transition: transform 0.2s;
}
.modal-overlay.active .modal { transform: translateY(0); }
.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 24px;
}
.modal-title { font-size: 18px; font-weight: 700; }
.modal-close {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    border: none;
    background: var(--panel);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
}
.modal-close:hover { background: var(--bg); }

/* File upload */
.upload-zone {
    border: 2px dashed var(--border);
    border-radius: var(--radius);
    padding: 40px 20px;
    text-align: center;
    cursor: pointer;
    transition: var(--transition);
    background: var(--panel-soft);
}
.upload-zone:hover, .upload-zone.dragover {
    border-color: var(--accent);
    background: rgba(233,122,69,0.04);
}
.upload-zone i { color: var(--muted); margin-bottom: 10px; }
.upload-zone p { color: var(--muted); font-size: 14px; }
.upload-zone .highlight { color: var(--accent); font-weight: 600; }

/* Variable chips */
.var-chip {
    display: inline-block;
    background: rgba(233,122,69,0.1);
    color: var(--accent);
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 600;
    font-family: monospace;
    cursor: pointer;
    margin: 2px;
}
.var-chip:hover { background: rgba(233,122,69,0.2); }

/* Mapping row */
.mapping-row {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 10px;
}
.mapping-row .arrow { color: var(--muted); font-size: 18px; flex-shrink: 0; }

/* Progress bar */
.progress-bar {
    height: 8px;
    background: var(--panel);
    border-radius: 10px;
    overflow: hidden;
    margin-top: 8px;
}
.progress-fill {
    height: 100%;
    background: var(--accent);
    border-radius: 10px;
    transition: width 0.5s ease;
}

/* Empty state */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--muted);
}
.empty-state i { margin-bottom: 16px; opacity: 0.4; }
.empty-state h3 {
    font-size: 16px;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 6px;
}
.empty-state p { font-size: 14px; margin-bottom: 20px; }

/* Toast */
.toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 2000;
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.toast {
    background: var(--white);
    border-radius: var(--radius-sm);
    padding: 14px 20px;
    box-shadow: var(--shadow-lg);
    font-size: 13.5px;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 10px;
    animation: slideIn 0.3s ease;
    min-width: 280px;
}
.toast.success { border-left: 4px solid var(--success); }
.toast.error { border-left: 4px solid var(--danger); }
.toast.info { border-left: 4px solid var(--accent); }
@keyframes slideIn {
    from { transform: translateX(100px); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

/* Spinner */
.spinner {
    width: 20px;
    height: 20px;
    border: 2.5px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
    display: inline-block;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Preview table container */
.preview-table-wrap {
    max-height: 300px;
    overflow: auto;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
}
.preview-table-wrap table { font-size: 12.5px; }
.preview-table-wrap th { position: sticky; top: 0; background: var(--panel); z-index: 1; }

/* Template editor */
.template-preview {
    background: var(--panel-soft);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 16px;
    margin-top: 10px;
    font-size: 14px;
    white-space: pre-wrap;
    word-wrap: break-word;
}

/* Meta status badges */
.badge-meta-local { background: rgba(138,124,116,0.12); color: var(--muted); }
.badge-meta-pending { background: rgba(229,182,71,0.15); color: #b8922e; }
.badge-meta-approved { background: rgba(73,160,90,0.15); color: var(--success); }
.badge-meta-rejected { background: rgba(224,82,82,0.12); color: var(--danger); }
.badge-meta-paused { background: rgba(233,122,69,0.12); color: var(--accent); }
.badge-meta-disabled { background: rgba(138,124,116,0.2); color: #666; }

/* Template card actions row */
.tpl-actions { display: flex; gap: 4px; flex-wrap: wrap; }
.tpl-meta-info { font-size: 11.5px; color: var(--muted); margin-top: 4px; }

/* Category pills */
.cat-pill {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}
.cat-utility { background: rgba(73,160,90,0.1); color: var(--success); }
.cat-marketing { background: rgba(233,122,69,0.1); color: var(--accent); }
.cat-authentication { background: rgba(229,182,71,0.1); color: #b8922e; }

/* Hide all pages by default */
.page { display: none; }
.page.active { display: block; }

/* Responsive */
@media (max-width: 768px) {
    .sidebar { width: 60px; }
    .sidebar-header h1, .sidebar-header span,
    .nav-section-title, .nav-item span,
    .user-name, .user-email, .btn-logout span { display: none; }
    .sidebar-header { padding: 16px; justify-content: center; }
    .nav-item { justify-content: center; padding: 12px; }
    .content { padding: 20px 16px; }
    .topbar { padding: 14px 16px; }
}

/* Scrollbar */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 10px; }
::-webkit-scrollbar-thumb:hover { background: var(--muted); }
