

:root {
    /* Dynamic Theme Variables - Will be overridden by JS */
    --primary: #007AFF; /* Apple System Blue */
    --primary-hover: #0062cc; 
    
    /* Dynamic Background Config */
    --bg-overlay-opacity: 0.4;
    --bg-image: none;

    /* VisionOS Color Palette */
    --glass-bg: rgba(30, 30, 30, 0.65);
    --glass-bg-hover: rgba(50, 50, 50, 0.65);
    --glass-border: rgba(255, 255, 255, 0.15);
    --glass-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
    --glass-blur: 50px;

    /* Text */
    --text-main: #FFFFFF;
    --text-secondary: rgba(255, 255, 255, 0.7);
    --text-muted: rgba(255, 255, 255, 0.45);
    
    /* Status Colors */
    --success: #30D158;
    --danger: #FF453A;
    --warning: #FFD60A;
    
    /* Dimensions */
    --radius-lg: 28px;
    --radius-md: 16px;
    --radius-sm: 10px;
    
    --font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    -webkit-font-smoothing: antialiased;
    -webkit-tap-highlight-color: transparent;
}

/* --- Custom Scrollbar (VisionOS Style) --- */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}
::-webkit-scrollbar-track {
    background: transparent;
}
::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.15);
    border-radius: 10px;
    /* Border transparent creates a padding effect */
    border: 2px solid transparent;
    background-clip: content-box;
}
::-webkit-scrollbar-thumb:hover {
    background-color: rgba(255, 255, 255, 0.3);
    border: 1px solid transparent;
}
::-webkit-scrollbar-corner {
    background: transparent;
}

body {
    font-family: var(--font-family);
    background-color: #000000;
    background-image: var(--bg-image);
    background-size: cover;
    background-position: center;
    background-attachment: fixed;
    color: var(--text-main);
    min-height: 100vh;
    position: relative;
    overflow-x: hidden;
    font-size: 15px;
    line-height: 1.5;
}

body:not([style*="--bg-image"]) {
    background-image: radial-gradient(circle at 50% 0%, #1c1c2e 0%, #000000 100%);
}

body::before {
    content: '';
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0, 0, 0, var(--bg-overlay-opacity));
    z-index: -1;
    pointer-events: none;
}

/* --- VisionOS Glass Cards --- */
.bot-card, .modal-content, .login-card {
    background: var(--glass-bg);
    backdrop-filter: blur(var(--glass-blur)) saturate(180%);
    -webkit-backdrop-filter: blur(var(--glass-blur)) saturate(180%);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-lg);
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.4);
    transition: transform 0.3s cubic-bezier(0.25, 0.8, 0.25, 1), background 0.3s;
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.05), 0 20px 40px rgba(0,0,0,0.4);
}

/* --- Buttons --- */
.btn {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-main);
    border: none;
    padding: 0.6rem 1.2rem;
    border-radius: 999px;
    cursor: pointer;
    font-weight: 500;
    font-size: 0.95rem;
    transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    backdrop-filter: blur(10px);
    box-shadow: inset 0 0 0 1px rgba(255,255,255,0.1);
    white-space: nowrap;
}

.btn:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: scale(1.02);
}

.btn:active {
    transform: scale(0.96);
    background: rgba(255, 255, 255, 0.15);
}

.btn-primary { background: var(--primary); color: white; box-shadow: 0 4px 12px rgba(0,0,0,0.2); }
.btn-primary:hover { background: var(--primary-hover); filter: brightness(1.1); }

.btn-secondary { background: rgba(120, 120, 128, 0.2); color: var(--text-main); }
.btn-secondary:hover { background: rgba(120, 120, 128, 0.35); }

.btn-danger { background: rgba(255, 69, 58, 0.15); color: var(--danger); box-shadow: inset 0 0 0 1px rgba(255, 69, 58, 0.3); }
.btn-danger:hover { background: var(--danger); color: white; }

.btn-warning { background: rgba(255, 214, 10, 0.15); color: var(--warning); box-shadow: inset 0 0 0 1px rgba(255, 214, 10, 0.3); }
.btn-warning:hover { background: var(--warning); color: black; }

.btn-success { background: rgba(48, 209, 88, 0.15); color: var(--success); box-shadow: inset 0 0 0 1px rgba(48, 209, 88, 0.3); }
.btn-success:hover { background: var(--success); color: white; }

.btn-saved {
    background-color: var(--success) !important;
    color: white !important;
    pointer-events: none;
    transform: scale(1.05);
    box-shadow: 0 0 15px rgba(48, 209, 88, 0.4);
}

.btn-sm { padding: 0.4rem 0.9rem; font-size: 0.85rem; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none !important; }

