/* ==========================================================================
   THEND PANEL CORE STYLES - PREMIUM SAAS DESIGN SYSTEM
   ========================================================================== */

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

:root {
    /* ------------------- Color Palette (Premium Minimalist Dark) ------------------- */
    --primary: #6366f1; /* Indigo 500 */
    --primary-hover: #4f46e5; /* Indigo 600 */
    --primary-glow: rgba(99, 102, 241, 0.25);
    --primary-gradient: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);

    --secondary: #8b5cf6; /* Violet 500 */

    /* Refined Status Colors */
    --success: #10b981; 
    --danger: #ef4444;  
    --warning: #f59e0b; 
    --info: #3b82f6;    

    /* Base Backgrounds - Deep, Rich, Minimal */
    --bg-base: #030305; /* Deeper black for ultimate contrast and depth */
    --bg-card: rgba(255, 255, 255, 0.02); /* Extremely subtle white wash */
    --bg-input: rgba(0, 0, 0, 0.3);
    
    /* Typography Colors */
    --text-main: #f8fafc; /* Slate 50 */
    --text-muted: #a1a1aa; /* Zinc 400 */
    --text-label: #d4d4d8; /* Zinc 300 */

    /* Glassmorphism Tokens */
    --glass-border: rgba(255, 255, 255, 0.06);
    --glass-border-light: rgba(255, 255, 255, 0.15);
    --glass-blur: blur(24px);
    --glass-shadow: 0 10px 40px -10px rgba(0, 0, 0, 0.7);
    --glass-shadow-hover: 0 20px 40px -10px rgba(99, 102, 241, 0.15);
    --glass-inner-glow: inset 0 1px 0 rgba(255, 255, 255, 0.07);

    /* Dimensions & Spacing */
    --sidebar-width: 280px;
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 20px;
    --radius-full: 9999px;
    
    /* Transitions */
    --transition-smooth: all 0.4s cubic-bezier(0.16, 1, 0.3, 1);
    --transition-bounce: all 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
}

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

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    background-color: var(--bg-base);
    /* Soft ambient glows simulating depth */
    background-image: 
        radial-gradient(circle at 15% 0%, rgba(99, 102, 241, 0.08) 0%, transparent 50%),
        radial-gradient(circle at 85% 100%, rgba(139, 92, 246, 0.08) 0%, transparent 50%);
    background-attachment: fixed;
    color: var(--text-main);
    min-height: 100vh;
    line-height: 1.6;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    /* Removed 0.8s fade animation - was causing perceived delay */

h1, h2, h3, h4, h5, h6 {
    font-weight: 600;
    color: #ffffff;
    letter-spacing: -0.02em;
}

h2.page-title {
    font-size: 1.8rem;
    margin-bottom: 1.5rem;
    background: linear-gradient(135deg, #ffffff 0%, #a1a1aa 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    display: inline-block;
}

/* ------------------- Layout Grid ------------------- */
.app-container {
    display: flex;
    min-height: 100vh;
}

/* Sidebar Styling */
.sidebar {
    width: var(--sidebar-width);
    background: rgba(5, 5, 7, 0.7); /* Deeper back for sidebar */
    backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur);
    border-right: 1px solid var(--glass-border);
    padding: 2rem 1.5rem;
    position: fixed;
    height: 100vh;
    z-index: 100;
    display: flex;
    flex-direction: column;
    left: 0;
    top: 0;
    box-shadow: 10px 0 30px -10px rgba(0,0,0,0.5); /* Sidebar depth shadow */
}

.sidebar-header {
    padding-bottom: 2rem;
    margin-bottom: 1rem;
    font-size: 1.25rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    color: #fff;
}

.sidebar-nav {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    flex: 1;
}

.sidebar-link {
    display: flex;
    align-items: center;
    gap: 0.85rem;
    padding: 0.85rem 1rem;
    color: var(--text-muted);
    text-decoration: none;
    border-radius: var(--radius-md);
    transition: var(--transition-bounce);
    font-weight: 500;
    font-size: 0.95rem;
    border: 1px solid transparent;
    position: relative;
    overflow: hidden;
}

.sidebar-link::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background: radial-gradient(400px circle at var(--mouse-x, 0) var(--mouse-y, 0), rgba(255, 255, 255, 0.05), transparent 40%);
    opacity: 0;
    transition: opacity 0.3s;
    pointer-events: none;
}

.sidebar-link:hover {
    background: rgba(255, 255, 255, 0.03);
    color: var(--text-main);
    transform: translateX(4px);
}

.sidebar-link:hover::before {
    opacity: 1;
}

