/* ============================================
   SISTEM PAKAR - MAIN STYLESHEET
   Modern Glassmorphism Design
   ============================================ */

/* CSS Variables */
:root {
    /* Colors - Dark Theme (Default) */
    --primary: #6366f1;
    --primary-dark: #4f46e5;
    --primary-light: #818cf8;
    --secondary: #8b5cf6;
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    --dark: #1f2937;
    --light: #f3f4f6;

    /* Theme Colors */
    --bg-primary: #0f172a;
    --bg-secondary: rgba(15, 23, 42, 0.8);
    --bg-card: rgba(255, 255, 255, 0.05);
    --text-primary: #ffffff;
    --text-secondary: #94a3b8;
    --text-muted: #cbd5e1;
    --border-color: rgba(255, 255, 255, 0.1);
    --glass-bg: rgba(255, 255, 255, 0.1);
    --glass-border: rgba(255, 255, 255, 0.2);

    /* Gradients */
    --gradient-primary: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    --gradient-secondary: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
    --gradient-success: linear-gradient(135deg, #11998e 0%, #38ef7d 100%);
    --gradient-danger: linear-gradient(135deg, #fa709a 0%, #fee140 100%);
    --gradient-bg: linear-gradient(135deg, #667eea 0%, #764ba2 50%, #f093fb 100%);

    /* 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);
    --shadow-glow: 0 0 30px rgba(99, 102, 241, 0.3);

    /* Glassmorphism */
    --glass-blur: 10px;

    /* Spacing */
    --spacing-sm: 0.5rem;
    --spacing-md: 1rem;
    --spacing-lg: 2rem;
    --spacing-xl: 4rem;

    /* Border Radius */
    --radius-sm: 0.375rem;
    --radius-md: 0.5rem;
    --radius-lg: 1rem;
    --radius-xl: 1.5rem;
    --radius-full: 9999px;

    /* Transitions */
    --transition-fast: 150ms cubic-bezier(0.4, 0, 0.2, 1);
    --transition-base: 300ms cubic-bezier(0.4, 0, 0.2, 1);
    --transition-slow: 500ms cubic-bezier(0.4, 0, 0.2, 1);
}

/* Light Theme */
body.light-theme {
    --bg-primary: #f8fafc;
    --bg-secondary: rgba(255, 255, 255, 0.95);
    --bg-card: rgba(255, 255, 255, 0.9);
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --text-muted: #475569;
    --border-color: rgba(0, 0, 0, 0.1);
    --glass-bg: rgba(255, 255, 255, 0.9);
    --glass-border: rgba(0, 0, 0, 0.1);
    --gradient-bg: linear-gradient(135deg, #667eea55 0%, #764ba255 50%, #f093fb55 100%);
}

/* Light theme specific overrides for visibility */
body.light-theme .btn-secondary {
    background: rgba(99, 102, 241, 0.1);
    color: #1e293b;
    border: 2px solid rgba(99, 102, 241, 0.3);
}

body.light-theme .btn-secondary:hover {
    background: rgba(99, 102, 241, 0.2);
    color: #1e293b;
}

body.light-theme input::placeholder,
body.light-theme select::placeholder {
    color: #64748b !important;
    opacity: 0.8;
}

body.light-theme h1,
body.light-theme h2,
body.light-theme h3,
body.light-theme h4,
body.light-theme p,
body.light-theme label,
body.light-theme span {
    color: inherit;
}

/* ============================================
   RESET & BASE STYLES
   ============================================ */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    font-size: 16px;
    line-height: 1.6;
    color: var(--text-primary);
    background: var(--bg-primary);
    overflow-x: hidden;
    transition: background 0.3s ease, color 0.3s ease;
}

/* Background Gradient */
.bg-gradient {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--gradient-bg);
    opacity: 0.1;
    z-index: -1;
    animation: gradientShift 15s ease infinite;
    transition: background 0.3s ease, opacity 0.3s ease;
}

body.light-theme .bg-gradient {
    opacity: 0.3;
}

@keyframes gradientShift {

    0%,
    100% {
        transform: scale(1) rotate(0deg);
    }

    50% {
        transform: scale(1.1) rotate(5deg);
    }
}

/* ============================================
   LOADER
   ============================================ */

.loader {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(15, 23, 42, 0.95);
    backdrop-filter: blur(10px);
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 9999;
}

.loader-spinner {
    width: 60px;
    height: 60px;
    border: 4px solid rgba(99, 102, 241, 0.2);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

.loader p {
    margin-top: 1rem;
    color: #fff;
    font-weight: 500;
}

/* ============================================
   NAVIGATION & THEME TOGGLE
   ============================================ */

.nav {
    display: flex;
    gap: 2rem;
    align-items: center;
}

.nav-link {
    color: var(--text-muted);
    text-decoration: none;
    font-weight: 500;
    transition: var(--transition-base);
    position: relative;
}

.nav-link:hover {
    color: var(--primary-light);
}

.nav-link.active {
    color: var(--primary);
}

.nav-link.active::after {
    content: '';
    position: absolute;
    bottom: -0.5rem;
    left: 0;
    width: 100%;
    height: 2px;
    background: var(--gradient-primary);
    border-radius: var(--radius-full);
}

/* Theme Toggle Button */
.theme-toggle {
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    backdrop-filter: blur(10px);
    border-radius: var(--radius-full);
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all var(--transition-base);
    margin-left: 1rem;
}

.theme-toggle:hover {
    background: var(--primary);
    transform: scale(1.1);
}

.theme-icon {
    font-size: 1.25rem;
    transition: transform var(--transition-slow);
}

.theme-toggle:hover .theme-icon {
    transform: rotate(360deg);
}

/* Fullscreen Container for Desktop */
.container {
    width: 100%;
    max-width: none;
    margin: 0 auto;
    padding: 0 2rem;
}

@media (min-width: 768px) {
    .container {
        padding: 0 3rem;
    }
}

@media (min-width: 1024px) {
    .container {
        padding: 0 4rem;
    }
}

/* ============================================
   HEADER
   ============================================ */

.header {
    position: sticky;
    top: 0;
    background: var(--bg-secondary);
    backdrop-filter: blur(20px);
    border-bottom: 1px solid var(--border-color);
    padding: 1rem 0;
    z-index: 1000;
    transition: all 0.3s ease;
}

.header-content {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.logo-section {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.logo-icon {
    font-size: 2.5rem;
    filter: drop-shadow(0 0 10px rgba(99, 102, 241, 0.5));
}

.logo-text h1 {
    font-size: 1.5rem;
    font-weight: 800;
    background: var(--gradient-primary);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.logo-text p {
    font-size: 0.875rem;
    color: var(--text-secondary);
    transition: color 0.3s ease;
}

/* ============================================
   HERO SECTION
   ============================================ */

.hero-section {
    padding: 6rem 0;
    min-height: calc(100vh - 80px);
    display: flex;
    align-items: center;
}

.hero-content {
    display: grid;
    grid-template-columns: 1.2fr 0.8fr;
    gap: 4rem;
    align-items: center;
}

.hero-title {
    font-size: 3.5rem;
    font-weight: 800;
    line-height: 1.2;
    color: var(--text-primary);
    margin-bottom: 1.5rem;
    animation: fadeInUp 0.8s ease;
}

.hero-description {
    font-size: 1.125rem;
    color: var(--text-muted);
    margin-bottom: 2rem;
    line-height: 1.8;
    animation: fadeInUp 1s ease;
}

.hero-buttons {
    display: flex;
    gap: 1rem;
    animation: fadeInUp 1.2s ease;
}

.hero-stats {
    display: grid;
    grid-template-columns: repeat(1, 1fr);
    gap: 1.5rem;
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ============================================
   STAT CARDS
   ============================================ */

.stat-card {
    background: var(--bg-card);
    backdrop-filter: blur(10px);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-xl);
    padding: 2rem;
    text-align: center;
    transition: var(--transition-base);
    animation: scaleIn 0.6s ease;
    animation-fill-mode: backwards;
}

.stat-card:nth-child(1) {
    animation-delay: 0.2s;
}

.stat-card:nth-child(2) {
    animation-delay: 0.4s;
}

.stat-card:nth-child(3) {
    animation-delay: 0.6s;
}

@keyframes scaleIn {
    from {
        opacity: 0;
        transform: scale(0.9);
    }

    to {
        opacity: 1;
        transform: scale(1);
    }
}

.stat-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 20px 40px rgba(99, 102, 241, 0.2);
}

.stat-icon {
    font-size: 3rem;
    margin-bottom: 1rem;
    filter: drop-shadow(0 0 10px rgba(99, 102, 241, 0.5));
}

.stat-value {
    font-size: 2.5rem;
    font-weight: 800;
    color: var(--text-primary);
    margin-bottom: 0.5rem;
}

.stat-label {
    font-size: 0.875rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.stat-card.stat-danger .stat-value {
    background: var(--gradient-danger);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

/* ============================================
   BUTTONS
   ============================================ */

.btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 1rem 2rem;
    border: none;
    border-radius: var(--radius-lg);
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition-base);
    text-decoration: none;
}

.btn-primary {
    background: var(--gradient-primary);
    color: #fff;
    box-shadow: var(--shadow-lg);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-xl), var(--shadow-glow);
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
    border: 1px solid rgba(255, 255, 255, 0.2);
    backdrop-filter: blur(10px);
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.15);
    transform: translateY(-2px);
}

.btn-success {
    background: var(--gradient-success);
    color: #fff;
    box-shadow: var(--shadow-lg);
}

.btn-success:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-xl), var(--shadow-glow);
}

.btn-danger {
    background: var(--gradient-danger);
    color: #fff;
    box-shadow: var(--shadow-lg);
}

.btn-danger:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-xl), var(--shadow-glow);
}