/* --- Inputs --- */
.form-control {
    width: 100%;
    padding: 0.8rem 1rem;
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: var(--radius-md);
    color: white;
    font-size: 1rem;
    transition: all 0.2s;
    backdrop-filter: blur(10px);
}

.form-control:focus {
    outline: none;
    background: rgba(0, 0, 0, 0.4);
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(var(--primary), 0.3);
}

.input-error {
    border-color: var(--danger) !important;
    animation: shake 0.4s cubic-bezier(.36,.07,.19,.97) both;
    box-shadow: 0 0 0 1px var(--danger) !important;
}

@keyframes shake {
  10%, 90% { transform: translate3d(-1px, 0, 0); }
  20%, 80% { transform: translate3d(2px, 0, 0); }
  30%, 50%, 70% { transform: translate3d(-4px, 0, 0); }
  40%, 60% { transform: translate3d(4px, 0, 0); }
}

/* Input with Icon Wrapper */
.input-with-icon {
    position: relative;
    display: flex;
    align-items: center;
}
.input-with-icon svg {
    position: absolute;
    left: 12px;
    width: 20px;
    height: 20px;
    pointer-events: none;
    z-index: 1;
}
.input-with-icon .form-control {
    padding-left: 40px;
}

/* Switch Toggle */
.switch { position: relative; display: inline-block; width: 44px; height: 24px; }
.switch input { opacity: 0; width: 0; height: 0; }
.slider { position: absolute; cursor: pointer; top: 0; left: 0; right: 0; bottom: 0; background-color: rgba(255,255,255,0.2); transition: .4s; border-radius: 24px; }
.slider:before { position: absolute; content: ""; height: 20px; width: 20px; left: 2px; bottom: 2px; background-color: white; transition: .4s; border-radius: 50%; }
input:checked + .slider { background-color: var(--primary); }
input:checked + .slider:before { transform: translateX(20px); }

/* --- Layout --- */
.login-container { display: flex; justify-content: center; align-items: center; min-height: 100vh; padding: 1rem; }
.login-card { padding: 3rem; width: 100%; max-width: 420px; text-align: center; }
.dashboard { max-width: 1280px; margin: 0 auto; padding: 2rem; padding-top: 100px; padding-bottom: 4rem; }

/* --- Floating Nav --- */
.header-ornament {
    position: fixed;
    top: 20px; left: 50%; transform: translateX(-50%);
    z-index: 100;
    background: rgba(20, 20, 20, 0.75);
    backdrop-filter: blur(40px) saturate(180%);
    border: 1px solid rgba(255, 255, 255, 0.15);
    padding: 0.5rem 0.75rem;
    border-radius: 999px;
    display: flex; align-items: center; gap: 0.5rem;
    box-shadow: 0 10px 30px rgba(0,0,0,0.3);
}

.header-title { padding: 0 1rem; font-weight: 600; color: var(--text-main); display: flex; flex-direction: column; line-height: 1.1; }
.nav-btn { background: transparent; border: none; color: var(--text-secondary); width: 44px; height: 44px; border-radius: 50%; display: flex; align-items: center; justify-content: center; cursor: pointer; transition: all 0.2s; }
.nav-btn:hover { background: rgba(255, 255, 255, 0.1); color: white; transform: scale(1.1); }

/* Icons */
.nav-btn svg, .btn svg { width: 24px; height: 24px; }

/* Fallback Line Icons (for those without gradients) */
.icon-line {
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

/* --- Bot Grid --- */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(360px, 1fr)); gap: 2rem; }
.bot-card { padding: 1.75rem; display: flex; flex-direction: column; position: relative; }
.bot-card:hover { transform: translateY(-6px) scale(1.01); background: var(--glass-bg-hover); }

.status-badge { position: absolute; top: 1.2rem; right: 1.2rem; display: flex; align-items: center; gap: 6px; background: rgba(0,0,0,0.3); padding: 4px 10px; border-radius: 99px; font-size: 0.75rem; border: 1px solid rgba(255,255,255,0.05); }
.status-dot { width: 8px; height: 8px; border-radius: 50%; }
.status-online .status-dot { background: var(--success); box-shadow: 0 0 8px var(--success); }
.status-offline .status-dot { background: var(--text-muted); }
.status-warning { color: var(--warning); background: rgba(255,149,0,0.15); border-color: rgba(255,149,0,0.3); }
.status-warning .status-dot { background: var(--warning); box-shadow: 0 0 8px var(--warning); }
.status-restricted { color: var(--danger); background: rgba(255,59,48,0.15); border-color: rgba(255,59,48,0.35); }
.status-restricted .status-dot { background: var(--danger); box-shadow: 0 0 8px var(--danger); }

