/* ============================================
   SIMAS - Sistem Informasi Manajemen Surat
   CSS Stylesheet
   ============================================ */

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

:root {
    --primary: #10b981;
    --primary-dark: #047857;
    --primary-light: #d1fae5;
    --amber: #f59e0b;
    --amber-dark: #d97706;
    --amber-light: #fef3c7;
    --danger: #ef4444;
    --danger-light: #fee2e2;
    --sidebar-width: 260px;
    --topbar-height: 64px;
    --bg: #f8fafc;
    --white: #ffffff;
    --text: #1e293b;
    --text-muted: #64748b;
    --border: #e2e8f0;
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
    --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.07), 0 2px 4px -1px rgba(0,0,0,0.04);
    --shadow-lg: 0 10px 25px -3px rgba(0,0,0,0.08), 0 4px 6px -2px rgba(0,0,0,0.03);
    --radius: 12px;
    --radius-sm: 8px;
    --radius-lg: 16px;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    color: var(--text);
    background: var(--bg);
    line-height: 1.6;
    font-size: 14px;
    -webkit-font-smoothing: antialiased;
}

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

img { max-width: 100%; }

/* ---- Login Page ---- */
.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #ecfdf5 0%, #ffffff 50%, #ecfdf5 100%);
    padding: 20px;
}

.login-container { width: 100%; max-width: 420px; text-align: center; }

.login-card {
    background: var(--white);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    padding: 40px 32px;
}

.login-logo { margin-bottom: 28px; }