/* ============================================
   SECTIONS
   ============================================ */

section {
    padding: 5rem 0;
}

.section-header {
    text-align: center;
    margin-bottom: 4rem;
}

.section-title {
    font-size: 2.5rem;
    font-weight: 800;
    color: var(--text-primary);
    margin-bottom: 1rem;
}

.section-subtitle {
    font-size: 1.125rem;
    color: var(--text-secondary);
}

/* ============================================
   FOOTER
   ============================================ */

.footer {
    background: var(--bg-secondary);
    border-top: 1px solid var(--border-color);
    padding: 2rem 0;
    text-align: center;
    color: var(--text-secondary);
}

.footer a {
    transition: all 0.3s ease;
}

.footer a:hover {
    color: var(--primary-light) !important;
    text-decoration: underline !important;
    transform: translateY(-1px);
}

/* ============================================
   MODAL
   ============================================ */

.modal {
    display: none;
    position: fixed;
    z-index: 10000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(5px);
    overflow-y: auto;
}

/* ============================================
   LOGIN MODAL SPECIFIC
   ============================================ */

.login-content {
    background: rgba(15, 23, 42, 0.6) !important;
    backdrop-filter: blur(25px) !important;
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5), inset 0 0 0 1px rgba(255, 255, 255, 0.05);
    padding: 3rem !important;
    max-width: 450px !important;
    border-radius: 24px !important;
}