.bot-info { display: flex; align-items: center; gap: 1.25rem; margin-bottom: 1.5rem; }
.bot-avatar { width: 64px; height: 64px; border-radius: 50%; background: rgba(255,255,255,0.1); display: flex; align-items: center; justify-content: center; overflow: hidden; border: 2px solid rgba(255,255,255,0.1); flex-shrink: 0; cursor: pointer; }
.bot-avatar img { width: 100%; height: 100%; object-fit: cover; }
.bot-details h3 { font-size: 1.3rem; font-weight: 600; margin-bottom: 0.2rem; }
.stats-row { display: flex; background: rgba(0, 0, 0, 0.2); border-radius: var(--radius-md); padding: 1rem; margin-bottom: 1.5rem; border: 1px solid rgba(255,255,255,0.05); }
.stat-item { flex: 1; text-align: center; }
.stat-value { font-size: 1.2rem; font-weight: 600; }
.actions { margin-top: auto; display: flex; gap: 0.75rem; }
.actions .btn { flex: 1; }

/* --- Modals --- */
.modal-overlay { position: fixed; inset: 0; background: rgba(0, 0, 0, 0.6); backdrop-filter: blur(10px); display: flex; justify-content: center; align-items: center; z-index: 1000; padding: 1rem; animation: fadeIn 0.3s ease-out; }
.modal-content { width: 100%; max-height: 85vh; display: flex; flex-direction: column; animation: scaleIn 0.3s; border: 1px solid rgba(255,255,255,0.2); }
.modal-header { padding: 1.25rem 1.5rem; border-bottom: 1px solid rgba(255,255,255,0.1); display: flex; justify-content: space-between; align-items: center; }
.modal-header h3 { display: flex; align-items: center; gap: 0.5rem; white-space: nowrap; }
.modal-body { padding: 1.5rem; overflow-y: auto; }
.modal-actions { padding: 1.25rem 1.5rem; border-top: 1px solid rgba(255,255,255,0.1); display: flex; justify-content: flex-end; gap: 0.75rem; background: rgba(0,0,0,0.1); }

