/* ========================================
   Custom Stylesheet (di atas Tailwind CSS)
   ======================================== */

/* ========================================
   1. GOOGLE FONTS & ROOT VARIABLES
   ======================================== */
@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;500;600;700;800;900&display=swap');

:root {
    /* Primary Corporate Blue Palette */
    --primary-50: #E6F0F9;
    --primary-100: #CCE1F3;
    --primary-200: #99C3E7;
    --primary-300: #66A5DB;
    --primary-400: #3387CF;
    --primary-500: #1E6FB8;  /* Main primary */
    --primary-600: #0A4D8C;  /* Darker primary */
    --primary-700: #083D70;
    --primary-800: #062D54;
    --primary-900: #041E38;

    /* Accent Colors */
    --accent-gold: #D4AF37;
    --accent-green: #10B981;
    --accent-red: #EF4444;
    --accent-yellow: #F59E0B;
    --accent-orange: #F97316;

    /* Neutral Colors */
    --gray-50: #F9FAFB;
    --gray-100: #F3F4F6;
    --gray-200: #E5E7EB;
    --gray-300: #D1D5DB;
    --gray-400: #9CA3AF;
    --gray-500: #6B7280;
    --gray-600: #4B5563;
    --gray-700: #374151;
    --gray-800: #1F2937;
    --gray-900: #111827;

    /* Shadows */
    --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 -1px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);

    /* Transitions */
    --transition-fast: 150ms ease;
    --transition-normal: 300ms ease;
    --transition-slow: 500ms ease;
}

/* ========================================
   2. BASE STYLES
   ======================================== */
* {
    font-family: 'Outfit', sans-serif;
}

body {
    font-family: 'Outfit', sans-serif;
    color: var(--gray-800);
    background-color: var(--gray-50);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* Custom Scrollbar */
::-webkit-scrollbar {
    width: 10px;
    height: 10px;
}

::-webkit-scrollbar-track {
    background: var(--gray-100);
}

::-webkit-scrollbar-thumb {
    background: var(--primary-300);
    border-radius: 5px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--primary-500);
}

/* Selection */
::selection {
    background-color: var(--primary-100);
    color: var(--primary-800);
}

/* ========================================
   3. TYPOGRAPHY
   ======================================== */
h1, h2, h3, h4, h5, h6 {
    font-weight: 700;
    color: var(--gray-900);
    line-height: 1.3;
}

.text-gradient {
    background: linear-gradient(135deg, var(--primary-500) 0%, var(--primary-700) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

/* ========================================
   4. BUTTONS
   ======================================== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.625rem 1.25rem;
    font-weight: 500;
    border-radius: 0.5rem;
    transition: all var(--transition-normal);
    cursor: pointer;
    border: none;
    font-size: 0.9375rem;
    white-space: nowrap;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary-500) 0%, var(--primary-600) 100%);
    color: white;
    box-shadow: 0 4px 6px -1px rgba(10, 77, 140, 0.2);
}

.btn-primary:hover {
    background: linear-gradient(135deg, var(--primary-600) 0%, var(--primary-700) 100%);
    transform: translateY(-2px);
    box-shadow: 0 10px 15px -3px rgba(10, 77, 140, 0.3);
}

.btn-secondary {
    background: white;
    color: var(--primary-600);
    border: 2px solid var(--primary-200);
}

.btn-secondary:hover {
    background: var(--primary-50);
    border-color: var(--primary-500);
}

.btn-danger {
    background: var(--accent-red);
    color: white;
}

.btn-danger:hover {
    background: #DC2626;
    transform: translateY(-2px);
}

.btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none !important;
}

/* ========================================
   5. CARDS
   ======================================== */
.card {
    background: white;
    border-radius: 0.75rem;
    box-shadow: var(--shadow-md);
    transition: all var(--transition-normal);
    overflow: hidden;
}

.card-hover:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-xl);
}

.card-header {
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--gray-100);
    background: linear-gradient(135deg, var(--primary-50) 0%, white 100%);
}

.card-body {
    padding: 1.5rem;
}

.card-footer {
    padding: 1.25rem 1.5rem;
    border-top: 1px solid var(--gray-100);
    background: var(--gray-50);
}

/* ========================================
   6. FORMS
   ======================================== */
.form-group {
    margin-bottom: 1.25rem;
}

.form-label {
    display: block;
    font-weight: 500;
    color: var(--gray-700);
    margin-bottom: 0.5rem;
    font-size: 0.875rem;
}

.form-label .required {
    color: var(--accent-red);
    margin-left: 0.25rem;
}

