/* =========================================
   SIGNFLOW PREMIUM CSS (FULL FINAL)
   ========================================= */

/* 1. VARIABLES */
:root {
    --primary: #4f46e5;
    --primary-hover: #4338ca;
    --primary-light: #eef2ff;
    --bg-body: #f8fafc;
    --bg-card: #ffffff;
    --text-main: #0f172a;
    --text-muted: #64748b;
    --border: #e2e8f0;
    --success: #10b981;
    --warning: #f59e0b;
    --sidebar-width: 280px;
    --header-height: 70px;
    --radius: 8px;
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1);
}

/* 2. RESET */
* {
    box-sizing: border-box !important;
    margin: 0;
    padding: 0;
    outline: none;
}

body {
    font-family: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, sans-serif !important;
    background-color: var(--bg-body) !important;
    color: var(--text-main) !important;
    height: 100vh;
    display: flex;
    overflow: hidden;
    -webkit-font-smoothing: antialiased;
}

/* 3. LAYOUT SYSTEM */
#app {
    display: flex;
    width: 100%;
    height: 100%;
}

/* Sidebar */
.sidebar {
    width: var(--sidebar-width);
    background-color: var(--bg-card);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    z-index: 50;
    transition: transform 0.3s ease;
    flex-shrink: 0;
}

.brand-section {
    height: var(--header-height);
    display: flex;
    align-items: center;
    padding: 0 24px;
    border-bottom: 1px solid #f1f5f9;
}

.brand-logo {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--primary);
    display: flex;
    align-items: center;
    gap: 10px;
}

.nav-section {
    flex: 1;
    padding: 24px 16px;
    overflow-y: auto;
}

.nav-label {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    margin-bottom: 8px;
    padding-left: 12px;
    letter-spacing: 0.5px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    border-radius: var(--radius);
    color: var(--text-muted);
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    margin-bottom: 4px;
}

.nav-item:hover {
    background-color: var(--bg-body);
    color: var(--text-main);
}

.nav-item.active {
    background-color: var(--primary-light);
    color: var(--primary);
    font-weight: 600;
}

.user-profile {
    padding: 20px;
    border-top: 1px solid #f1f5f9;
    display: flex;
    align-items: center;
    gap: 12px;
    cursor: pointer;
}

.avatar {
    width: 36px; height: 36px;
    background: var(--primary);
    color: white;
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-weight: 700; font-size: 0.9rem;
}

/* Main Wrapper */
.main-wrapper {
    flex: 1;
    display: flex;
    flex-direction: column;
    position: relative;
    overflow: hidden;
}

/* Header */
.top-header {
    height: var(--header-height);
    background-color: var(--bg-card);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 32px;
    flex-shrink: 0;
}

.header-left { display: flex; align-items: center; gap: 16px; }
.page-title { font-size: 1.25rem; font-weight: 700; color: var(--text-main); }

/* Content Area */
.content-area {
    flex: 1;
    padding: 32px;
    overflow-y: auto;
    position: relative;
    background-color: var(--bg-body);
}

/* =========================================
   PERBAIKAN KRUSIAL: VIEW SECTION
   ========================================= */
.view-section {
    display: none !important; /* Default hidden */
    max-width: 1200px;
    margin: 0 auto;
    opacity: 0;
    animation: fadeIn 0.3s ease-in-out forwards;
}

