/* ==========================================================================
   SDN SIGNATURE - MASTER STYLE (FULL RESTORED VERSION)
   Content: Login, Dashboard (Mobile/Desktop), PDF Editor, & Components.
   Lines: 300+ (No Logic Removed)
   ========================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@400;500;600;700;800&display=swap');

:root {
    /* MAIN COLORS */
    --primary: #4361ee;
    --primary-gradient: linear-gradient(135deg, #4361ee 0%, #304ffe 100%);
    --secondary: #64748b;
    --dark: #1e293b;
    --light: #f8fafc;
    --border: #e2e8f0;
    --white: #ffffff;
    --success: #10b981;
    --danger: #ef4444;
    
    /* DIMENSIONS */
    --sidebar-w: 260px;
    --radius: 12px;
    
    /* SHADOWS */
    --shadow-sm: 0 2px 4px rgba(0,0,0,0.05);
    --shadow-card: 0 10px 30px -5px rgba(0, 0, 0, 0.1);
    --shadow-glow: 0 5px 15px rgba(67, 97, 238, 0.3);
}

/* RESET & BODY */
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; outline: none; }

body {
    font-family: 'Plus Jakarta Sans', sans-serif;
    background: #f1f5f9;
    min-height: 100vh; margin: 0; padding: 0;
    color: var(--dark);
    /* Default Flex untuk Dashboard */
    display: flex; justify-content: center; align-items: flex-start;
}

/* ==========================================================================
   1. KHUSUS HALAMAN LOGIN (FIX TENGAH)
   ========================================================================== */
/* Tambahkan class="login-mode" di body login.php jika perlu spesifik */
body.login-mode {
    align-items: center; /* Paksa tengah vertikal */
}

.glass-container.auth {
    width: 100%; max-width: 420px; /* Ukuran pas, tidak melebar */
    padding: 40px; 
    background: white; 
    border-radius: 16px;
    text-align: center; 
    box-shadow: var(--shadow-card);
    margin: 20px; 
    border: 1px solid white;
}
.glass-container.auth .logo-area img { width: 90px; margin-bottom: 20px; }
.glass-container.auth h3 { color: var(--primary); margin: 0 0 5px; font-size: 1.5rem; }
.glass-container.auth p { color: var(--secondary); font-size: 0.9rem; }

/* ==========================================================================
   2. LAYOUT DASHBOARD (RESPONSIVE)
   ========================================================================== */
.dashboard-wrapper {
    display: flex; width: 100%; min-height: 100vh;
}

/* SIDEBAR (Desktop Default) */
.sidebar {
    width: var(--sidebar-w); 
    background: #ffffff;
    border-right: 1px solid var(--border); 
    padding: 25px 20px;
    display: flex; flex-direction: column;
    position: fixed; height: 100vh; left: 0; top: 0; z-index: 50;
    overflow-y: auto;
}
.logo-area { text-align: center; margin-bottom: 30px; }
.logo-area img { width: 80px; margin-bottom: 10px; }
.logo-area h3 { font-size: 1.1rem; color: var(--primary); margin: 0; }
.logo-area p { font-size: 0.85rem; color: var(--secondary); margin: 0; }

.menu-group { display: flex; flex-direction: column; gap: 8px; }

