/* ==========================================================================
   Modern Glassmorphism & Dark Premium Theme for Stock Monitor
   ========================================================================== */

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

:root {
    --bg-primary: #0a0e1a;
    --bg-secondary: #121829;
    --bg-card: rgba(22, 30, 53, 0.65);
    --bg-card-hover: rgba(30, 41, 71, 0.8);
    --border-color: rgba(255, 255, 255, 0.08);
    --border-glow: rgba(56, 189, 248, 0.3);
    
    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    --text-accent: #38bdf8;
    
    --accent-blue: #38bdf8;
    --accent-emerald: #10b981;
    --accent-emerald-glow: rgba(16, 185, 129, 0.25);
    --accent-purple: #8b5cf6;
    --accent-rose: #f43f5e;
    
    --shadow-sm: 0 4px 6px -1px rgba(0, 0, 0, 0.3), 0 2px 4px -1px rgba(0, 0, 0, 0.2);
    --shadow-lg: 0 10px 25px -5px rgba(0, 0, 0, 0.5), 0 8px 10px -6px rgba(0, 0, 0, 0.4);
    --shadow-glow: 0 0 30px rgba(56, 189, 248, 0.15);
    
    --radius-md: 12px;
    --radius-lg: 20px;
    --radius-xl: 28px;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Outfit', -apple-system, BlinkMacSystemFont, sans-serif;
    background-color: var(--bg-primary);
    color: var(--text-main);
    min-height: 100vh;
    background-image: 
        radial-gradient(circle at 15% 15%, rgba(56, 189, 248, 0.08) 0%, transparent 40%),
        radial-gradient(circle at 85% 85%, rgba(139, 92, 246, 0.08) 0%, transparent 40%),
        radial-gradient(circle at 50% 50%, rgba(16, 185, 129, 0.05) 0%, transparent 50%);
    background-attachment: fixed;
    line-height: 1.6;
    overflow-x: hidden;
}

/* Background Glow Orbs */
.glow-orb {
    position: fixed;
    border-radius: 50%;
    filter: blur(100px);
    z-index: -1;
    pointer-events: none;
}
.glow-orb-1 {
    top: -100px;
    left: -100px;
    width: 400px;
    height: 400px;
    background: rgba(56, 189, 248, 0.12);
}
.glow-orb-2 {
    bottom: -100px;
    right: -100px;
    width: 500px;
    height: 500px;
    background: rgba(139, 92, 246, 0.1);
}

/* Container */
.app-container {
    max-width: 1240px;
    margin: 0 auto;
    padding: 2rem 1.5rem;
}

/* Header Section */
.app-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 1.5rem;
    margin-bottom: 2.5rem;
    padding-bottom: 1.5rem;
    border-bottom: 1px solid var(--border-color);
}

.header-brand {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.brand-icon {
    width: 48px;
    height: 48px;
    border-radius: var(--radius-md);
    background: linear-gradient(135deg, var(--accent-blue), var(--accent-purple));
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    box-shadow: 0 8px 16px rgba(56, 189, 248, 0.25);
}

.brand-info h1 {
    font-size: 1.75rem;
    font-weight: 700;
    letter-spacing: -0.5px;
    background: linear-gradient(135deg, #fff 0%, var(--text-accent) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.brand-info p {
    font-size: 0.9rem;
    color: var(--text-muted);
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.6rem 1.25rem;
    border-radius: var(--radius-md);
    font-family: inherit;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.25s ease;
    border: none;
    outline: none;
}

.btn-primary {
    background: linear-gradient(135deg, var(--accent-blue), #0284c7);
    color: #fff;
    box-shadow: 0 4px 12px rgba(56, 189, 248, 0.3);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 18px rgba(56, 189, 248, 0.45);
}

.btn-primary:active {
    transform: translateY(0);
}

.btn-outline {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-color);
    color: var(--text-main);
}

.btn-outline:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: var(--accent-blue);
}

.btn-accent {
    background: linear-gradient(135deg, var(--accent-purple), #6d28d9);
    color: #fff;
    box-shadow: 0 4px 12px rgba(139, 92, 246, 0.3);
}

.btn-accent:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 18px rgba(139, 92, 246, 0.45);
}

.btn-accent:active {
    transform: translateY(0);
}

.btn-icon {
    transition: transform 0.4s ease;
}

.btn.refreshing .btn-icon {
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Stats Cards Grid */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2.5rem;
}

.stat-card {
    background: var(--bg-card);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    box-shadow: var(--shadow-sm);
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

.stat-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 4px;
    height: 100%;
    background: var(--accent-blue);
    opacity: 0.8;
}

.stat-card.card-available::before { background: var(--accent-emerald); }
.stat-card.card-id::before { background: var(--accent-blue); }
.stat-card.card-server::before { background: var(--accent-purple); }

.stat-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-lg), var(--shadow-glow);
    border-color: rgba(255, 255, 255, 0.15);
}