.sidebar-link.active {
    background: rgba(255, 255, 255, 0.06);
    color: #fff;
    border: 1px solid var(--glass-border-light);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.1), 0 4px 12px rgba(0,0,0,0.2);
    transform: translateX(6px);
}

.sidebar-link .icon {
    width: 20px;
    display: flex;
    justify-content: center;
    font-size: 1rem;
    opacity: 0.9;
    transition: var(--transition-bounce);
}

.sidebar-link:hover .icon {
    transform: scale(1.15);
    color: var(--primary);
}

.sidebar-footer {
    margin-top: auto;
    padding-top: 1.5rem;
}

.user-info {
    padding: 1rem;
    margin-bottom: 0.75rem;
    background: rgba(255, 255, 255, 0.02);
    border-radius: var(--radius-md);
    border: 1px solid var(--glass-border);
    box-shadow: var(--glass-inner-glow);
}

.user-name {
    font-weight: 600;
    font-size: 0.9rem;
    color: #fff;
    margin-bottom: 0.2rem;
}

.user-role {
    font-size: 0.75rem;
    font-weight: 500;
    letter-spacing: 0.02em;
}

.logout-link {
    display: flex;
    align-items: center;
    gap: 0.85rem;
    padding: 0.75rem 1rem;
    color: var(--danger);
    text-decoration: none;
    border-radius: var(--radius-md);
    transition: var(--transition-smooth);
    font-weight: 500;
    font-size: 0.95rem;
    opacity: 0.8;
}

.logout-link:hover {
    background: rgba(239, 68, 68, 0.1);
    opacity: 1;
}

.main-content {
    flex: 1;
    margin-left: var(--sidebar-width);
    padding: 2rem 3rem; /* Slightly reduced padding to maximize space */
    max-width: 100%; /* Allow full width to fit tables */
    width: calc(100% - var(--sidebar-width));
    /* Removed 0.6s fade-up animation - was causing perceived delay */
    opacity: 1;
}

/* Dashboard Cards (Stats) */
.dash-card {
    background: var(--bg-card);
    backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur);
    border: 1px solid var(--glass-border);
    padding: 1.75rem;
    border-radius: var(--radius-lg);
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    min-height: 140px;
    position: relative;
    overflow: hidden;
    transition: var(--transition-bounce);
    box-shadow: var(--glass-shadow), var(--glass-inner-glow);
}

/* Dynamic lighting effect container */
.dash-card::after, .glass-panel::after {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background: radial-gradient(600px circle at var(--mouse-x, 0) var(--mouse-y, 0), rgba(255, 255, 255, 0.04), transparent 40%);
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none;
    z-index: -1;
}

.dash-card:hover::after, .glass-panel:hover::after {
    opacity: 1;
}

.dash-card:hover {
    transform: translateY(-6px) scale(1.02);
    border-color: var(--glass-border-light);
    background: rgba(255, 255, 255, 0.04);
    box-shadow: var(--glass-shadow-hover), var(--glass-inner-glow);
    z-index: 10;
}

.dash-card-title {
    color: var(--text-muted);
    font-size: 0.8rem;
    text-transform: uppercase;
    font-weight: 600;
    letter-spacing: 0.05em;
    margin-bottom: 0.75rem;
}

.dash-card-value {
    color: #fff;
    font-size: 2.25rem;
    font-weight: 700;
    line-height: 1.2;
    letter-spacing: -0.03em;
}

/* Responsive Grid Helpers */
.grid-2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 1.5rem; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1.5rem; }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1.5rem; }

@media (max-width: 1024px) {
    .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
    .sidebar { transform: translateX(-100%); transition: transform 0.3s ease; }
    .main-content { margin-left: 0; width: 100%; padding: 2rem; }
}

/* ------------------- Key Component: Glass Panel ------------------- */
.glass-panel {
    background: var(--bg-card);
    backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-lg);
    padding: 2.5rem;
    box-shadow: var(--glass-shadow), var(--glass-inner-glow);
    margin-bottom: 2rem;
    position: relative;
    overflow: hidden;
    transition: var(--transition-smooth);
}

.glass-panel:hover {
    box-shadow: var(--glass-shadow-hover), var(--glass-inner-glow);
    border-color: rgba(255,255,255,0.1);
}

/* Soft highlight on top edge */
.glass-panel::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0; height: 1px;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.15), transparent);
}

/* ------------------- Forms & Inputs ------------------- */
.form-group {
    margin-bottom: 1.5rem;
    position: relative;
}

.form-label {
    display: block;
    font-size: 0.8rem;
    color: var(--text-label);
    margin-bottom: 0.5rem;
    font-weight: 500;
    letter-spacing: 0.02em;
}

