/* ----------------------------------------------------------------
   1. GLOBAL STYLES & MEDICAL LIGHT BLUE SYSTEM
---------------------------------------------------------------- */
:root {
    --bg-light: #f0f6fc;
    --card-bg: rgba(255, 255, 255, 0.85);
    --card-border: rgba(2, 132, 199, 0.12);
    --text-main: #1e293b;       /* Dark slate */
    --text-muted: #64748b;      /* Muted gray */
    
    --primary: #0284c7;         /* Sky Blue */
    --primary-hover: #0369a1;
    --secondary: #0ea5e9;       /* Light Sky Blue */
    --success: #10b981;         /* Green */
    
    /* Risk Levels (Vibrant colors optimized for Light Mode) */
    --color-expired: #ef4444;     /* Red */
    --color-urgent: #f97316;      /* Orange */
    --color-near: #b45309;        /* Warm Yellow/Amber */
    --color-watch: #0284c7;       /* Blue */
    --color-normal: #10b981;      /* Green */
    --color-low-stock: #8b5cf6;   /* Purple */
    
    --transition-smooth: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    --shadow-soft: 0 4px 20px rgba(2, 132, 199, 0.06);
    --shadow-medium: 0 10px 30px rgba(2, 132, 199, 0.12);
    --glow-shadow: 0 0 15px rgba(2, 132, 199, 0.25);
}

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

body {
    background-color: var(--bg-light);
    color: var(--text-main);
    font-family: 'Outfit', 'Sarabun', sans-serif;
    min-height: 100vh;
    overflow-x: hidden;
    position: relative;
}

/* Medical Ambient Glows */
.bg-glow {
    position: fixed;
    width: 600px;
    height: 600px;
    border-radius: 50%;
    filter: blur(140px);
    opacity: 0.35;
    pointer-events: none;
    z-index: -1;
}
.bg-glow-1 {
    top: -15%;
    left: -10%;
    background: radial-gradient(circle, #e0f2fe 0%, transparent 70%);
}
.bg-glow-2 {
    bottom: -15%;
    right: -10%;
    background: radial-gradient(circle, #bae6fd 0%, transparent 70%);
}

/* Custom Scrollbar */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}
::-webkit-scrollbar-track {
    background: rgba(2, 132, 199, 0.05);
}
::-webkit-scrollbar-thumb {
    background: rgba(2, 132, 199, 0.25);
    border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
    background: rgba(2, 132, 199, 0.5);
}

/* ----------------------------------------------------------------
   2. LAYOUT & CONTAINER
---------------------------------------------------------------- */
.dashboard-container {
    max-width: 1440px;
    margin: 0 auto;
    padding: 1.5rem 2rem;
}

/* Header */
.app-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-bottom: 1.5rem;
    border-bottom: 1.5px solid rgba(2, 132, 199, 0.1);
    margin-bottom: 1.5rem;
}
.header-logo {
    display: flex;
    align-items: center;
    gap: 1rem;
}
.logo-icon {
    font-size: 2.3rem;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    filter: drop-shadow(0 2px 5px rgba(2, 132, 199, 0.2));
}
.logo-text h1 {
    font-size: 1.65rem;
    font-weight: 700;
    letter-spacing: -0.5px;
    color: var(--primary);
}
.logo-text p {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-top: 0.1rem;
}

/* Navigation Tabs */
.tab-navigation {
    display: flex;
    gap: 0.5rem;
    border-bottom: 2px solid rgba(2, 132, 199, 0.1);
    margin-bottom: 1.5rem;
    padding-bottom: 1px;
}
.tab-btn {
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-family: inherit;
    font-size: 0.95rem;
    font-weight: 600;
    padding: 0.75rem 1.5rem;
    cursor: pointer;
    border-radius: 8px 8px 0 0;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    position: relative;
    transition: var(--transition-smooth);
}
.tab-btn:hover {
    color: var(--primary);
    background: rgba(2, 132, 199, 0.05);
}
.tab-btn.active {
    color: var(--primary);
    background: #ffffff;
    box-shadow: 0 -2px 10px rgba(2, 132, 199, 0.05);
}
.tab-btn.active::after {
    content: '';
    position: absolute;
    bottom: -3px;
    left: 0;
    right: 0;
    height: 3px;
    background: var(--primary);
    border-radius: 3px 3px 0 0;
}

/* Tab Views management */
.tab-view {
    display: none;
}
.tab-view.active {
    display: block;
    animation: fadeIn 0.4s ease-out forwards;
}

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

/* ----------------------------------------------------------------
   3. METRICS / STATS CARDS
---------------------------------------------------------------- */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 1rem;
    margin-bottom: 1.5rem;
}
.stat-card {
    background: #ffffff;
    border: 1px solid var(--card-border);
    border-radius: 14px;
    padding: 1rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    box-shadow: var(--shadow-soft);
    transition: var(--transition-smooth);
}
.stat-card:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-medium);
    border-color: rgba(2, 132, 199, 0.25);
}
.stat-icon {
    width: 42px;
    height: 42px;
    border-radius: 10px;
    background: rgba(2, 132, 199, 0.05);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    color: var(--primary);
}
.stat-details h3 {
    font-size: 1.45rem;
    font-weight: 700;
    color: var(--text-main);
    line-height: 1.2;
}
.stat-details p {
    font-size: 0.75rem;
    color: var(--text-muted);
}