.login-header h2 {
    font-size: 2rem;
    font-weight: 800;
    margin-bottom: 0.5rem;
    background: linear-gradient(to right, #fff, #94a3b8);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.login-header p {
    color: var(--text-secondary);
    font-size: 0.95rem;
}

.input-group {
    position: relative;
    margin-bottom: 1.5rem;
}

.input-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-muted);
}

.input-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

.input-icon {
    position: absolute;
    left: 1rem;
    color: var(--text-secondary);
    font-size: 1.2rem;
    pointer-events: none;
    transition: color 0.3s ease;
}

.login-input {
    width: 100%;
    padding: 0.875rem 1rem 0.875rem 3rem !important;
    background: rgba(0, 0, 0, 0.2) !important;
    border: 1px solid rgba(255, 255, 255, 0.1) !important;
    border-radius: 12px !important;
    color: #fff !important;
    font-size: 1rem;
    transition: all 0.3s ease;
}

.login-input:focus {
    background: rgba(0, 0, 0, 0.4) !important;
    border-color: var(--primary) !important;
    box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.1);
    outline: none;
}

.login-input:focus+.input-icon,
.input-wrapper:focus-within .input-icon {
    color: var(--primary);
}

.btn-login {
    width: 100%;
    padding: 1rem;
    background: linear-gradient(135deg, #6366f1 0%, #a855f7 100%);
    border: none;
    border-radius: 12px;
    color: white;
    font-weight: 600;
    font-size: 1.1rem;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    margin-top: 1rem;
}

.btn-login:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 20px -5px rgba(99, 102, 241, 0.4);
}

.btn-login:active {
    transform: translateY(0);
}

.modal-content {
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(20px);
    margin: 2rem auto;
    padding: 2rem;
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: var(--radius-xl);
    width: 90%;
    max-width: 600px;
    position: relative;
    animation: modalSlideIn 0.3s ease;
}

@keyframes modalSlideIn {
    from {
        opacity: 0;
        transform: translateY(-50px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.modal-close {
    color: #fff;
    float: right;
    font-size: 2rem;
    font-weight: bold;
    cursor: pointer;
    transition: var(--transition-base);
}

.modal-close:hover {
    color: var(--danger);
}

.modal-locked .modal-close {
    display: none;
}

/* Auth Info in Header */
.auth-info {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-right: 1rem;
}

.user-greeting {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.user-greeting strong {
    color: var(--primary-light);
}

.btn-logout {
    padding: 0.4rem 0.8rem;
    background: rgba(239, 68, 68, 0.1);
    color: var(--danger);
    border: 1px solid rgba(239, 68, 68, 0.2);
    border-radius: var(--radius-md);
    cursor: pointer;
    font-size: 0.85rem;
    transition: all 0.2s;
}

.btn-logout:hover {
    background: var(--danger);
    color: #fff;
}

/* ============================================
   TOAST NOTIFICATIONS
   ============================================ */

.toast {
    position: fixed;
    bottom: -100px;
    right: 2rem;
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: #fff;
    padding: 1rem 1.5rem;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-xl);
    transition: var(--transition-base);
    z-index: 10001;
}

.toast.show {
    bottom: 2rem;
}

.toast-success {
    border-left: 4px solid var(--success);
}

.toast-error {
    border-left: 4px solid var(--danger);
}

.toast-warning {
    border-left: 4px solid var(--warning);
}

.toast-info {
    border-left: 4px solid var(--primary);
}

/* ============================================
   MOBILE BOTTOM NAVIGATION
   ============================================ */

.bottom-nav {
    display: none;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--bg-secondary);
    backdrop-filter: blur(20px);
    border-top: 1px solid var(--border-color);
    padding: 0.5rem;
    z-index: 1000;
    box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.1);
}

.bottom-nav-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 0.5rem;
    text-decoration: none;
    color: var(--text-secondary);
    transition: all var(--transition-base);
    border-radius: var(--radius-md);
    position: relative;
}