.stat-content h3 {
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-muted);
    margin-bottom: 0.5rem;
    font-weight: 600;
}

.stat-value {
    font-size: 2.25rem;
    font-weight: 700;
    letter-spacing: -1px;
    display: flex;
    align-items: baseline;
    gap: 0.5rem;
}

.stat-value.value-available {
    color: var(--accent-emerald);
    text-shadow: 0 0 20px var(--accent-emerald-glow);
}

.stat-unit {
    font-size: 0.9rem;
    color: var(--text-muted);
    font-weight: 500;
}

.stat-icon {
    width: 54px;
    height: 54px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.card-available .stat-icon { color: var(--accent-emerald); background: rgba(16, 185, 129, 0.1); }
.card-id .stat-icon { color: var(--accent-blue); background: rgba(56, 189, 248, 0.1); }
.card-server .stat-icon { color: var(--accent-purple); background: rgba(139, 92, 246, 0.1); }

/* Main Content Panel */
.content-panel {
    background: var(--bg-card);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-lg);
    overflow: hidden;
}

.panel-header {
    padding: 1.5rem 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 1rem;
    border-bottom: 1px solid var(--border-color);
    background: rgba(18, 24, 41, 0.4);
}

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

.panel-title h2 {
    font-size: 1.25rem;
    font-weight: 600;
}

.status-badge {
    padding: 0.25rem 0.75rem;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    background: rgba(16, 185, 129, 0.15);
    color: var(--accent-emerald);
    border: 1px solid rgba(16, 185, 129, 0.3);
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.status-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--accent-emerald);
    box-shadow: 0 0 8px var(--accent-emerald);
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.4; transform: scale(0.85); }
}

.filter-controls {
    display: flex;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
}

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

.search-box input {
    width: 100%;
    padding: 0.55rem 1rem 0.55rem 2.4rem;
    border-radius: var(--radius-md);
    background: rgba(10, 14, 26, 0.6);
    border: 1px solid var(--border-color);
    color: var(--text-main);
    font-family: inherit;
    font-size: 0.85rem;
    outline: none;
    transition: all 0.25s ease;
}

.search-box input:focus {
    border-color: var(--accent-blue);
    box-shadow: 0 0 12px rgba(56, 189, 248, 0.2);
}

.search-box svg {
    position: absolute;
    left: 0.85rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    width: 16px;
    height: 16px;
    pointer-events: none;
}

.product-selector {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.product-selector label {
    font-size: 0.85rem;
    color: var(--text-muted);
    font-weight: 500;
}

.product-selector select {
    padding: 0.55rem 1rem;
    border-radius: var(--radius-md);
    background: rgba(10, 14, 26, 0.8);
    border: 1px solid var(--border-color);
    color: var(--text-main);
    font-family: inherit;
    font-size: 0.85rem;
    font-weight: 600;
    outline: none;
    cursor: pointer;
    transition: border-color 0.25s ease;
}

.product-selector select:focus {
    border-color: var(--accent-blue);
}

/* Table Section */
.table-responsive {
    width: 100%;
    overflow-x: auto;
    min-height: 320px;
}

.stock-table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
}

.stock-table th {
    padding: 1rem 1.5rem;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-muted);
    font-weight: 600;
    border-bottom: 1px solid var(--border-color);
    background: rgba(10, 14, 26, 0.3);
}

.stock-table td {
    padding: 1rem 1.5rem;
    font-size: 0.9rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.04);
    transition: background 0.2s ease;
}

.stock-table tbody tr {
    animation: fadeIn 0.35s ease forwards;
}

.stock-table tbody tr:hover td {
    background: rgba(255, 255, 255, 0.03);
}

.stock-table tbody tr:last-child td {
    border-bottom: none;
}

.font-mono {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.85rem;
}

.pill-id {
    display: inline-block;
    padding: 0.2rem 0.6rem;
    border-radius: 6px;
    background: rgba(56, 189, 248, 0.1);
    color: var(--accent-blue);
    font-weight: 600;
}

.data-content {
    max-width: 420px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    display: inline-block;
    vertical-align: middle;
}

.badge-available {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.25rem 0.65rem;
    border-radius: 6px;
    font-size: 0.75rem;
    font-weight: 600;
    background: rgba(16, 185, 129, 0.12);
    color: var(--accent-emerald);
    border: 1px solid rgba(16, 185, 129, 0.25);
}

.time-text {
    color: var(--text-muted);
    font-size: 0.85rem;
}

/* Empty & Error States */
.state-container {
    padding: 4rem 2rem;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1rem;
}

.state-icon {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.75rem;
    background: rgba(255, 255, 255, 0.04);
    color: var(--text-muted);
    margin-bottom: 0.5rem;
}

.state-container.error .state-icon {
    background: rgba(244, 63, 94, 0.1);
    color: var(--accent-rose);
}

.state-container h3 {
    font-size: 1.2rem;
    font-weight: 600;
}

.state-container p {
    color: var(--text-muted);
    max-width: 480px;
    font-size: 0.9rem;
}