.logo-icon {
    width: 64px; height: 64px;
    background: linear-gradient(135deg, #10b981, #059669);
    border-radius: 16px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 8px 24px rgba(16,185,129,0.3);
    margin-bottom: 16px;
}

.login-logo h1 {
    font-size: 28px;
    font-weight: 700;
    background: linear-gradient(135deg, #10b981, #059669);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.login-logo p { color: var(--text-muted); font-size: 14px; }

.login-form { text-align: left; }
.login-form .form-group { margin-bottom: 18px; }

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

.input-wrapper {
    display: flex;
    align-items: center;
    gap: 10px;
}

.input-icon-outside {
    width: 40px;
    height: 40px;
    min-width: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #ecfdf5, #d1fae5);
    border: 1px solid #a7f3d0;
    border-radius: var(--radius-sm);
    color: var(--primary);
}

.input-wrapper input {
    flex: 1;
}

.login-footer {
    margin-top: 20px;
    font-size: 13px;
    color: var(--text-muted);
}

.login-footer a { color: var(--primary); font-weight: 500; }
.copyright { font-size: 12px; color: var(--text-muted); margin-top: 24px; }

/* ---- Captcha Widgets ---- */
.captcha-widget {
    margin: 16px 0 8px;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 66px;
}

.captcha-widget > div {
    transform: scale(1);
    transform-origin: center center;
}

.captcha-recaptcha {
    margin-top: 8px;
}

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

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

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

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

.logo-icon-sm {
    width: 40px; height: 40px;
    background: linear-gradient(135deg, #10b981, #059669);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.sidebar-title { font-size: 18px; font-weight: 700; color: var(--text); display: block; }
.sidebar-subtitle { font-size: 11px; color: var(--text-muted); display: block; }

.sidebar-close {
    display: none;
    background: none; border: none;
    padding: 6px; border-radius: 8px;
    cursor: pointer; color: var(--text-muted);
}
.sidebar-close:hover { background: #f1f5f9; }

.sidebar-nav {
    flex: 1;
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    overflow-y: auto;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    border-radius: 10px;
    font-size: 14px;
    font-weight: 500;
    color: #475569;
    transition: all 0.2s;
    text-decoration: none;
    white-space: nowrap;
    overflow: hidden;
}
.nav-item svg {
    flex-shrink: 0;
}
.nav-item:hover { background: #f1f5f9; color: var(--text); text-decoration: none; }
.nav-item.active {
    background: linear-gradient(135deg, #10b981, #059669);
    color: white;
    box-shadow: 0 4px 12px rgba(16,185,129,0.25);
}
.nav-item.active svg { stroke: white; }

.nav-logout { color: #ef4444; }
.nav-logout:hover { background: #fef2f2; color: #dc2626; }

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

.sidebar-user {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    margin-bottom: 4px;
}

.avatar {
    width: 36px; height: 36px;
    border-radius: 50%;
    background: linear-gradient(135deg, #6ee7b7, #34d399);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 700;
    font-size: 14px;
    flex-shrink: 0;
}

.avatar-sm { width: 32px; height: 32px; font-size: 12px; }

.user-info { display: flex; flex-direction: column; }
.user-name { font-size: 13px; font-weight: 600; color: var(--text); }
.user-role { font-size: 11px; color: var(--text-muted); }

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

/* ---- Top Bar ---- */
.topbar {
    height: var(--topbar-height);
    background: rgba(255,255,255,0.8);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    position: sticky;
    top: 0;
    z-index: 50;
}

.menu-toggle {
    display: none;
    background: none; border: none;
    padding: 8px; border-radius: 8px;
    cursor: pointer; color: var(--text);
}
.menu-toggle:hover { background: #f1f5f9; }

.topbar-right {
    display: flex;
    align-items: center;
    gap: 12px;
}

.topbar-user { font-size: 14px; font-weight: 500; }

/* ---- Page Content ---- */
.page-content {
    padding: 24px;
    max-width: 1400px;
    margin: 0 auto;
}

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

.page-header h1 { font-size: 24px; font-weight: 700; color: var(--text); }
.text-muted { color: var(--text-muted); font-size: 13px; }
.text-xs { font-size: 12px; }

/* ---- Buttons ---- */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 9px 18px;
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-weight: 500;
    border: none;
    cursor: pointer;
    transition: all 0.2s;
    text-decoration: none;
    font-family: inherit;
    line-height: 1.4;
    white-space: nowrap;
}
.btn svg {
    flex-shrink: 0;
}

.btn:hover { text-decoration: none; transform: translateY(-1px); }
.btn-sm { padding: 6px 12px; font-size: 13px; }
.btn-block { width: 100%; justify-content: center; }

.btn-primary {
    background: linear-gradient(135deg, #10b981, #059669);
    color: white;
    box-shadow: 0 4px 12px rgba(16,185,129,0.25);
}
.btn-primary:hover { box-shadow: 0 6px 16px rgba(16,185,129,0.35); }

.btn-amber {
    background: linear-gradient(135deg, #f59e0b, #ea580c);
    color: white;
    box-shadow: 0 4px 12px rgba(245,158,11,0.25);
}
.btn-amber:hover { box-shadow: 0 6px 16px rgba(245,158,11,0.35); }

.btn-secondary {
    background: var(--white);
    color: var(--text);
    border: 1px solid var(--border);
}
.btn-secondary:hover { background: #f8fafc; border-color: #cbd5e1; }

.btn-danger {
    background: var(--danger);
    color: white;
}
.btn-danger:hover { background: #dc2626; }

.btn-ghost {
    background: transparent;
    color: var(--text-muted);
}
.btn-ghost:hover { background: #f1f5f9; }

.btn-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px; height: 32px;
    min-width: 32px;
    min-height: 32px;
    border-radius: 8px;
    border: none;
    background: transparent;
    color: #64748b;
    cursor: pointer;
    transition: all 0.2s;
    text-decoration: none;
    flex-shrink: 0;
}
.btn-icon:hover { background: #f1f5f9; color: var(--text); text-decoration: none; }
.btn-icon-warning:hover { background: #fef3c7; color: #d97706; }
.btn-icon-danger:hover { background: #fee2e2; color: #dc2626; }
.btn-icon-info:hover { background: #dbeafe; color: #2563eb; }

/* ---- Cards ---- */
.card {
    background: var(--white);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border);
    overflow: hidden;
}

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

.card-title {
    font-size: 15px;
    font-weight: 600;
    color: var(--text);
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.card-title svg {
    flex-shrink: 0;
}

.card-body { padding: 20px; }
.card-body.p-0 { padding: 0; }

/* ---- Stats Grid ---- */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.stat-card {
    background: var(--white);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    padding: 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border: 1px solid var(--border);
    transition: box-shadow 0.2s;
    gap: 16px;
}
.stat-info {
    flex: 1;
    min-width: 0;
    overflow: hidden;
}
.stat-card:hover { box-shadow: var(--shadow-md); }

.stat-label { font-size: 13px; color: var(--text-muted); font-weight: 500; }
.stat-value { font-size: 28px; font-weight: 700; color: var(--text); margin-top: 4px; }
.stat-sub { font-size: 12px; color: var(--text-muted); margin-top: 4px; }

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

.stat-icon-purple { background: linear-gradient(135deg, #8b5cf6, #7c3aed); color: white; }
.stat-icon-emerald { background: linear-gradient(135deg, #34d399, #10b981); color: white; }
.stat-icon-amber { background: linear-gradient(135deg, #f59e0b, #d97706); color: white; }
.stat-icon-rose { background: linear-gradient(135deg, #059669, #e11d48); color: white; }

/* ---- Dashboard Tables ---- */
.dashboard-tables {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(480px, 1fr));
    gap: 20px;
}

/* ---- Table ---- */
.table-responsive { overflow-x: auto; }

.table {
    width: 100%;
    border-collapse: collapse;
}

.table thead { background: #f8fafc; }

.table th {
    padding: 10px 16px;
    text-align: left;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    white-space: nowrap;
}

.table td {
    padding: 12px 16px;
    font-size: 14px;
    border-top: 1px solid var(--border);
    vertical-align: middle;
}

.table tbody tr:hover { background: #f8fafc; }

.text-truncate { max-width: 200px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.text-right { text-align: right; }

/* ---- File Badge ---- */
.file-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 12px;
    color: var(--text-muted);
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.file-badge svg {
    flex-shrink: 0;
}

/* ---- Badges ---- */
.badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 500;
}
.badge-emerald { background: #d1fae5; color: #065f46; }
.badge-amber { background: #fef3c7; color: #92400e; }
.badge-clickable { cursor: pointer; transition: all 0.15s; text-decoration: none; }
.badge-clickable:hover { opacity: 0.85; transform: translateY(-1px); box-shadow: 0 2px 6px rgba(0,0,0,0.1); }

/* ---- Kategori Link ---- */
.kategori-link { color: var(--text-primary); text-decoration: none; transition: color 0.15s; }
.kategori-link:hover { color: var(--primary); }

/* ---- Filter Badge (aktif di halaman surat) ---- */
.filter-badge {
    display: inline-flex; align-items: center; gap: 6px;
    margin-top: 8px; padding: 6px 12px; border-radius: 20px;
    background: #ede9fe; color: #5b21b6; font-size: 12px; font-weight: 500;
}
.filter-close {
    display: inline-flex; align-items: center; justify-content: center;
    width: 18px; height: 18px; border-radius: 50%; background: #5b21b6; color: #fff;
    font-size: 13px; font-weight: 700; text-decoration: none; line-height: 1;
    transition: background 0.15s;
}
.filter-close:hover { background: #4c1d95; }

/* ---- Status Badges ---- */
.bg-emerald-100 { background: #d1fae5; }
.text-emerald-700 { color: #065f46; }
.bg-amber-100 { background: #fef3c7; }
.text-amber-700 { color: #92400e; }
.bg-blue-100 { background: #dbeafe; }
.text-blue-700 { color: #1d4ed8; }
.bg-red-100 { background: #fee2e2; }
.text-red-700 { color: #b91c1c; }
.bg-green-100 { background: #dcfce7; }
.text-green-700 { color: #15803d; }
.bg-yellow-100 { background: #fef9c3; }
.text-yellow-700 { color: #a16207; }
.bg-gray-100 { background: #f1f5f9; }
.text-gray-700 { color: #374151; }

.inline-block { display: inline-block; }
.px-2\.5 { padding-left: 10px; padding-right: 10px; }
.py-0\.5 { padding-top: 2px; padding-bottom: 2px; }
.rounded-full { border-radius: 9999px; }
.font-medium { font-weight: 500; }

/* ---- Forms ---- */
.form-group { margin-bottom: 18px; }
.form-group label {
    display: block;
    font-size: 13px;
    font-weight: 500;
    color: var(--text);
    margin-bottom: 6px;
}

.required { color: var(--danger); }

.form-group input[type="text"],
.form-group input[type="email"],
.form-group input[type="password"],
.form-group input[type="date"],
.form-group input[type="number"],
.form-group textarea,
.form-group select {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-family: inherit;
    color: var(--text);
    background: var(--white);
    transition: border-color 0.2s, box-shadow 0.2s;
}

.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(16,185,129,0.1);
}

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

.form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0 20px;
}
.form-group.span-2 { grid-column: span 2; }

.form-actions { display: flex; gap: 12px; margin-top: 8px; }

.file-upload { margin-top: 4px; }
.file-upload input[type="file"] {
    width: 100%;
    padding: 8px;
    border: 2px dashed var(--border);
    border-radius: var(--radius-sm);
    background: #fafbfc;
    cursor: pointer;
    font-size: 13px;
}

.file-current {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 6px;
}

/* ---- Search Form ---- */
.search-form {
    display: flex;
    align-items: center;
    gap: 12px;
}
.search-form svg { color: var(--text-muted); flex-shrink: 0; }
.search-form input {
    flex: 1;
    padding: 8px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-family: inherit;
}
.search-form input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(16,185,129,0.1);
}

/* ---- Action Buttons ---- */
.action-buttons {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 4px;
    flex-wrap: wrap;
}

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

.pagination-info { font-size: 13px; color: var(--text-muted); }
.pagination-buttons { display: flex; align-items: center; gap: 6px; }
.pagination-dots { padding: 0 4px; color: var(--text-muted); }

/* ---- Alert ---- */
.alert {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    margin-bottom: 16px;
    font-size: 14px;
}
.alert-error { background: #fee2e2; color: #b91c1c; border: 1px solid #fecaca; }
.alert-success { background: #d1fae5; color: #065f46; border: 1px solid #6ee7b7; }

/* ---- Empty State ---- */
.empty-state {
    text-align: center;
    padding: 48px 24px;
    color: var(--text-muted);
}
.empty-state.small { padding: 24px; }
.empty-icon { opacity: 0.4; margin-bottom: 12px; }
.empty-state p { margin-bottom: 12px; }
.mt-2 { margin-top: 8px; }
.mt-6 { margin-top: 24px; }
.text-center { text-align: center; }

/* ---- Modal ---- */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 200;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.modal {
    background: var(--white);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    width: 100%;
    max-width: 560px;
    max-height: 85vh;
    overflow-y: auto;
    animation: modalIn 0.2s 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;
    padding: 20px 24px;
    border-bottom: 1px solid var(--border);
}

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

.modal-close {
    background: none; border: none;
    font-size: 24px; color: var(--text-muted);
    cursor: pointer; width: 32px; height: 32px;
    display: flex; align-items: center; justify-content: center;
    border-radius: 8px;
}
.modal-close:hover { background: #f1f5f9; }

.modal-body { padding: 24px; }

/* ---- Detail Grid ---- */
.detail-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}
.detail-item { display: flex; flex-direction: column; gap: 4px; }
.detail-item.span-2 { grid-column: span 2; }
.detail-label { font-size: 12px; color: var(--text-muted); font-weight: 500; text-transform: uppercase; letter-spacing: 0.05em; }
.detail-value { font-size: 14px; }

.file-info-card {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    background: #f8fafc;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    flex-wrap: wrap;
}
.file-info-card > svg {
    flex-shrink: 0;
}
.file-info-card > div {
    flex: 1;
    min-width: 120px;
}

/* ---- Toast ---- */
.toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 300;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.toast {
    background: var(--white);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-lg);
    padding: 12px 20px;
    font-size: 14px;
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 280px;
    animation: toastIn 0.3s ease;
    border-left: 4px solid var(--primary);
}
.toast.toast-error { border-left-color: var(--danger); }
.toast.toast-success { border-left-color: #10b981; }

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

/* ---- Overlay for mobile sidebar ---- */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.3);
    z-index: 99;
}

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

/* ---- Responsive ---- */
@media (max-width: 1024px) {
    .dashboard-tables { grid-template-columns: 1fr; }
}

@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
    }
    .sidebar.active {
        transform: translateX(0);
    }
    .sidebar-close { display: block; }
    .menu-toggle { display: block; }

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

    .page-content { padding: 16px; }

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

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

    .form-grid {
        grid-template-columns: 1fr;
    }
    .form-group.span-2 { grid-column: span 1; }

    .detail-grid {
        grid-template-columns: 1fr;
    }
    .detail-item.span-2 { grid-column: span 1; }

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

    .search-form { flex-wrap: wrap; }

    .topbar-user { display: none; }

    .table th, .table td { padding: 8px 12px; font-size: 12px; }

    .action-buttons {
        gap: 2px;
        justify-content: flex-start;
    }
    .btn-icon {
        width: 28px; height: 28px; min-width: 28px; min-height: 28px;
    }
    .btn-icon svg { width: 14px; height: 14px; }

    .file-info-card {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }
    .file-info-card > div { min-width: 100%; }
    .file-info-card .btn { width: 100%; justify-content: center; }

    .pagination-buttons { flex-wrap: wrap; }
}

@media (max-width: 480px) {
    .stats-grid { grid-template-columns: 1fr; }
    .login-card { padding: 28px 20px; }
}

/* ============================================
   SIMAS - Rich Text Editor (Toolbar)
   ============================================ */
.rte-wrapper {
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    overflow: hidden;
    background: var(--white);
}
.rte-wrapper:focus-within { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(16,185,129,0.1); }
.rte-toolbar {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 4px;
    padding: 8px 10px;
    background: #f8fafc;
    border-bottom: 1px solid var(--border);
}
.rte-tb {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 30px; height: 30px;
    border: none;
    border-radius: 6px;
    background: transparent;
    color: #475569;
    cursor: pointer;
    transition: all 0.15s;
    font-family: Georgia, serif;
}
.rte-tb:hover { background: #e2e8f0; color: var(--text); }
.rte-sep { width: 1px; height: 20px; background: var(--border); margin: 0 4px; flex-shrink: 0; }
.rte-select {
    padding: 5px 8px;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 12px;
    font-family: 'Inter', -apple-system, sans-serif;
    background: var(--white);
    color: var(--text);
    cursor: pointer;
    max-width: 150px;
}
.rte-select:focus { outline: none; border-color: var(--primary); }
.rte-area {
    min-height: 300px;
    max-height: 600px;
    overflow-y: auto;
    padding: 16px 18px;
    font-family: 'Times New Roman', Times, serif;
    font-size: 12pt;
    line-height: 1.5;
    outline: none;
    background: var(--white);
    color: #1e293b;
}
.rte-area:empty::before { content: attr(data-placeholder); color: #94a3b8; }
.rte-area p { margin-bottom: 8px; text-align: justify; }
.rte-area ul, .rte-area ol { margin: 0 0 10px 0; padding-left: 26px; }
.rte-area img { max-width: 100%; }
.rte-area .letter-meta, .rte-area table { border-collapse: collapse; }
.rte-area .letter-meta td:first-child { width: 2.4cm; }
.rte-area .letter-signature { margin-left: 52%; }
.rte-area .letter-signature p { text-align: left; }

/* ============================================
   SIMAS - Generator Surat
   ============================================ */
.gen-form-section { margin-bottom: 20px; }
.gen-section-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    font-weight: 700;
    color: var(--text);
    text-transform: uppercase;
    letter-spacing: 0.4px;
    margin-bottom: 12px;
    padding-bottom: 8px;
    border-bottom: 2px solid #f1f5f9;
}
.gen-section-title .gen-step {
    width: 24px; height: 24px;
    min-width: 24px;
    border-radius: 50%;
    background: linear-gradient(135deg, #10b981, #059669);
    color: #fff;
    font-size: 12px;
    font-weight: 700;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
.gen-hint { font-size: 12px; color: var(--text-muted); margin-top: 4px; }
.gen-preview-num {
    background: var(--primary-light);
    border: 1px dashed #34d399;
    color: #065f46;
    border-radius: var(--radius-sm);
    padding: 9px 12px;
    font-size: 13px;
    font-weight: 600;
    margin-top: 6px;
    word-break: break-all;
}
.contact-fields { display: none; }
.contact-fields.show { display: grid; }
.gen-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 8px; }
.gen-actions .btn { flex-shrink: 0; }
.preview-iframe { width: 100%; height: 65vh; border: none; border-radius: var(--radius-sm); background: #e5e7eb; }
.badge-violet { background: #ede9fe; color: #5b21b6; }
.badge-blue { background: #dbeafe; color: #1e40af; }

/* Field builder (template) */
.field-list { display: flex; flex-direction: column; gap: 8px; margin-top: 8px; }
.field-item {
    display: flex;
    align-items: center;
    gap: 8px;
    background: #f8fafc;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 8px 10px;
    font-size: 13px;
}
.field-item .field-key {
    font-family: 'Courier New', monospace;
    background: #ede9fe;
    color: #5b21b6;
    padding: 2px 8px;
    border-radius: 5px;
    font-size: 12px;
    white-space: nowrap;
}
.field-item .field-label { flex: 1; font-weight: 500; }
.field-item .field-remove { color: var(--danger); cursor: pointer; border: none; background: transparent; padding: 4px; border-radius: 6px; }
.field-item .field-remove:hover { background: var(--danger-light); }
.field-add-row { display: flex; gap: 8px; margin-top: 10px; flex-wrap: wrap; }
.field-add-row input { flex: 1; min-width: 140px; }

/* Kop upload */
.kop-dropzone {
    border: 2px dashed #cbd5e1;
    border-radius: var(--radius);
    background: #f8fafc;
    padding: 26px 20px;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s;
}
.kop-dropzone:hover, .kop-dropzone.dragover { border-color: var(--primary); background: var(--primary-light); }
.kop-dropzone input[type="file"] { display: none; }
.kop-dropzone .dz-icon { margin-bottom: 10px; color: #94a3b8; }
.kop-dropzone.dragover .dz-icon { color: var(--primary); }
.kop-dropzone strong { color: var(--primary); }
.kop-preview-card {
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 14px;
    background: var(--white);
}
.kop-preview-card img { max-width: 100%; max-height: 220px; display: block; margin: 0 auto 10px; border: 1px solid #f1f5f9; border-radius: 6px; }
.kop-frame {
    background: #fff;
    border-radius: var(--radius-sm);
    padding: 18px;
    border-bottom: 3.5px solid #000;
    position: relative;
}
.kop-frame::after { content: ''; display: block; border-bottom: 1.5px solid #000; margin-top: 3px; transform: translateY(4px); }
.kop-frame img { max-width: 100%; max-height: 5.5cm; display: block; margin: 0 auto; }

/* ============================================
   SIMAS - Preview & Print Surat
   ============================================ */
.letter-preview-wrap { background: #e5e7eb; border-radius: var(--radius-sm); overflow: hidden; }
@media (max-width: 768px) {
    .rte-area { padding: 12px; font-size: 11pt; }
    .letter-signature { margin-left: 30% !important; }
}