.form-control {
    width: 100%;
    padding: 0.625rem 0.875rem;
    border: 1.5px solid var(--gray-300);
    border-radius: 0.5rem;
    font-size: 0.9375rem;
    transition: all var(--transition-fast);
    background: white;
}

.form-control:focus {
    outline: none;
    border-color: var(--primary-500);
    box-shadow: 0 0 0 3px rgba(30, 111, 184, 0.1);
}

.form-control.is-invalid {
    border-color: var(--accent-red);
}

.form-control.is-invalid:focus {
    box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.1);
}

.invalid-feedback {
    color: var(--accent-red);
    font-size: 0.8125rem;
    margin-top: 0.375rem;
    display: none;
}

.form-control.is-invalid ~ .invalid-feedback {
    display: block;
}

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

/* File Upload */
.file-upload {
    border: 2px dashed var(--gray-300);
    border-radius: 0.5rem;
    padding: 2rem;
    text-align: center;
    cursor: pointer;
    transition: all var(--transition-normal);
    background: var(--gray-50);
}

.file-upload:hover {
    border-color: var(--primary-500);
    background: var(--primary-50);
}

.file-upload.dragover {
    border-color: var(--primary-500);
    background: var(--primary-50);
}

/* Checkbox & Radio Custom */
.custom-checkbox,
.custom-radio {
    display: inline-flex;
    align-items: center;
    cursor: pointer;
    user-select: none;
}

.custom-checkbox input,
.custom-radio input {
    margin-right: 0.5rem;
    accent-color: var(--primary-500);
}

/* ========================================
   7. BADGES & STATUS
   ======================================== */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 0.25rem 0.75rem;
    font-size: 0.75rem;
    font-weight: 500;
    border-radius: 9999px;
    white-space: nowrap;
}

.badge-primary {
    background: var(--primary-100);
    color: var(--primary-700);
}

.badge-success {
    background: #D1FAE5;
    color: #065F46;
}

.badge-warning {
    background: #FEF3C7;
    color: #92400E;
}

.badge-danger {
    background: #FEE2E2;
    color: #991B1B;
}

.badge-info {
    background: #DBEAFE;
    color: #1E40AF;
}

.badge-gray {
    background: var(--gray-100);
    color: var(--gray-700);
}

/* Status Dot */
.status-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    margin-right: 0.5rem;
}

.status-dot.success { background: var(--accent-green); }
.status-dot.warning { background: var(--accent-yellow); }
.status-dot.danger { background: var(--accent-red); }
.status-dot.info { background: var(--primary-500); }

/* ========================================
   8. TABLES
   ======================================== */
.table-container {
    background: white;
    border-radius: 0.75rem;
    overflow: hidden;
    box-shadow: var(--shadow-md);
}

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

.data-table thead {
    background: linear-gradient(135deg, var(--primary-50) 0%, var(--gray-50) 100%);
}

.data-table th {
    padding: 1rem;
    text-align: left;
    font-weight: 600;
    color: var(--gray-700);
    font-size: 0.8125rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    border-bottom: 2px solid var(--gray-200);
}

.data-table td {
    padding: 1rem;
    border-bottom: 1px solid var(--gray-100);
    color: var(--gray-700);
    font-size: 0.875rem;
}

.data-table tbody tr {
    transition: background var(--transition-fast);
}

.data-table tbody tr:hover {
    background: var(--primary-50);
}

/* ========================================
   9. NAVIGATION & LAYOUT (DIPERBAIKI v2)
   ======================================== */

/* Public Header */
.public-header {
    background: white;
    box-shadow: var(--shadow-sm);
    position: sticky;
    top: 0;
    z-index: 50;
}

.nav-link {
    color: var(--gray-700);
    font-weight: 500;
    padding: 0.5rem 1rem;
    border-radius: 0.5rem;
    transition: all var(--transition-fast);
}

.nav-link:hover,
.nav-link.active {
    color: var(--primary-600);
    background: var(--primary-50);
}