/* Footer */
.app-footer {
    margin-top: 3rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 1rem;
    font-size: 0.85rem;
    color: var(--text-muted);
}

.db-info {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.db-badge {
    padding: 0.2rem 0.5rem;
    border-radius: 4px;
    background: rgba(255, 255, 255, 0.06);
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.75rem;
}

/* Animations */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .panel-header {
        flex-direction: column;
        align-items: flex-start;
    }
    
    .filter-controls {
        width: 100%;
        justify-content: space-between;
    }
    
    .search-box {
        width: 100%;
    }
}

/* ==========================================================================
   Modal Overlay & Form Styles (Ambil Stock)
   ========================================================================== */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(10, 14, 26, 0.8);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
    padding: 1rem;
}

.modal-overlay.active {
    opacity: 1;
    pointer-events: auto;
}

.modal-content {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-xl);
    width: 100%;
    max-width: 520px;
    box-shadow: var(--shadow-lg), 0 0 50px rgba(139, 92, 246, 0.15);
    transform: scale(0.95) translateY(15px);
    transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    overflow: hidden;
}

.modal-overlay.active .modal-content {
    transform: scale(1) translateY(0);
}

.modal-header {
    padding: 1.5rem;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    border-bottom: 1px solid var(--border-color);
    background: rgba(255, 255, 255, 0.02);
}

.modal-title {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.modal-icon {
    width: 44px;
    height: 44px;
    border-radius: var(--radius-md);
    background: rgba(139, 92, 246, 0.15);
    border: 1px solid rgba(139, 92, 246, 0.3);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.35rem;
}

.modal-title h3 {
    font-size: 1.15rem;
    font-weight: 600;
}

.modal-title p {
    font-size: 0.82rem;
    color: var(--text-muted);
}

.modal-close {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 1.75rem;
    cursor: pointer;
    line-height: 1;
    padding: 0.2rem 0.5rem;
    border-radius: 6px;
    transition: all 0.2s ease;
}

.modal-close:hover {
    color: var(--text-main);
    background: rgba(255, 255, 255, 0.05);
}

.modal-body {
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

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

.form-label {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-main);
}

.form-input {
    width: 100%;
    padding: 0.7rem 1rem;
    border-radius: var(--radius-md);
    background: rgba(10, 14, 26, 0.8);
    border: 1px solid var(--border-color);
    color: var(--text-main);
    font-family: inherit;
    font-size: 0.9rem;
    outline: none;
    transition: border-color 0.25s ease, box-shadow 0.25s ease;
}

.form-input:focus {
    border-color: var(--accent-purple);
    box-shadow: 0 0 14px rgba(139, 92, 246, 0.25);
}

.input-with-suffix {
    position: relative;
    display: flex;
    align-items: center;
}

.input-with-suffix input {
    padding-right: 3.5rem;
}

.input-suffix {
    position: absolute;
    right: 1rem;
    font-size: 0.85rem;
    color: var(--text-muted);
    font-weight: 600;
    pointer-events: none;
}

.form-help {
    font-size: 0.78rem;
    color: var(--text-muted);
    line-height: 1.4;
}

/* Custom Checkbox */
.checkbox-group {
    margin-top: 0.25rem;
}

.checkbox-label {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    cursor: pointer;
    user-select: none;
}

.checkbox-label input[type="checkbox"] {
    display: none;
}

.checkbox-custom {
    width: 20px;
    height: 20px;
    border-radius: 6px;
    background: rgba(10, 14, 26, 0.8);
    border: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: all 0.2s ease;
    margin-top: 2px;
}

.checkbox-label input[type="checkbox"]:checked + .checkbox-custom {
    background: var(--accent-purple);
    border-color: var(--accent-purple);
}

.checkbox-label input[type="checkbox"]:checked + .checkbox-custom::after {
    content: '✓';
    color: #fff;
    font-size: 0.8rem;
    font-weight: 800;
}

.checkbox-text {
    display: flex;
    flex-direction: column;
}

.checkbox-text strong {
    font-size: 0.88rem;
    color: var(--text-main);
}

.checkbox-text span {
    font-size: 0.78rem;
    color: var(--text-muted);
}

.modal-footer {
    padding: 1.25rem 1.5rem;
    border-top: 1px solid var(--border-color);
    background: rgba(10, 14, 26, 0.4);
    display: flex;
    justify-content: flex-end;
    gap: 0.75rem;
}

.modal-alert {
    padding: 0.85rem 1rem;
    border-radius: var(--radius-md);
    font-size: 0.85rem;
    line-height: 1.5;
}

.modal-alert.error {
    background: rgba(244, 63, 94, 0.15);
    border: 1px solid rgba(244, 63, 94, 0.3);
    color: #fda4af;
}

.modal-alert.success {
    background: rgba(16, 185, 129, 0.15);
    border: 1px solid rgba(16, 185, 129, 0.3);
    color: #6ee7b7;
}