.nav-item {
    padding: 12px 15px; border-radius: var(--radius);
    color: var(--secondary); text-decoration: none; font-weight: 600; font-size: 0.95rem;
    display: flex; align-items: center; gap: 12px; transition: 0.2s;
}
.nav-item:hover { background: #f8fafc; color: var(--primary); }
.nav-item.active { background: var(--primary-gradient); color: white; box-shadow: var(--shadow-glow); }
.logout-btn { margin-top: auto; color: var(--danger); }
.logout-btn:hover { background: #fee2e2; }

/* CONTENT AREA */
.content {
    margin-left: var(--sidebar-w);
    flex: 1; padding: 40px; background: #f8fafc;
    width: calc(100% - var(--sidebar-w));
}
.content h2 { font-size: 1.8rem; margin: 0 0 5px 0; color: #0f172a; }
.subtitle { color: var(--secondary); margin-bottom: 30px; }

/* HEADER MOBILE (Hidden di Desktop) */
.mobile-header { display: none; }

/* ==========================================================================
   3. MOBILE APP VIEW (MAX-WIDTH 768PX)
   ========================================================================== */
@media (max-width: 768px) {
    body { display: block; } /* Reset flex body */
    .dashboard-wrapper { flex-direction: column; }

    /* Header Atas */
    .mobile-header {
        display: flex; align-items: center; justify-content: space-between;
        background: white; padding: 15px 20px;
        position: fixed; top: 0; left: 0; width: 100%; z-index: 40;
        border-bottom: 1px solid var(--border);
        box-shadow: var(--shadow-sm);
    }
    .mobile-logo { display: flex; align-items: center; gap: 10px; font-weight: bold; color: var(--primary); }
    .mobile-logo img { height: 32px; }

    /* Sidebar Transform ke Bottom Navigation */
    .sidebar {
        width: 100%; height: auto;
        position: fixed; bottom: 0; left: 0; top: auto;
        flex-direction: row; padding: 8px 15px;
        border-right: none; border-top: 1px solid var(--border);
        justify-content: space-around;
        background: rgba(255,255,255,0.98);
        backdrop-filter: blur(10px);
        box-shadow: 0 -5px 20px rgba(0,0,0,0.05);
    }
    .sidebar .logo-area { display: none; } /* Hide logo di bottom nav */
    
    .menu-group { 
        flex-direction: row; width: 100%; justify-content: space-between; gap: 0; 
    }
    .nav-item {
        flex-direction: column; gap: 4px; padding: 5px;
        font-size: 0.7rem; text-align: center; border-radius: 8px;
        flex: 1; background: transparent !important; box-shadow: none !important;
        color: #94a3b8;
    }
    .nav-item.active { color: var(--primary); }
    .nav-item i { font-size: 1.2rem; display: block; margin-bottom: 2px; }

    /* Content Adjustment */
    .content {
        margin-left: 0; width: 100%;
        padding: 80px 20px 100px 20px; /* Spacer untuk header & navbar */
    }
}

/* ==========================================================================
   4. COMPONENTS (BUTTONS, CARDS, INPUTS)
   ========================================================================== */
.card-white { 
    background: white; border: 1px solid var(--border); border-radius: var(--radius); 
    padding: 25px; margin-bottom: 20px; box-shadow: var(--shadow-sm); 
}

.form-group { margin-bottom: 20px; }
.form-control { 
    width: 100%; padding: 12px; border: 1px solid var(--border); 
    border-radius: 8px; font-size: 1rem; transition: 0.2s;
}
.form-control:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(67, 97, 238, 0.1); }

/* Tombol & Input File */
input[type="file"] { padding: 8px; background: white; width: 100%; }
input[type="file"]::file-selector-button { 
    background: var(--primary-gradient); color: white; border: none; 
    padding: 8px 15px; border-radius: 6px; margin-right: 10px; cursor: pointer; 
}

.btn-primary { 
    background: var(--primary-gradient); color: white; padding: 12px; 
    border-radius: 8px; border: none; font-weight: 700; width: 100%; 
    cursor: pointer; display: flex; align-items: center; justify-content: center; gap: 8px;
    box-shadow: 0 4px 10px rgba(67,97,238,0.2); transition: 0.2s;
}
.btn-primary:hover { transform: translateY(-2px); box-shadow: 0 6px 15px rgba(67,97,238,0.3); }

.btn-secondary { 
    background: white; border: 1px solid var(--border); color: var(--dark); 
    padding: 8px 15px; border-radius: 8px; cursor: pointer; 
}

/* Tabs & Grid */
.sig-option-tabs { display: flex; gap: 8px; background: #f1f5f9; padding: 5px; border-radius: 10px; margin-bottom: 15px; overflow-x: auto; }
.tab-btn { flex: 1; padding: 10px; background: transparent; border: none; color: var(--secondary); font-weight: 600; border-radius: 8px; cursor: pointer; white-space: nowrap; }
.tab-btn.active { background: white; color: var(--primary); box-shadow: var(--shadow-sm); }

.saved-sig-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(80px, 1fr)); gap: 10px; margin-top: 10px; }
.sig-item { border: 1px solid var(--border); border-radius: 8px; height: 70px; display: flex; align-items: center; justify-content: center; cursor: pointer; position: relative; background: white; }
.sig-item.selected { border-color: var(--primary); background: #eff6ff; box-shadow: 0 0 0 2px rgba(67, 97, 238, 0.2); }
.sig-item img { max-width: 100%; max-height: 100%; }
.btn-delete-sig { position: absolute; top: -5px; right: -5px; width: 20px; height: 20px; background: var(--danger); color: white; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 12px; cursor: pointer; }

/* ==========================================================================
   5. KHUSUS EDITOR PDF (PERBAIKAN LAYOUT RUSAK)
   ========================================================================== */
   
/* Layout Halaman Editor PDF */
.editor-card {
    background: white; border-radius: var(--radius); padding: 20px;
    min-height: 85vh; display: flex; flex-direction: column;
    margin-bottom: 20px; border: 1px solid var(--border);
    box-shadow: var(--shadow-sm);
}

/* Container Canvas PDF (Area Kerja) */
.editor-area {
    background: #525659; /* Abu gelap khas PDF Viewer */
    border-radius: 8px;
    overflow: hidden; /* Scrollable jika PDF besar */
    display: flex; justify-content: center;
    position: relative;
    border: 1px solid #ccc;
    margin-bottom: 20px;
    min-height: 500px;
}
#pdf-canvas { display: block; max-width: 100%; height: auto; box-shadow: 0 5px 15px rgba(0,0,0,0.3); }

/* ==========================================================================
   6. ADVANCED SIGNATURE STYLES (DARI GUEST_SIGN.PHP)
   ========================================================================== */
/* Wrapper Utama yang Bisa Digeser & Diputar */
.ttd-wrapper {
    position: absolute; top: 50%; left: 50%;
    width: 150px; height: 80px; z-index: 100;
    touch-action: none; user-select: none;
    transform-origin: center center;
}

/* Kotak Tanda Tangan */
.ttd-box {
    width: 100%; height: 100%; position: relative;
    border: 2px solid #4361ee; background: rgba(67, 97, 238, 0.1);
    cursor: grab;
}

.ttd-image { width: 100%; height: 100%; object-fit: contain; pointer-events: none; }

/* Node Resize (Titik Pojok) - PENTING DI HP */
.resize-node {
    position: absolute; width: 24px; height: 24px;
    background: white; border: 2px solid #4361ee; border-radius: 50%; z-index: 102;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}
.rn-tl { top: -12px; left: -12px; }
.rn-tr { top: -12px; right: -12px; }
.rn-bl { bottom: -12px; left: -12px; }
.rn-br { bottom: -12px; right: -12px; }

/* Knob Rotasi (Gagang Putar) */
.rotate-handle {
    position: absolute; top: -45px; left: 50%; transform: translateX(-50%);
    width: 32px; height: 32px; background: white; border-radius: 50%;
    box-shadow: 0 2px 5px rgba(0,0,0,0.2); display: flex; align-items: center; justify-content: center;
    cursor: grab; z-index: 102; color: #4361ee; font-weight: bold; font-size: 18px;
}
.rotate-line { position: absolute; top: -28px; left: 50%; width: 2px; height: 28px; background: #4361ee; z-index: 101; }

/* Controls (Tombol Prev/Next Halaman) */
.page-controls { display: flex; justify-content: center; align-items: center; gap: 15px; margin-bottom: 15px; }
.page-btn { background: white; border: 1px solid var(--border); padding: 8px 15px; border-radius: 6px; cursor: pointer; font-weight: bold; }

/* List Posisi TTD (Queue) */
.sig-list-container {
    background: #f8fafc; padding: 15px; border-radius: 8px; border: 1px solid var(--border);
    margin-bottom: 20px; max-height: 200px; overflow-y: auto;
}
.sig-item-row { 
    display: flex; justify-content: space-between; align-items: center;
    background: white; padding: 10px; border-radius: 6px; margin-bottom: 5px; border: 1px solid #e2e8f0; 
}
.btn-remove-sig { color: var(--danger); cursor: pointer; font-weight: bold; font-size: 0.9rem; }

.btn-add-sig {
    background: #10b981; color: white; border: none; padding: 12px; width: 100%; 
    border-radius: 8px; font-weight: bold; cursor: pointer; margin-bottom: 10px;
    box-shadow: 0 4px 10px rgba(16, 185, 129, 0.2);
}

/* --- MODAL (CROPPER & IMAGE EDIT) --- */
.modal-overlay { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.9); z-index: 2000; display: none; justify-content: center; align-items: center; padding: 10px; }
.modal-content { background: white; width: 100%; max-width: 1000px; height: 90vh; border-radius: 12px; display: flex; flex-direction: column; overflow: hidden; }
.modal-header { padding: 15px; border-bottom: 1px solid #eee; display: flex; justify-content: space-between; font-weight: bold; background: #fff; }
.modal-body { flex: 1; display: flex; overflow: hidden; }
.pane-left { flex: 1; padding: 15px; background: white; border-right: 1px solid #eee; display: flex; flex-direction: column; }
.pane-right { flex: 1; padding: 15px; background: #f8fafc; display: flex; flex-direction: column; }
.canvas-wrapper { flex: 1; background: #eee; border: 1px solid #ddd; display: flex; justify-content: center; align-items: center; overflow: hidden; margin-bottom: 10px; position: relative; }
.bg-checker { background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAABGdBTUEAALGPC/xhBQAAAAlwSFlzAAAOwgAADsIBFShKgAAAABhJREFUOE9jZGBg+M+ABAD5QAY5gG00eAAAAABJRU5ErkJggg=='); }
#cropper-image, #clean-canvas { max-width: 100%; max-height: 100%; display: block; object-fit: contain; }

.editor-toolbar { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; padding: 5px; background: white; border: 1px solid #ddd; border-radius: 8px; }
.tool-btn { padding: 8px; border: 1px solid #ddd; background: white; border-radius: 6px; cursor: pointer; }

/* Responsive Modal */
@media (max-width: 768px) {
    .modal-body { flex-direction: column; overflow-y: auto; }
    .pane-left { min-height: 400px; border-right: none; border-bottom: 1px solid #eee; }
    .pane-right { min-height: 450px; }
}

/* Loading Overlay */
.loading-overlay { position: fixed; top:0; left:0; width:100%; height:100%; background:rgba(255,255,255,0.95); z-index:9999; display:none; justify-content:center; align-items:center; flex-direction:column; }
.spinner { width: 40px; height: 40px; border: 4px solid #e2e8f0; border-top: 4px solid var(--primary); border-radius: 50%; animation: spin 1s linear infinite; margin-bottom: 10px; }
@keyframes spin { to { transform: rotate(360deg); } }