/* Border styles for stats cards */
.border-expired { border-left: 4px solid var(--color-expired); }
.border-urgent { border-left: 4px solid var(--color-urgent); }
.border-near { border-left: 4px solid var(--color-near); }
.border-watch { border-left: 4px solid var(--color-watch); }
.border-low-stock { border-left: 4px solid var(--color-low-stock); }

.color-expired { color: var(--color-expired); }
.color-urgent { color: var(--color-urgent); }
.color-near { color: var(--color-near); }
.color-watch { color: var(--color-watch); }
.color-low-stock { color: var(--color-low-stock); }

.icon-expired { color: var(--color-expired); background: rgba(239, 68, 68, 0.08); }
.icon-urgent { color: var(--color-urgent); background: rgba(249, 115, 22, 0.08); }
.icon-near { color: var(--color-near); background: rgba(180, 83, 9, 0.08); }
.icon-watch { color: var(--color-watch); background: rgba(2, 132, 199, 0.08); }
.icon-low-stock { color: var(--color-low-stock); background: rgba(139, 92, 246, 0.08); }

/* ----------------------------------------------------------------
   4. GLASS CARD & DYNAMIC GRID
---------------------------------------------------------------- */
.main-content {
    display: grid;
    grid-template-columns: 35% 65%;
    gap: 1.5rem;
    align-items: start;
}
.glass-card {
    background: var(--card-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--card-border);
    border-radius: 16px;
    padding: 1.75rem;
    box-shadow: var(--shadow-soft);
    position: relative;
}

.card-header {
    margin-bottom: 1.25rem;
}
.card-header h2 {
    font-size: 1.2rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--primary);
}
.card-header p {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-top: 0.2rem;
}

/* ----------------------------------------------------------------
   5. INTERACTIVE FORMS
---------------------------------------------------------------- */
.app-form {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}
.form-row {
    display: flex;
    gap: 0.75rem;
}
.col-6 {
    flex: 1;
}
.form-group {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}
.form-group label {
    font-size: 0.8rem;
    font-weight: 600;
    color: #475569;
}
.form-group label i {
    color: var(--primary);
}
.form-group input, .form-group select {
    background: #ffffff;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    padding: 0.6rem 0.75rem;
    color: var(--text-main);
    font-family: inherit;
    font-size: 0.85rem;
    transition: var(--transition-smooth);
}
.form-group input:focus, .form-group select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 8px rgba(2, 132, 199, 0.15);
}

/* ----------------------------------------------------------------
   6. PREMIUM BUTTONS
---------------------------------------------------------------- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    font-family: inherit;
    font-size: 0.9rem;
    font-weight: 600;
    padding: 0.65rem 1.25rem;
    border-radius: 8px;
    border: none;
    cursor: pointer;
    transition: var(--transition-smooth);
}
.btn-block {
    width: 100%;
}
.btn-primary {
    background: linear-gradient(135deg, var(--primary) 0%, #0284c7 100%);
    color: #ffffff;
}
.btn-primary:hover {
    background: var(--primary-hover);
    transform: translateY(-1px);
    box-shadow: var(--glow-shadow);
}
.btn-secondary {
    background: linear-gradient(135deg, #0ea5e9 0%, #0284c7 100%);
    color: #ffffff;
}
.btn-secondary:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(2, 132, 199, 0.2);
}
.btn-danger {
    background: rgba(239, 68, 68, 0.08);
    color: var(--color-expired);
    border: 1px solid rgba(239, 68, 68, 0.15);
    padding: 0.4rem 0.75rem;
    font-size: 0.8rem;
}
.btn-danger:hover {
    background: var(--color-expired);
    color: #ffffff;
}

.btn.loading i {
    animation: fa-spin 1s infinite linear;
}
.btn.loading {
    pointer-events: none;
    opacity: 0.8;
}

/* ----------------------------------------------------------------
   7. INVENTORY TABLE & FILTERS
---------------------------------------------------------------- */
.table-card {
    padding: 1.5rem;
}
.toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1.25rem;
    flex-wrap: wrap;
}
.search-box {
    position: relative;
    flex: 1;
    min-width: 250px;
}
.search-icon {
    position: absolute;
    left: 0.85rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
}
.search-box input {
    width: 100%;
    background: #ffffff;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    padding: 0.55rem 0.85rem 0.55rem 2.25rem;
    color: var(--text-main);
    font-size: 0.85rem;
    transition: var(--transition-smooth);
}
.search-box input:focus {
    outline: none;
    border-color: var(--primary);
}

.filter-controls {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}
.filter-controls select {
    background: #ffffff;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    padding: 0.55rem 0.85rem;
    color: var(--text-main);
    font-size: 0.85rem;
    outline: none;
    cursor: pointer;
    transition: var(--transition-smooth);
}
.filter-controls select:focus {
    border-color: var(--primary);
}