.form-input,
.form-select {
    width: 100%;
    padding: 0.85rem 1.2rem;
    background: var(--bg-input);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-md);
    color: #fff;
    font-family: inherit;
    font-size: 0.95rem;
    transition: var(--transition-smooth);
    box-shadow: inset 0 2px 4px rgba(0,0,0,0.1);
}

.form-input::placeholder {
    color: rgba(255,255,255,0.2);
}

.form-input:focus,
.form-select:focus {
    outline: none;
    border-color: rgba(99, 102, 241, 0.5);
    background: rgba(0, 0, 0, 0.3);
    box-shadow: 0 0 0 3px var(--primary-glow), inset 0 2px 4px rgba(0,0,0,0.1);
}

select.form-select option {
    background: var(--bg-base);
    color: #fff;
}

/* ------------------- Buttons ------------------- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.75rem 1.5rem;
    border-radius: var(--radius-md);
    font-weight: 500;
    font-size: 0.95rem;
    cursor: pointer;
    transition: var(--transition-smooth);
    border: 1px solid transparent;
    gap: 0.5rem;
    text-decoration: none;
    letter-spacing: 0.01em;
}

.btn-primary {
    background: var(--primary-gradient);
    color: #fff;
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.2);
    border: 1px solid rgba(255,255,255,0.1);
    box-shadow: inset 0 1px 0 rgba(255,255,255,0.2), 0 4px 15px rgba(99, 102, 241, 0.3);
    position: relative;
    overflow: hidden;
}

.btn-primary::after {
    content: '';
    position: absolute;
    top: -50%; left: -50%; width: 200%; height: 200%;
    background: radial-gradient(circle at center, rgba(255,255,255,0.3) 0%, transparent 60%);
    opacity: 0;
    transition: opacity 0.3s;
    pointer-events: none;
    transform: translate(var(--mouse-x, -50%), var(--mouse-y, -50%));
}

.btn-primary:hover {
    transform: translateY(-2px) scale(1.02);
    box-shadow: inset 0 1px 0 rgba(255,255,255,0.3), 0 8px 25px rgba(99, 102, 241, 0.4);
    background: linear-gradient(135deg, #7174f2 0%, #986ef7 100%);
}

.btn-primary:hover::after {
    opacity: 1;
}

.btn-danger {
    background: rgba(239, 68, 68, 0.1);
    color: var(--danger);
    border: 1px solid rgba(239, 68, 68, 0.2);
}

.btn-danger:hover {
    background: rgba(239, 68, 68, 0.2);
    transform: translateY(-2px) scale(1.02);
    box-shadow: 0 8px 20px rgba(239, 68, 68, 0.15);
}

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

.btn-ghost:hover {
    background: rgba(255, 255, 255, 0.08);
    border-color: var(--glass-border-light);
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.2);
}

/* ------------------- Modern Tables ------------------- */
.table-container {
    width: 100%;
    overflow-x: auto;
    border-radius: var(--radius-md);
    background: transparent;
}

.modern-table {
    width: 100%;
    border-collapse: collapse;
    white-space: nowrap;
    font-size: 0.9rem;
}