/* Admin Sidebar */
.admin-sidebar {
    width: 260px;
    background: linear-gradient(180deg, var(--primary-800) 0%, var(--primary-900) 100%);
    color: white;
    min-height: 100vh;
    position: fixed;
    left: 0;
    top: 0;
    z-index: 40;
    overflow: hidden;
    /* ✅ FIX: Transition untuk width (desktop) DAN transform (mobile) */
    transition: 
        width 0.3s cubic-bezier(0.4, 0, 0.2, 1),
        transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Collapsed State (Desktop) */
.admin-sidebar.collapsed {
    width: 80px;
}

/* Hide text saat collapsed - menggunakan CSS murni */
.admin-sidebar.collapsed .sidebar-text {
    opacity: 0;
    display: none;
    /* visibility: hidden; */
    width: 0;
    overflow: hidden;
    transition: opacity 0.2s ease, visibility 0.2s ease;
}

.admin-sidebar .sidebar-text {
    opacity: 1;
    visibility: visible;
    transition: opacity 0.2s ease 0.1s, visibility 0.2s ease 0.1s;
}

/* Menu Items */
.sidebar-menu-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1.25rem;
    color: rgba(255, 255, 255, 0.8);
    text-decoration: none;
    transition: all var(--transition-fast);
    border-left: 3px solid transparent;
    font-weight: 500;
    white-space: nowrap;
    /* ✅ FIX: Icon tidak boleh shrink */
    flex-shrink: 0;
}

.sidebar-menu-item:hover {
    background: rgba(255, 255, 255, 0.1);
    color: white;
    border-left-color: var(--accent-gold);
}

.sidebar-menu-item.active {
    background: rgba(255, 255, 255, 0.15);
    color: white;
    border-left-color: var(--accent-gold);
}

/* ✅ FIX: Saat collapsed, menu item di-center-kan */
.admin-sidebar.collapsed .sidebar-menu-item {
    padding: 0.75rem 0;
    justify-content: center;
    border-left-width: 0;
}

/* Badge di menu (tidak boleh di-hide saat collapsed) */
.sidebar-menu-item .sidebar-text.ml-auto {
    opacity: 1 !important;
    visibility: visible !important;
    width: auto !important;
}

.admin-sidebar.collapsed .sidebar-menu-item .sidebar-text.ml-auto {
    opacity: 0 !important;
    visibility: hidden !important;
    width: 0 !important;
}

/* Sidebar Header (Logo Area) */
.sidebar-header {
    padding: 1.5rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 88px;
    transition: padding 0.3s ease;
}

.admin-sidebar.collapsed .sidebar-header {
    padding: 1.5rem 0;
}

/* Sidebar Footer (User Profile) */
.sidebar-footer {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 1rem;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    transition: padding 0.3s ease;
}

.admin-sidebar.collapsed .sidebar-footer {
    padding: 1rem 0.5rem;
    justify-content: center;
}

/* Admin Main Content */
.admin-main {
    margin-left: 260px;
    transition: margin-left 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    min-height: 100vh;
    background: var(--gray-50);
}

.admin-main.expanded {
    margin-left: 80px;
}

/* Mobile Overlay */
.sidebar-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    z-index: 35;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.sidebar-overlay.active {
    opacity: 1;
    visibility: visible;
}

/* ========================================
   10. HERO SECTION
   ======================================== */
.hero-section {
    background: linear-gradient(135deg, var(--primary-700) 0%, var(--primary-500) 100%);
    color: white;
    position: relative;
    overflow: hidden;
}

.hero-section::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-image: 
        radial-gradient(circle at 20% 50%, rgba(255, 255, 255, 0.1) 0%, transparent 50%),
        radial-gradient(circle at 80% 80%, rgba(255, 255, 255, 0.1) 0%, transparent 50%);
    pointer-events: none;
}

/* ========================================
   11. TOAST NOTIFICATIONS
   ======================================== */
.toast-container {
    position: fixed;
    top: 1.5rem;
    right: 1.5rem;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    max-width: 400px;
}

.toast {
    background: white;
    border-radius: 0.5rem;
    box-shadow: var(--shadow-lg);
    padding: 1rem 1.25rem;
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    min-width: 300px;
    animation: slideInRight 0.3s ease;
    border-left: 4px solid var(--primary-500);
}

.toast.success { border-left-color: var(--accent-green); }
.toast.error { border-left-color: var(--accent-red); }
.toast.warning { border-left-color: var(--accent-yellow); }
.toast.info { border-left-color: var(--primary-500); }

.toast-icon {
    flex-shrink: 0;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: bold;
}

.toast.success .toast-icon { background: var(--accent-green); }
.toast.error .toast-icon { background: var(--accent-red); }
.toast.warning .toast-icon { background: var(--accent-yellow); }
.toast.info .toast-icon { background: var(--primary-500); }

.toast-content {
    flex: 1;
}

.toast-title {
    font-weight: 600;
    color: var(--gray-900);
    margin-bottom: 0.25rem;
}

.toast-message {
    font-size: 0.875rem;
    color: var(--gray-600);
}

.toast-close {
    background: none;
    border: none;
    color: var(--gray-400);
    cursor: pointer;
    padding: 0;
    font-size: 1.25rem;
    line-height: 1;
}

.toast-close:hover {
    color: var(--gray-700);
}