.bottom-nav-icon {
    font-size: 1.5rem;
    margin-bottom: 0.25rem;
    transition: transform var(--transition-base);
}

.bottom-nav-label {
    font-size: 0.7rem;
    font-weight: 600;
    transition: color var(--transition-base);
}

.bottom-nav-item.active {
    color: var(--primary);
}

.bottom-nav-item.active .bottom-nav-icon {
    transform: scale(1.2);
}

.bottom-nav-item.active::before {
    content: '';
    position: absolute;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 30px;
    height: 3px;
    background: var(--gradient-primary);
    border-radius: 0 0 var(--radius-full) var(--radius-full);
}

.bottom-nav-item:active {
    transform: scale(0.95);
}

/* Show bottom nav only on mobile */
@media (max-width: 768px) {
    .bottom-nav {
        display: flex;
    }

    /* Add padding to body to prevent content being hidden behind bottom nav */
    body {
        padding-bottom: 70px;
    }

    /* Hide desktop header navigation on mobile */
    .header .nav {
        display: none;
    }
}

/* ============================================
   UTILITIES
   ============================================ */

.text-center {
    text-align: center;
}

.required {
    color: var(--danger);
}

/* ============================================
   RESPONSIVE DESIGN
   ============================================ */

@media (max-width: 1024px) {
    .hero-content {
        grid-template-columns: 1fr;
        gap: 3rem;
    }

    .hero-title {
        font-size: 2.5rem;
    }
}

@media (max-width: 768px) {
    .container {
        padding: 0 1rem;
    }

    .header-content {
        flex-direction: column;
        gap: 1rem;
    }

    .nav {
        gap: 1rem;
    }

    .hero-title {
        font-size: 2rem;
    }

    .hero-buttons {
        flex-direction: column;
    }

    .section-title {
        font-size: 2rem;
    }
}

/* ============================================
   ADDITIONAL IMPROVEMENTS FOR DARK THEME
   ============================================ */

/* Improve search and filter input readability in dark theme */
input[type="text"],
textarea,
select {
    color: #ffffff;
    background: rgba(15, 23, 42, 0.5);
}

body.light-theme input[type="text"],
body.light-theme textarea,
body.light-theme select {
    color: #1e293b;
    background: #ffffff;
}

/* Improve small text readability */
small {
    color: #94a3b8;
}

body.light-theme small {
    color: #64748b;
}

/* Improve paragraph text in dark theme */
p {
    color: var(--text-muted);
}

body.light-theme p {
    color: #475569;
}

@media (max-width: 768px) {
    .controls-toolbar {
        flex-direction: column;
        align-items: stretch !important;
    }

    .controls-toolbar>div {
        flex-direction: column;
        width: 100%;
    }
}

/* Controls Styles */
#searchInput::placeholder {
    color: rgba(255, 255, 255, 0.5);
}

#searchInput:focus,
#filterInput:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.2);
}

#filterInput option {
    background-color: #1f2937;
    color: #fff;
}

/* ============================================
   AUTO-FILLED FIELDS (from NPSN lookup)
   ============================================ */

/* Auto-filled fields - Dark Theme */
input.auto-filled,
select.auto-filled {
    background-color: rgba(16, 185, 129, 0.15) !important;
    color: #ffffff !important;
    border-color: rgba(16, 185, 129, 0.5) !important;
    font-weight: 600;
}

/* Auto-filled fields - Light Theme */
body.light-theme input.auto-filled,
body.light-theme select.auto-filled {
    background-color: #e8f5e9 !important;
    color: #1e293b !important;
    border-color: #10b981 !important;
    font-weight: 600;
}

/* Readonly inputs styling */
input[readonly] {
    cursor: not-allowed;
}

/* Select with pointer-events: none */
select[style*="pointer-events: none"] {
    cursor: not-allowed;
    opacity: 0.9;
}