/* ===================================================================
   MAIN APPLICATION STYLES - E-KARTU PELAJAR SD NEGERI 3
   Modern Glassmorphism UI, Responsive, Rich Visual Aesthetics
   =================================================================== */

@import url('https://fonts.googleapis.com/css2?family=JetBrains+Mono:wght@400;600;700&family=Plus+Jakarta+Sans:wght@300;400;500;600;700;800&display=swap');

:root {
    --primary: #2563eb;
    --primary-hover: #1d4ed8;
    --primary-light: #eff6ff;
    --primary-focus: rgba(37, 99, 235, 0.25);
    
    --secondary: #0ea5e9;
    --accent: #f59e0b;
    --success: #10b981;
    --danger: #ef4444;
    --warning: #f59e0b;

    --bg-main: #f8fafc;
    --bg-surface: #ffffff;
    --bg-card: rgba(255, 255, 255, 0.85);
    
    --border-color: #e2e8f0;
    --border-subtle: #f1f5f9;

    --text-primary: #0f172a;
    --text-secondary: #475569;
    --text-muted: #94a3b8;

    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 16px;
    --radius-xl: 24px;

    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -2px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -4px rgba(0, 0, 0, 0.1);
    --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.1);

    --transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

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

body {
    font-family: 'Plus Jakarta Sans', system-ui, -apple-system, sans-serif;
    background-color: var(--bg-main);
    color: var(--text-primary);
    line-height: 1.5;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    overflow-x: hidden;
    background-image: 
        radial-gradient(at 0% 0%, rgba(37, 99, 235, 0.04) 0px, transparent 50%),
        radial-gradient(at 100% 100%, rgba(14, 165, 233, 0.04) 0px, transparent 50%);
}

/* Typography Helpers */
h1, h2, h3, h4, h5, h6 {
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: -0.02em;
}

/* Container */
.app-container {
    width: 100%;
    max-width: 1440px;
    margin: 0 auto;
    padding: 0 1.25rem 2rem 1.25rem;
}

/* ===================================================================
   NAVIGATION BAR
   =================================================================== */

.app-navbar {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border-color);
    position: sticky;
    top: 0;
    z-index: 50;
    box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.04);
}

.navbar-inner {
    max-width: 1440px;
    margin: 0 auto;
    padding: 0.75rem 1.25rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}

.navbar-brand {
    display: flex;
    align-items: center;
    gap: 0.85rem;
    text-decoration: none;
    color: inherit;
}

.navbar-logo {
    width: 44px;
    height: 44px;
    object-fit: contain;
    filter: drop-shadow(0 2px 4px rgba(0,0,0,0.1));
}

.brand-text h1 {
    font-size: 1.125rem;
    font-weight: 800;
    line-height: 1.2;
    background: linear-gradient(135deg, #1e3a8a 0%, #2563eb 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.brand-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 0.72rem;
    color: var(--text-secondary);
    font-weight: 600;
}

.brand-badge .pill {
    background: #dbeafe;
    color: #1d4ed8;
    font-size: 0.65rem;
    font-weight: 700;
    padding: 1px 6px;
    border-radius: 9999px;
}

/* Navbar Actions */
.navbar-actions {
    display: flex;
    align-items: center;
    gap: 0.6rem;
}

/* ===================================================================
   BUTTONS & BADGES
   =================================================================== */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    font-family: inherit;
    font-size: 0.875rem;
    font-weight: 600;
    padding: 0.55rem 1rem;
    border-radius: var(--radius-md);
    border: 1px solid transparent;
    cursor: pointer;
    transition: var(--transition);
    text-decoration: none;
    white-space: nowrap;
    user-select: none;
}

.btn:active {
    transform: scale(0.98);
}