@keyframes slideInRight {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

/* ========================================
   12. MODAL
   ======================================== */
/* Overlay Backdrop */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    z-index: 9998;
    display: flex;
    align-items: center;
    justify-content: center;
    
    /* State Tersembunyi (Fade Out) */
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

/* State Aktif (Fade In) */
.modal-overlay.active {
    opacity: 1;
    visibility: visible;
}

/* Modal Content Box */
.modal {
    background: white;
    border-radius: 0.75rem;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1);
    max-width: 500px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
    
    /* State Tersembunyi (Scale Down + Fade Out) */
    transform: scale(0.95) translateY(10px);
    opacity: 0;
    transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.3s ease;
}

/* State Aktif (Scale Up + Fade In) */
.modal-overlay.active .modal {
    transform: scale(1) translateY(0);
    opacity: 1;
}

/* Ukuran Modal Variatif */
.modal.modal-sm { max-width: 400px; }
.modal.modal-lg { max-width: 700px; }

/* Struktur Internal Modal (Tetap Sama) */
.modal-header {
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid #F3F4F6;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.modal-title {
    font-size: 1.25rem;
    font-weight: 600;
    color: #111827;
}

.modal-close {
    background: none;
    border: none;
    color: #9CA3AF;
    cursor: pointer;
    padding: 0.25rem;
    transition: color 0.2s;
}

.modal-close:hover { color: #374151; }

.modal-body { padding: 1.5rem; }

.modal-footer {
    padding: 1.25rem 1.5rem;
    border-top: 1px solid #F3F4F6;
    display: flex;
    gap: 0.75rem;
    justify-content: flex-end;
}

/* ========================================
   13. LOADING STATES
   ======================================== */
.loading-spinner {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    border-top-color: white;
    animation: spin 0.8s linear infinite;
}

.loading-spinner.dark {
    border-color: rgba(0, 0, 0, 0.1);
    border-top-color: var(--primary-500);
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.8);
    backdrop-filter: blur(4px);
    z-index: 9999;
    display: none;
    align-items: center;
    justify-content: center;
}

.loading-overlay.active {
    display: flex;
}

/* ========================================
   14. UTILITIES
   ======================================== */
.text-primary { color: var(--primary-600); }
.bg-primary { background: var(--primary-500); }
.border-primary { border-color: var(--primary-500); }

.tracking-code {
    font-family: 'Courier New', monospace;
    font-size: 1.5rem;
    font-weight: 700;
    letter-spacing: 0.1em;
    color: var(--primary-700);
    background: var(--primary-50);
    padding: 0.75rem 1.5rem;
    border-radius: 0.5rem;
    display: inline-block;
    border: 2px dashed var(--primary-300);
}

/* Fade In Animation */
.fade-in {
    animation: fadeInUp 0.6s ease;
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ========================================
   15. RESPONSIVE (DIPERBAIKI v2)
   ======================================== */
@media (max-width: 768px) {
    .admin-sidebar {
        /* ✅ FIX: Default tersembunyi di mobile */
        transform: translateX(-100%);
        width: 260px !important;
    }
    
    .admin-sidebar.mobile-open {
        transform: translateX(0);
    }
    
    /* Reset text visibility di mobile */
    .admin-sidebar.collapsed .sidebar-text,
    .admin-sidebar .sidebar-text {
        opacity: 1 !important;
        visibility: visible !important;
        width: auto !important;
    }
    
    /* Reset menu item padding di mobile */
    .admin-sidebar.collapsed .sidebar-menu-item {
        padding: 0.75rem 1.25rem;
        justify-content: flex-start;
        border-left-width: 3px;
    }
    
    .admin-sidebar.collapsed .sidebar-header {
        padding: 1.5rem;
        justify-content: flex-start;
    }
    
    .admin-sidebar.collapsed .sidebar-footer {
        padding: 1rem;
        justify-content: flex-start;
    }
    
    .admin-main {
        margin-left: 0 !important;
    }
    
    .toast-container {
        left: 1rem;
        right: 1rem;
        max-width: none;
    }
    
    .toast {
        min-width: auto;
    }
}

.modal-icon {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 1.5rem;
}

.modal-icon.success {
    background: #D1FAE5;
    color: #059669;
}

.modal-icon.error {
    background: #FEE2E2;
    color: #DC2626;
}

.modal-icon.warning {
    background: #FEF3C7;
    color: #D97706;
}

.modal-icon.info {
    background: #DBEAFE;
    color: #2563EB;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes scaleIn {
    from {
        transform: scale(0.9);
        opacity: 0;
    }
    to {
        transform: scale(1);
        opacity: 1;
    }
}