/* Valuation pill badge */
.total-valuation-badge {
    background: #e0f2fe;
    color: #0369a1;
    border: 1px solid rgba(2, 132, 199, 0.15);
    border-radius: 20px;
    padding: 0.45rem 1rem;
    font-size: 0.85rem;
    font-weight: 500;
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
}

/* Table Design */
.table-responsive {
    overflow-x: auto;
    border-radius: 10px;
    border: 1px solid #e2e8f0;
    background: #ffffff;
}
.inventory-table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
    font-size: 0.85rem;
}
.inventory-table th {
    background: #f8fafc;
    color: #334155;
    font-weight: 700;
    padding: 0.85rem 1rem;
    border-bottom: 2px solid #e2e8f0;
}
.inventory-table td {
    padding: 0.85rem 1rem;
    border-bottom: 1px solid #f1f5f9;
    color: #334155;
    vertical-align: middle;
}
.inventory-table tbody tr {
    transition: var(--transition-smooth);
}
.inventory-table tbody tr:hover {
    background: rgba(2, 132, 199, 0.02);
}

/* Custom badges */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    padding: 0.2rem 0.6rem;
    border-radius: 12px;
    font-size: 0.72rem;
    font-weight: 700;
}
.badge-expired { background: rgba(239, 68, 68, 0.08); color: var(--color-expired); border: 1px solid rgba(239, 68, 68, 0.15); }
.badge-urgent { background: rgba(249, 115, 22, 0.08); color: var(--color-urgent); border: 1px solid rgba(249, 115, 22, 0.15); }
.badge-near { background: rgba(180, 83, 9, 0.08); color: var(--color-near); border: 1px solid rgba(180, 83, 9, 0.15); }
.badge-watch { background: rgba(2, 132, 199, 0.08); color: var(--color-watch); border: 1px solid rgba(2, 132, 199, 0.15); }
.badge-normal { background: rgba(16, 185, 129, 0.08); color: var(--color-normal); border: 1px solid rgba(16, 185, 129, 0.15); }
.badge-low-stock { background: rgba(139, 92, 246, 0.08); color: var(--color-low-stock); border: 1px solid rgba(139, 92, 246, 0.15); }

/* Progress indicator or remaining days design */
.days-left-val {
    font-weight: 700;
}
.text-danger { color: var(--color-expired); }
.text-warning { color: var(--color-urgent); }
.text-caution { color: var(--color-near); }
.text-info { color: var(--color-watch); }
.text-success { color: var(--color-normal); }

.low-stock-highlight {
    color: var(--color-low-stock);
    font-weight: 700;
    background: rgba(139, 92, 246, 0.08);
    border-radius: 4px;
    padding: 0.1rem 0.3rem;
    font-size: 0.8rem;
    display: inline-block;
}

.td-status-msg {
    text-align: center;
    padding: 2.5rem !important;
    color: var(--text-muted);
}
.spinner-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.75rem;
}
.spinner-icon {
    font-size: 1.75rem;
    color: var(--primary);
}

/* ----------------------------------------------------------------
   8. TOAST NOTIFICATION SYSTEM
---------------------------------------------------------------- */
.toast-container {
    position: fixed;
    top: 1.5rem;
    right: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 0.65rem;
    z-index: 9999;
}
.toast {
    background: #ffffff;
    border-left: 4px solid var(--primary);
    border-top: 1px solid #e2e8f0;
    border-bottom: 1px solid #e2e8f0;
    border-right: 1px solid #e2e8f0;
    padding: 0.85rem 1.25rem;
    border-radius: 8px;
    box-shadow: 0 10px 25px rgba(2, 132, 199, 0.08);
    display: flex;
    align-items: center;
    gap: 0.65rem;
    min-width: 280px;
    max-width: 420px;
    transform: translateX(120%);
    animation: toastSlideIn 0.3s forwards cubic-bezier(0.175, 0.885, 0.32, 1.275);
}
.toast.toast-success { border-left-color: var(--success); }
.toast.toast-error { border-left-color: var(--color-expired); }
.toast.toast-info { border-left-color: var(--color-watch); }

.toast-icon {
    font-size: 1.1rem;
}
.toast-success .toast-icon { color: var(--success); }
.toast-error .toast-icon { color: var(--color-expired); }
.toast-info .toast-icon { color: var(--color-watch); }

.toast-message {
    font-size: 0.8rem;
    color: var(--text-main);
    flex: 1;
}

@keyframes toastSlideIn {
    to { transform: translateX(0); }
}

/* ----------------------------------------------------------------
   9. RESPONSIVE DESIGN
---------------------------------------------------------------- */
@media (max-width: 1200px) {
    .stats-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media (max-width: 992px) {
    .main-content {
        grid-template-columns: 100%;
    }
}

@media (max-width: 768px) {
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    .app-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 1rem;
    }
    .header-actions {
        width: 100%;
    }
    .btn-glow {
        width: 100%;
    }
}

@media (max-width: 480px) {
    .stats-grid {
        grid-template-columns: 100%;
    }
    .form-row {
        flex-direction: column;
        gap: 1rem;
    }
}