.btn-primary {
    background: linear-gradient(135deg, #2563eb 0%, #1d4ed8 100%);
    color: #ffffff;
    box-shadow: 0 4px 10px rgba(37, 99, 235, 0.25);
}

.btn-primary:hover {
    background: linear-gradient(135deg, #1d4ed8 0%, #1e40af 100%);
    box-shadow: 0 6px 14px rgba(37, 99, 235, 0.35);
}

.btn-highlight {
    background: linear-gradient(135deg, #059669 0%, #047857 100%);
    color: #ffffff;
    box-shadow: 0 4px 10px rgba(5, 150, 105, 0.25);
}

.btn-highlight:hover {
    background: linear-gradient(135deg, #047857 0%, #065f46 100%);
    box-shadow: 0 6px 14px rgba(5, 150, 105, 0.35);
}

.btn-secondary {
    background: #ffffff;
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-sm);
}

.btn-secondary:hover {
    background: #f8fafc;
    border-color: #cbd5e1;
    color: #0f172a;
}

.btn-danger {
    background: #fee2e2;
    color: #dc2626;
    border: 1px solid #fecaca;
}

.btn-danger:hover {
    background: #dc2626;
    color: #ffffff;
}

.btn-icon-only {
    padding: 0.55rem;
    width: 36px;
    height: 36px;
    border-radius: var(--radius-md);
}

.btn-sm {
    padding: 0.35rem 0.65rem;
    font-size: 0.775rem;
    border-radius: var(--radius-sm);
}

.btn-lg {
    padding: 0.75rem 1.4rem;
    font-size: 1rem;
    border-radius: var(--radius-md);
}

/* ===================================================================
   HERO / BANNER & STATS
   =================================================================== */

.app-stats-bar {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
    margin: 1.25rem 0;
}

.stat-card {
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 1rem 1.25rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    box-shadow: var(--shadow-sm);
    transition: var(--transition);
}

.stat-card:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
    border-color: #cbd5e1;
}

.stat-icon {
    width: 44px;
    height: 44px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    flex-shrink: 0;
}

.stat-icon.blue { background: #eff6ff; color: #2563eb; }
.stat-icon.green { background: #f0fdf4; color: #16a34a; }
.stat-icon.amber { background: #fffbeb; color: #d97706; }
.stat-icon.purple { background: #faf5ff; color: #9333ea; }

.stat-info h4 {
    font-size: 0.8rem;
    color: var(--text-secondary);
    font-weight: 500;
}

.stat-info .stat-value {
    font-size: 1.5rem;
    font-weight: 800;
    color: var(--text-primary);
    line-height: 1.1;
}

/* ===================================================================
   MAIN WORKSPACE GRID (INPUT FORM & LIVE PREVIEW)
   =================================================================== */

.main-workspace {
    display: grid;
    grid-template-columns: 1.1fr 1fr;
    gap: 1.5rem;
    margin-bottom: 2rem;
}

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

.card-panel {
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-xl);
    padding: 1.5rem;
    box-shadow: var(--shadow-sm);
    display: flex;
    flex-direction: column;
}

.panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.25rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid var(--border-color);
}

.panel-header-title {
    display: flex;
    align-items: center;
    gap: 0.6rem;
}

.panel-header-title h2 {
    font-size: 1.15rem;
    font-weight: 700;
}

.panel-header-subtitle {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

/* ===================================================================
   FORM STYLES
   =================================================================== */

.form-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1rem;
}

.form-group-full {
    grid-column: span 2;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.form-label {
    font-size: 0.825rem;
    font-weight: 600;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: 4px;
}

.form-label .req {
    color: var(--danger);
}

.form-input, .form-select, .form-textarea {
    width: 100%;
    font-family: inherit;
    font-size: 0.875rem;
    padding: 0.6rem 0.85rem;
    border-radius: var(--radius-md);
    border: 1.5px solid var(--border-color);
    background-color: #ffffff;
    color: var(--text-primary);
    transition: var(--transition);
    outline: none;
}

.form-input:focus, .form-select:focus, .form-textarea:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-focus);
}

.form-input::placeholder, .form-textarea::placeholder {
    color: var(--text-muted);
}

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

/* Photo Dropzone */
.photo-dropzone-container {
    display: flex;
    align-items: center;
    gap: 1rem;
    background: #f8fafc;
    border: 2px dashed #cbd5e1;
    border-radius: var(--radius-lg);
    padding: 0.75rem 1rem;
    transition: var(--transition);
}

.photo-dropzone-container.dragover {
    border-color: var(--primary);
    background: #eff6ff;
}

.photo-thumb-preview {
    width: 60px;
    height: 75px;
    border-radius: var(--radius-md);
    background: #e2e8f0;
    overflow: hidden;
    flex-shrink: 0;
    position: relative;
    border: 1px solid #cbd5e1;
    display: flex;
    align-items: center;
    justify-content: center;
}

.photo-thumb-preview img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.photo-dropzone-info {
    flex: 1;
    min-width: 0;
}

.photo-dropzone-info p {
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-bottom: 0.35rem;
}

.photo-actions {
    display: flex;
    gap: 0.5rem;
}

/* Form Actions */
.form-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 0.75rem;
    margin-top: 1.25rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border-color);
}

/* ===================================================================
   LIVE PREVIEW PANEL STYLES
   =================================================================== */

.preview-panel {
    display: flex;
    flex-direction: column;
}

.preview-controls {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 0.75rem;
    margin-bottom: 1rem;
}

.theme-pill-selector {
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.theme-pill {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    border: 2px solid #ffffff;
    cursor: pointer;
    box-shadow: 0 0 0 1px #cbd5e1;
    transition: var(--transition);
}

.theme-pill:hover, .theme-pill.active {
    transform: scale(1.2);
    box-shadow: 0 0 0 2px var(--primary);
}

.theme-pill.navy { background: #1e3a8a; }
.theme-pill.emerald { background: #065f46; }
.theme-pill.crimson { background: #991b1b; }
.theme-pill.cyan { background: #0e7490; }
.theme-pill.purple { background: #6b21a8; }

.preview-action-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    margin-top: 1rem;
}

.card-size-indicator {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-size: 0.75rem;
    color: var(--text-secondary);
    background: #f1f5f9;
    padding: 3px 8px;
    border-radius: 9999px;
    font-weight: 600;
}

/* ===================================================================
   STUDENT TABLE & MANAGEMENT SECTION
   =================================================================== */

.table-panel {
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-xl);
    padding: 1.5rem;
    box-shadow: var(--shadow-sm);
}

.table-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 1rem;
    margin-bottom: 1.25rem;
}

.toolbar-left {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.toolbar-right {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.search-box-wrap {
    position: relative;
    width: 240px;
}

.search-box-wrap input {
    padding-left: 2.2rem;
}

.search-box-wrap .search-icon {
    position: absolute;
    left: 0.75rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    pointer-events: none;
}

/* Modern Data Table */
.data-table-container {
    overflow-x: auto;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
    font-size: 0.875rem;
}

.data-table thead {
    background: #f8fafc;
    border-bottom: 1px solid var(--border-color);
}

.data-table th {
    padding: 0.75rem 1rem;
    font-weight: 700;
    color: var(--text-secondary);
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    white-space: nowrap;
}

.data-table tbody tr {
    border-bottom: 1px solid var(--border-subtle);
    transition: var(--transition);
}

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

.data-table tbody tr.selected {
    background-color: #eff6ff;
}

.data-table td {
    padding: 0.75rem 1rem;
    vertical-align: middle;
}

.student-table-photo {
    width: 38px;
    height: 48px;
    border-radius: 4px;
    object-fit: cover;
    background: #e2e8f0;
    border: 1px solid #cbd5e1;
    display: block;
}

.badge-kelas {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 700;
    background: #e0e7ff;
    color: #3730a3;
}

.badge-gender {
    display: inline-block;
    padding: 1px 6px;
    border-radius: 4px;
    font-size: 0.7rem;
    font-weight: 700;
}

.badge-gender.L { background: #dbeafe; color: #1e40af; }
.badge-gender.P { background: #fce7f3; color: #9d174d; }

.table-actions {
    display: flex;
    align-items: center;
    gap: 0.35rem;
}

/* Empty State */
.table-empty-state {
    text-align: center;
    padding: 3rem 1rem;
    color: var(--text-secondary);
}

.empty-state-icon {
    font-size: 3rem;
    margin-bottom: 0.5rem;
    opacity: 0.6;
}

/* ===================================================================
   MODALS
   =================================================================== */

.modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.6);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    opacity: 0;
    pointer-events: none;
    transition: var(--transition);
    padding: 1rem;
}

.modal-backdrop.open {
    opacity: 1;
    pointer-events: auto;
}

.modal-box {
    background: #ffffff;
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-xl);
    width: 100%;
    max-width: 820px;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    transform: scale(0.95) translateY(10px);
    transition: var(--transition);
    overflow: hidden;
}

.modal-backdrop.open .modal-box {
    transform: scale(1) translateY(0);
}

.modal-header {
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: #f8fafc;
}

.modal-header h3 {
    font-size: 1.15rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.modal-close-btn {
    background: transparent;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--text-muted);
    padding: 0.2rem 0.5rem;
    border-radius: var(--radius-sm);
    line-height: 1;
}

.modal-close-btn:hover {
    color: var(--danger);
    background: #fee2e2;
}

.modal-body {
    padding: 1.5rem;
    overflow-y: auto;
    flex: 1;
}

.modal-footer {
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--border-color);
    background: #f8fafc;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 0.75rem;
}

/* Print Settings Box in Modal */
.print-options-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1rem;
    margin-bottom: 1.25rem;
    background: #f8fafc;
    padding: 1rem;
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-color);
}

.print-notice {
    background: #eff6ff;
    border-left: 4px solid var(--primary);
    padding: 0.75rem 1rem;
    border-radius: var(--radius-sm);
    font-size: 0.8rem;
    color: #1e3a8a;
    margin-top: 1rem;
    line-height: 1.4;
}

.print-notice strong {
    color: #1e40af;
}

/* Modal Sheet Preview */
.modal-sheet-preview {
    background: #334155;
    padding: 1rem;
    border-radius: var(--radius-md);
    max-height: 380px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
}

.sheet-page-mock {
    background: #ffffff;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
    padding: 10px;
    border-radius: 4px;
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
    width: 100%;
    max-width: 520px;
}

.mini-card-mock {
    border: 1px solid #cbd5e1;
    border-radius: 4px;
    height: 80px;
    background: #f8fafc;
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px;
    font-size: 8px;
    overflow: hidden;
}

.mini-card-mock img {
    width: 24px;
    height: 32px;
    border-radius: 2px;
    object-fit: cover;
    background: #cbd5e1;
}

/* Toast Notifications */
.toast-container {
    position: fixed;
    bottom: 1.5rem;
    right: 1.5rem;
    z-index: 999;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    pointer-events: none;
}

.toast {
    background: #1e293b;
    color: #ffffff;
    padding: 0.75rem 1.25rem;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    font-size: 0.85rem;
    display: flex;
    align-items: center;
    gap: 0.6rem;
    pointer-events: auto;
    animation: toastIn 0.3s ease forwards;
}

.toast.success { background: #065f46; border-left: 4px solid #10b981; }
.toast.error { background: #7f1d1d; border-left: 4px solid #ef4444; }
.toast.info { background: #1e3a8a; border-left: 4px solid #3b82f6; }

@keyframes toastIn {
    from { opacity: 0; transform: translateY(12px) scale(0.95); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

/* Tooltip & Utilities */
.text-truncate {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