/* --- Lists --- */
.contract-item { padding: 1rem; border: 1px solid rgba(255,255,255,0.05); background: rgba(255,255,255,0.03); border-radius: var(--radius-sm); display: flex; justify-content: space-between; align-items: center; margin-bottom: 0.5rem; transition: background 0.2s; }
.contract-item:hover { background: rgba(255, 255, 255, 0.08); }
.group-avatar { width: 40px; height: 40px; border-radius: 50%; border: 1px solid rgba(255,255,255,0.1); margin-right: 12px; object-fit: cover; background: #000; flex-shrink: 0; }
.section-divider { font-size: 0.85rem; font-weight: 600; color: var(--text-secondary); margin: 1.5rem 0 1rem; text-transform: uppercase; letter-spacing: 1px; display: flex; align-items: center; }
.section-divider::after { content: ''; flex: 1; height: 1px; background: rgba(255,255,255,0.1); margin-left: 1rem; }
.tag-left { background: rgba(255,255,255,0.1); color: var(--text-secondary); padding: 2px 6px; border-radius: 4px; font-size: 0.7rem; margin-left: 6px; border: 1px solid rgba(255,255,255,0.1); }
.tag-missing { background: rgba(255, 69, 58, 0.1); color: var(--danger); padding: 2px 6px; border-radius: 4px; font-size: 0.7rem; margin-left: 6px; border: 1px solid rgba(255, 69, 58, 0.2); display: flex; align-items: center; gap: 4px; }
.tag-missing svg { width: 12px; height: 12px; }
.copyable-number { appearance: none; background: transparent; border: 0; border-radius: 4px; color: inherit; cursor: default; font: inherit; letter-spacing: 0; margin: -3px -4px; padding: 3px 4px; transition: background-color 140ms ease, box-shadow 140ms ease; }
.copyable-number:hover, .copyable-number:focus-visible { background: rgba(255,255,255,0.1); box-shadow: 0 0 0 1px rgba(255,255,255,0.16); outline: none; }

/* --- Stagger Animation --- */
@keyframes slideInStagger {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}
.stagger-item {
    opacity: 0;
    animation: slideInStagger 0.3s ease-out forwards;
}
.stagger-item:nth-child(1) { animation-delay: 0.02s; }
.stagger-item:nth-child(2) { animation-delay: 0.04s; }
.stagger-item:nth-child(3) { animation-delay: 0.06s; }
.stagger-item:nth-child(4) { animation-delay: 0.08s; }
.stagger-item:nth-child(5) { animation-delay: 0.10s; }
.stagger-item:nth-child(6) { animation-delay: 0.12s; }
.stagger-item:nth-child(7) { animation-delay: 0.14s; }
.stagger-item:nth-child(8) { animation-delay: 0.16s; }
.stagger-item:nth-child(9) { animation-delay: 0.18s; }
.stagger-item:nth-child(10) { animation-delay: 0.20s; }

/* --- Tables --- */
.history-table { width: 100%; border-collapse: separate; border-spacing: 0; white-space: nowrap; }
.history-table th, .history-table td { padding: 1rem; text-align: left; border-bottom: 1px solid rgba(255,255,255,0.05); }
.history-table th { color: var(--text-secondary); font-weight: 600; background: rgba(30,30,30,0.5); position: sticky; top: 0; backdrop-filter: blur(10px); z-index: 1; }

/* --- Toast Notification --- */
.toast-container {
    position: fixed;
    top: 24px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 2000;
    display: flex;
    flex-direction: column;
    gap: 8px;
    pointer-events: none;
}

.toast-item {
    background: rgba(20, 20, 20, 0.8);
    backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: white;
    padding: 6px 16px;
    border-radius: 99px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
    display: flex;
    align-items: center;
    gap: 8px;
    animation: toastIn 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
    font-size: 0.85rem;
    min-width: auto;
    justify-content: center;
    pointer-events: auto;
}

.toast-item svg {
    width: 16px;
    height: 16px;
}

.toast-success svg { color: var(--success); }
.toast-error svg { color: var(--danger); }

@keyframes toastIn {
    from { transform: translateY(-20px) scale(0.9); opacity: 0; }
    to { transform: translateY(0) scale(1); opacity: 1; }
}

/* --- Confirm Modal --- */
.confirm-overlay {
    position: fixed; inset: 0; background: rgba(0, 0, 0, 0.4); backdrop-filter: blur(4px); z-index: 2100;
    display: flex; justify-content: center; align-items: center; animation: fadeIn 0.2s;
}
.confirm-modal {
    background: rgba(30, 30, 30, 0.85); backdrop-filter: blur(40px);
    border: 1px solid rgba(255,255,255,0.15); border-radius: 20px;
    padding: 1.25rem; width: 280px; text-align: center;
    box-shadow: 0 25px 50px -12px rgba(0,0,0,0.5);
    animation: scaleIn 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.confirm-actions { display: flex; gap: 10px; margin-top: 1.5rem; }
.confirm-actions .btn { flex: 1; }

/* --- Page Transition --- */
.view-transition {
    width: 100%;
    animation: viewEnter 0.4s cubic-bezier(0.2, 0.8, 0.2, 1);
}
@keyframes viewEnter {
    from { opacity: 0; transform: scale(0.98); filter: blur(4px); }
    to { opacity: 1; transform: scale(1); filter: blur(0); }
}

/* --- Mobile Adaptation --- */
@media (max-width: 768px) {
    /* Layout */
    .dashboard { 
        padding: 1rem; 
        padding-top: 2rem; 
        padding-bottom: 120px; /* Space for bottom dock */
    }

    /* Bottom Dock Navigation */
    .header-ornament { 
        top: auto; 
        bottom: 20px; 
        width: 90%; 
        justify-content: space-around; 
        padding: 0.8rem;
        background: rgba(30, 30, 30, 0.85); 
    }
    
    .header-title { display: none; } 
    .nav-btn { width: 48px; height: 48px; } 
    .nav-btn svg { width: 28px; height: 28px; } 

    /* Stacked Grid */
    .grid { grid-template-columns: 1fr; gap: 1.5rem; }
    
    /* Modals */
    .modal-content { 
        max-height: 90vh; 
        width: 95%; 
        border-radius: var(--radius-md);
    }
    .modal-body { padding: 1rem; }

    /* Contract Items */
    .contract-item { 
        flex-direction: column; 
        align-items: flex-start; 
        gap: 1rem; 
    }
    .contract-item > div:first-child { width: 100%; }
    .contract-item > div:last-child { 
        width: 100%; 
        display: flex; 
        gap: 0.5rem; 
        margin-top: 0.5rem;
        flex-wrap: wrap;
    }
    .contract-item .btn { flex: 1; padding: 0.5rem; }

    /* Inputs & Forms */
    .form-group { margin-bottom: 1rem; }
    .form-group .form-control { font-size: 16px; } 
    
    /* Stats Row */
    .stats-row { padding: 0.8rem; }
    .stat-value { font-size: 1rem; }
    
    /* Hide less important info */
    .section-divider::after { display: none; }
    .section-divider { border-bottom: 1px solid rgba(255,255,255,0.1); padding-bottom: 0.5rem; }
}

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