.view-section.active {
    display: block !important; /* WAJIB BLOCK saat aktif */
    opacity: 1;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* 4. COMPONENTS UI */

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 20px;
    border-radius: var(--radius);
    font-weight: 600;
    font-size: 0.875rem;
    cursor: pointer;
    transition: all 0.2s;
    border: none;
}
.btn-primary { background-color: var(--primary); color: white; }
.btn-primary:hover { background-color: var(--primary-hover); }
.btn-secondary { background-color: white; border: 1px solid #cbd5e1; color: var(--text-main); }
.btn-secondary:hover { background-color: #f8fafc; border-color: #94a3b8; }
.btn-ghost { background: transparent; color: var(--text-muted); }
.btn-ghost:hover { background-color: var(--bg-body); color: var(--text-main); }

/* Icons */
.icon-btn {
    width: 40px; height: 40px;
    border-radius: 50%;
    border: 1px solid #e2e8f0;
    background: white;
    color: var(--text-muted);
    display: flex; align-items: center; justify-content: center;
    cursor: pointer; transition: 0.2s;
}
.icon-btn:hover { background-color: #f1f5f9; color: var(--text-main); }

/* Cards */
.card {
    background-color: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 24px;
    box-shadow: var(--shadow-sm);
}

/* Stats Grid */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 24px;
    margin-bottom: 32px;
}
.stat-card {
    display: flex;
    align-items: center;
    gap: 16px;
}
.stat-icon {
    width: 48px; height: 48px;
    border-radius: 10px;
    display: flex; align-items: center; justify-content: center;
    font-size: 1.25rem;
}
.stat-info h3 { font-size: 1.75rem; font-weight: 800; line-height: 1.2; margin-bottom: 4px; }
.stat-info p { font-size: 0.875rem; color: var(--text-muted); font-weight: 500; }

/* Table */
.table-container {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow-x: auto;
    box-shadow: var(--shadow-sm);
}
table { width: 100%; border-collapse: collapse; min-width: 600px; }
th {
    background-color: #f8fafc;
    padding: 16px 24px;
    text-align: left;
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border);
}
td {
    padding: 16px 24px;
    border-bottom: 1px solid #f1f5f9;
    color: var(--text-main);
    font-size: 0.875rem;
}
tr:last-child td { border-bottom: none; }
tr:hover td { background-color: #fcfcfc; }

/* Badges */
.badge {
    display: inline-flex; align-items: center;
    padding: 4px 12px; border-radius: 20px;
    font-size: 0.75rem; font-weight: 700;
}
.badge-success { background-color: #ecfdf5; color: #047857; }
.badge-warning { background-color: #fffbeb; color: #b45309; }

/* 5. EDITOR UI */
.workspace-grid {
    display: grid;
    grid-template-columns: 1fr 300px;
    gap: 24px;
    height: calc(100vh - 140px);
}
.doc-canvas-wrapper {
    background-color: #cbd5e1;
    border-radius: var(--radius);
    padding: 32px;
    overflow-y: auto;
    display: flex;
    justify-content: center;
}
.paper {
    background: white;
    width: 100%;
    max-width: 600px;
    min-height: 800px;
    padding: 40px;
    box-shadow: var(--shadow-md);
    font-family: 'Georgia', serif;
    color: #334155;
    position: relative;
}
.sign-area {
    border: 2px dashed var(--primary);
    background-color: rgba(79, 70, 229, 0.03);
    padding: 24px;
    text-align: center;
    margin-top: 40px;
    border-radius: 8px;
    cursor: pointer;
    transition: 0.2s;
}
.sign-area:hover {
    background-color: rgba(79, 70, 229, 0.08);
    transform: scale(1.01);
}

/* 6. UPLOAD UI */
.upload-zone {
    border: 2px dashed #cbd5e1;
    border-radius: var(--radius);
    background: #f8fafc;
    padding: 64px 24px;
    text-align: center;
    cursor: pointer;
    transition: 0.2s;
}
.upload-zone:hover { border-color: var(--primary); background: var(--primary-light); }
.upload-icon {
    width: 64px; height: 64px; background: white; border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    margin: 0 auto 16px; font-size: 1.5rem; color: var(--primary);
    box-shadow: var(--shadow-sm);
}

/* 7. MODAL & TOAST */
.modal-backdrop {
    position: fixed; inset: 0;
    background-color: rgba(15, 23, 42, 0.6);
    backdrop-filter: blur(4px);
    z-index: 100;
    display: none; align-items: center; justify-content: center;
}
.modal-backdrop.open { display: flex; animation: fadeIn 0.2s; }
.modal-content {
    background: white; border-radius: var(--radius);
    padding: 24px; width: 100%; max-width: 480px;
    box-shadow: var(--shadow-md);
}
.canvas-wrapper {
    border: 1px solid #e2e8f0;
    border-radius: var(--radius);
    background: white; margin: 16px 0;
    cursor: crosshair;
}

.toast {
    position: fixed; bottom: 24px; right: 24px;
    background: white; border-left: 4px solid var(--primary);
    padding: 16px 24px; border-radius: var(--radius);
    box-shadow: var(--shadow-md);
    display: flex; align-items: center; gap: 12px;
    font-weight: 600; transform: translateY(100px);
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    z-index: 200;
}
.toast.show { transform: translateY(0); }

/* Utilities */
.hidden { display: none !important; }
.flex-between { display: flex; justify-content: space-between; align-items: center; }
.menu-toggle { display: none; }

/* Responsive */
@media (max-width: 768px) {
    .sidebar {
        position: fixed; top: 0; left: 0; height: 100%;
        transform: translateX(-100%); box-shadow: 2px 0 10px rgba(0,0,0,0.1);
    }
    .sidebar.active { transform: translateX(0); }
    .menu-toggle { display: flex; }
    .top-header { padding: 0 16px; }
    .content-area { padding: 16px; }
    .stats-grid { grid-template-columns: 1fr; }
    .workspace-grid { grid-template-columns: 1fr; grid-template-rows: 1fr auto; }
    .sidebar-tools { display: none; }
    .paper { padding: 24px; min-height: auto; }
}