/* Allow long text like PC serials to wrap if they are too long */
.modern-table td {
    padding: 1.25rem 1rem;
    color: var(--text-main);
    border-bottom: 1px solid rgba(255, 255, 255, 0.03);
    transition: var(--transition-smooth);
    position: relative;
    max-width: 250px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Make sure the serial column can be fully seen on hover, or wraps cleanly */
.modern-table td:hover {
    white-space: normal;
    word-break: break-all;
    overflow: visible;
}

.modern-table th {
    color: var(--text-muted);
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-size: 0.75rem;
    text-align: left;
    padding: 1.25rem 1rem;
    border-bottom: 1px solid var(--glass-border);
}

.modern-table td {
    padding: 1.25rem 1rem;
    color: var(--text-main);
    border-bottom: 1px solid rgba(255, 255, 255, 0.03);
    transition: var(--transition-smooth);
    position: relative;
}

.modern-table tr {
    transition: var(--transition-bounce);
    transform-origin: left center;
}

.modern-table tr:hover {
    background: rgba(255, 255, 255, 0.03);
    transform: scale(1.005) translateX(2px);
    box-shadow: inset 2px 0 0 var(--primary);
}

.modern-table tr:hover td {
    color: #fff;
}

/* Actions cell reveal */
.modern-table td:last-child {
    opacity: 0.6;
    transition: opacity 0.3s;
}

.modern-table tr:hover td:last-child {
    opacity: 1;
}

/* Remove bottom border on last row */
.modern-table tr:last-child td {
    border-bottom: none;
}

/* ------------------- Status Badges ------------------- */
.badge {
    padding: 0.35rem 0.8rem;
    border-radius: var(--radius-full);
    font-size: 0.7rem;
    font-weight: 600;
    letter-spacing: 0.03em;
    text-transform: uppercase;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

/* Refined Badge Colors - Soft and legible */
.badge-success { background: rgba(16, 185, 129, 0.1); color: #34d399; border: 1px solid rgba(16, 185, 129, 0.2); }
.badge-warning { background: rgba(245, 158, 11, 0.1); color: #fbbf24; border: 1px solid rgba(245, 158, 11, 0.2); }
.badge-danger  { background: rgba(239, 68, 68, 0.1); color: #f87171; border: 1px solid rgba(239, 68, 68, 0.2); }
.badge-info    { background: rgba(59, 130, 246, 0.1); color: #60a5fa; border: 1px solid rgba(59, 130, 246, 0.2); }

/* Overriding inline badge styles used in ColorBolt.php */
span.badge[style*="var(--info)"] { background: rgba(59, 130, 246, 0.1) !important; color: #60a5fa !important; border: 1px solid rgba(59, 130, 246, 0.2) !important; }
span.badge[style*="var(--success)"] { background: rgba(16, 185, 129, 0.1) !important; color: #34d399 !important; border: 1px solid rgba(16, 185, 129, 0.2) !important; }
span.badge[style*="var(--warning)"] { background: rgba(245, 158, 11, 0.1) !important; color: #fbbf24 !important; border: 1px solid rgba(245, 158, 11, 0.2) !important; }
span.badge[style*="var(--danger)"] { background: rgba(239, 68, 68, 0.1) !important; color: #f87171 !important; border: 1px solid rgba(239, 68, 68, 0.2) !important; }

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

.fade-in {
    animation: fadeIn 0.5s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

/* ------------------- Permission Notifications ------------------- */
.permission-notification {
    position: fixed;
    top: 24px;
    right: 24px;
    min-width: 320px;
    max-width: 450px;
    padding: 1.25rem 1.5rem;
    border-radius: var(--radius-md);
    background: rgba(9, 9, 11, 0.85);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--glass-border-light);
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.4), inset 0 1px 0 rgba(255,255,255,0.1);
    z-index: 10000;
    opacity: 0;
    transform: translateX(20px);
    transition: all 0.4s cubic-bezier(0.16, 1, 0.3, 1);
    display: flex;
    align-items: center;
    gap: 1rem;
}

.permission-notification.show {
    opacity: 1;
    transform: translateX(0);
}

.permission-notification-info { border-left: 3px solid var(--info); }
.permission-notification-error { border-left: 3px solid var(--danger); }
.permission-notification-info i { color: #60a5fa; }
.permission-notification-error i { color: #f87171; }

/* ------------------- Toast Notifications ------------------- */
.toast-container {
    position: fixed;
    top: 24px;
    right: 24px;
    z-index: 99999;
    display: flex;
    flex-direction: column;
    gap: 10px;
    pointer-events: none;
}

.toast {
    pointer-events: auto;
    min-width: 320px;
    max-width: 450px;
    padding: 1rem 1.25rem;
    border-radius: var(--radius-md);
    background: rgba(9, 9, 11, 0.9);
    backdrop-filter: blur(20px);
    border: 1px solid var(--glass-border-light);
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.5), inset 0 1px 0 rgba(255,255,255,0.1);
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-size: 0.9rem;
    color: #fff;
    transform: translateX(120%);
    animation: toastIn 0.35s cubic-bezier(0.16, 1, 0.3, 1) forwards;
    border-left: 3px solid var(--info);
}

.toast.removing {
    animation: toastOut 0.25s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.toast-success { border-left-color: var(--success); }
.toast-error { border-left-color: var(--danger); }
.toast-warning { border-left-color: var(--warning); }
.toast-info { border-left-color: var(--info); }

.toast i { font-size: 1.1rem; flex-shrink: 0; }
.toast-success i { color: var(--success); }
.toast-error i { color: var(--danger); }
.toast-warning i { color: var(--warning); }
.toast-info i { color: var(--info); }

.toast-close {
    margin-left: auto;
    background: none;
    border: none;
    color: rgba(255,255,255,0.3);
    cursor: pointer;
    font-size: 1rem;
    padding: 2px;
    line-height: 1;
}
.toast-close:hover { color: #fff; }

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

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

/* ------------------- Scrollbar ------------------- */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}
::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.02);
}
::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.2);
}
