/* Diablito Dashboard v2 - Enhanced with Chat and Service Status */

:root {
    --bg-primary: #0a0a0f;
    --bg-secondary: #12121a;
    --glass-bg: rgba(20, 20, 30, 0.7);
    --glass-border: rgba(255, 255, 255, 0.1);
    --text-primary: #e0e0e0;
    --text-secondary: #888;
    --accent-primary: #00d4aa;
    --accent-secondary: #7c3aed;
    --success: #00d4aa;
    --error: #ff4757;
    --warning: #ffa502;
    --offline: #535c68;
    --chat-bg: rgba(25, 25, 35, 0.8);
}

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

body {
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    line-height: 1.6;
}

/* Background Animation */
body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: 
        radial-gradient(circle at 20% 80%, rgba(124, 58, 237, 0.15) 0%, transparent 50%),
        radial-gradient(circle at 80% 20%, rgba(0, 212, 170, 0.1) 0%, transparent 50%);
    z-index: -1;
    animation: bgPulse 8s ease-in-out infinite;
}

@keyframes bgPulse {
    0%, 100% { opacity: 0.8; }
    50% { opacity: 1; }
}

/* Screen Management */
.screen {
    display: none;
    min-height: 100vh;
    padding: 2rem;
}

.screen.active {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

/* Login Screen */
.login-container {
    background: var(--glass-bg);
    backdrop-filter: blur(20px);
    border: 1px solid var(--glass-border);
    border-radius: 24px;
    padding: 3rem;
    width: 100%;
    max-width: 400px;
    box-shadow: 
        0 8px 32px rgba(0, 0, 0, 0.4),
        inset 0 1px 0 rgba(255, 255, 255, 0.1);
    animation: slideUp 0.5s ease-out;
}

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

.login-container h1 {
    font-size: 2rem;
    font-weight: 700;
    text-align: center;
    margin-bottom: 0.5rem;
    background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.subtitle {
    text-align: center;
    color: var(--text-secondary);
    margin-bottom: 2rem;
}

/* Messages */
.error {
    background: rgba(255, 71, 87, 0.1);
    border: 1px solid var(--error);
    color: var(--error);
    padding: 1rem;
    border-radius: 8px;
    margin-bottom: 1rem;
    display: none;
}

.error.show {
    display: block;
    animation: shake 0.5s ease;
}

.success {
    background: rgba(0, 212, 170, 0.1);
    border: 1px solid var(--success);
    color: var(--success);
    padding: 1rem;
    border-radius: 8px;
    margin-bottom: 1rem;
    display: none;
}

.success.show {
    display: block;
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-5px); }
    75% { transform: translateX(5px); }
}

/* User Select */
.user-select {
    margin-bottom: 1.5rem;
}

.user-select label {
    display: block;
    margin-bottom: 0.5rem;
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.user-select select {
    width: 100%;
    padding: 1rem;
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid var(--glass-border);
    border-radius: 12px;
    color: var(--text-primary);
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.3s ease;
}

.user-select select:hover,
.user-select select:focus {
    border-color: var(--accent-primary);
    outline: none;
}

/* PIN Entry */
.pin-entry {
    margin-top: 1.5rem;
}

.pin-entry label {
    display: block;
    margin-bottom: 0.5rem;
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.pin-display {
    background: rgba(0, 0, 0, 0.3);
    border: 2px solid var(--glass-border);
    border-radius: 12px;
    padding: 1.5rem;
    text-align: center;
    margin-bottom: 1rem;
}

.pin-dot {
    display: inline-block;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: var(--text-secondary);
    margin: 0 8px;
    transition: all 0.2s ease;
}

.pin-dot.filled {
    background: var(--accent-primary);
    transform: scale(1.2);
    box-shadow: 0 0 10px var(--accent-primary);
}

/* Keypad */
.keypad {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.75rem;
}

.key {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--glass-border);
    border-radius: 16px;
    padding: 1.5rem;
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--text-primary);
    cursor: pointer;
    transition: all 0.2s ease;
}

.key:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: var(--accent-primary);
    transform: translateY(-2px);
}

.key:active {
    transform: translateY(0);
}

.key.clear {
    color: var(--error);
}

.key.enter {
    background: var(--accent-primary);
    color: var(--bg-primary);
}

.key.enter:hover {
    background: var(--accent-secondary);
}

/* Dashboard Header */
.dashboard-header {
    background: var(--glass-bg);
    backdrop-filter: blur(20px);
    border: 1px solid var(--glass-border);
    border-radius: 16px;
    padding: 1.5rem 2rem;
    margin-bottom: 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    animation: fadeIn 0.5s ease;
    width: 100%;
    max-width: 1200px;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.dashboard-header h1 {
    font-size: 1.5rem;
    background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 1rem;
}

#username-display {
    color: var(--text-secondary);
}

/* Buttons */
.btn-secondary {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid var(--glass-border);
    border-radius: 8px;
    padding: 0.5rem 1rem;
    color: var(--text-primary);
    cursor: pointer;
    transition: all 0.3s ease;
}

.btn-secondary:hover {
    background: var(--error);
    border-color: var(--error);
}

.btn-primary {
    background: var(--accent-primary);
    border: none;
    border-radius: 12px;
    padding: 1rem 2rem;
    color: var(--bg-primary);
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    transition: all 0.3s ease;
}

.btn-primary:hover {
    background: var(--accent-secondary);
    transform: translateY(-2px);
}

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

.btn-primary .icon {
    font-size: 1.2rem;
}

/* Dashboard Content */
.dashboard-content {
    width: 100%;
    max-width: 1200px;
}

/* Nodes Grid */
.nodes-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(340px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

/* Node Card */
.node-card {
    background: var(--glass-bg);
    backdrop-filter: blur(20px);
    border: 1px solid var(--glass-border);
    border-radius: 20px;
    padding: 1.5rem;
    transition: all 0.3s ease;
    animation: fadeInUp 0.5s ease;
}

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

.node-card:hover {
    border-color: rgba(255, 255, 255, 0.2);
    transform: translateY(-5px);
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.3);
}

.node-card.online {
    border-left: 4px solid var(--success);
}

.node-card.offline {
    border-left: 4px solid var(--error);
}

.node-card.pending {
    border-left: 4px solid var(--warning);
    opacity: 0.7;
}

.node-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.node-name {
    font-size: 1.2rem;
    font-weight: 600;
}

.node-status {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.25rem 0.75rem;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 500;
}

.node-status.online {
    background: rgba(0, 212, 170, 0.2);
    color: var(--success);
}

.node-status.offline {
    background: rgba(255, 71, 87, 0.2);
    color: var(--error);
}

.node-status.pending {
    background: rgba(255, 165, 2, 0.2);
    color: var(--warning);
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: currentColor;
    animation: pulse 2s ease infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

.node-metrics {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1rem;
    margin-top: 1rem;
}

.metric {
    background: rgba(0, 0, 0, 0.2);
    border-radius: 12px;
    padding: 1rem;
    text-align: center;
}

.metric-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--accent-primary);
}

.metric-label {
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-top: 0.25rem;
}

.node-info {
    color: var(--text-secondary);
    font-size: 0.85rem;
    margin-top: 0.5rem;
}

/* Service Badges */
.node-services {
    margin-top: 1rem;
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.service-badge {
    font-size: 0.75rem;
    padding: 0.25rem 0.5rem;
    border-radius: 6px;
    font-weight: 500;
    display: inline-block;
}

.service-badge.up {
    background: rgba(0, 212, 170, 0.2);
    color: var(--success);
    border: 1px solid rgba(0, 212, 170, 0.3);
}

.service-badge.down {
    background: rgba(255, 71, 87, 0.2);
    color: var(--error);
    border: 1px solid rgba(255, 71, 87, 0.3);
}

/* Chat Section */
.chat-section {
    background: var(--chat-bg);
    backdrop-filter: blur(20px);
    border: 1px solid var(--glass-border);
    border-radius: 20px;
    padding: 1.5rem;
    margin-bottom: 2rem;
}

.chat-section h2 {
    font-size: 1.25rem;
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.chat-container {
    background: rgba(0, 0, 0, 0.3);
    border-radius: 12px;
    height: 300px;
    overflow-y: auto;
    padding: 1rem;
    margin-bottom: 1rem;
}

.chat-welcome {
    color: var(--text-secondary);
    text-align: center;
    padding: 2rem;
    font-style: italic;
}

.chat-message {
    margin-bottom: 0.75rem;
    padding: 0.75rem;
    border-radius: 12px;
    max-width: 80%;
}

.chat-message.user {
    background: var(--accent-primary);
    color: var(--bg-primary);
    margin-left: auto;
    border-bottom-right-radius: 4px;
}

.chat-message.ai {
    background: rgba(255, 255, 255, 0.1);
    border-bottom-left-radius: 4px;
}

.chat-header {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    font-size: 0.75rem;
    margin-bottom: 0.25rem;
    opacity: 0.7;
}

.chat-text {
    word-wrap: break-word;
}

.chat-input-area {
    display: flex;
    gap: 0.75rem;
}

#chat-input {
    flex: 1;
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid var(--glass-border);
    border-radius: 12px;
    padding: 1rem;
    color: var(--text-primary);
    font-size: 1rem;
}

#chat-input:focus {
    outline: none;
    border-color: var(--accent-primary);
}

/* Actions */
.actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem;
    background: var(--glass-bg);
    backdrop-filter: blur(20px);
    border: 1px solid var(--glass-border);
    border-radius: 16px;
    gap: 1rem;
}

.actions-left {
    display: flex;
    gap: 1rem;
}

#last-updated {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

/* Responsive */
@media (max-width: 768px) {
    .screen {
        padding: 1rem;
    }
    
    .login-container {
        padding: 2rem;
    }
    
    .nodes-grid {
        grid-template-columns: 1fr;
    }
    
    .dashboard-header {
        flex-direction: column;
        gap: 1rem;
        text-align: center;
    }
    
    .key {
        padding: 1.25rem;
        font-size: 1.25rem;
    }
    
    .actions {
        flex-direction: column;
        align-items: stretch;
    }
    
    .actions-left {
        justify-content: center;
    }
    
    .chat-input-area {
        flex-direction: column;
    }
    
    #chat-input {
        width: 100%;
    }
    
    .chat-container {
        height: 200px;
    }
}

/* Loading Animation */
.loading {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid rgba(255, 255, 255, 0.1);
    border-top-color: var(--accent-primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Scrollbar */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: var(--bg-primary);
}

::-webkit-scrollbar-thumb {
    background: var(--glass-border);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-secondary);
}

/* Chat scrollbar */
.chat-container::-webkit-scrollbar {
    width: 6px;
}

.chat-container::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.2);
}

.chat-container::-webkit-scrollbar-thumb {
    background: var(--accent-primary);
    border-radius: 3px;
}
/* Chat Status Indicator Styles */
.chat-status-indicator {
    display: flex;
    align-items: center;
    padding: 8px 12px;
    margin: 8px 0;
    border-radius: 12px;
    font-size: 0.9em;
    background: rgba(100, 100, 100, 0.1);
    animation: fadeIn 0.3s ease;
}

.chat-status-indicator.typing {
    background: rgba(76, 175, 80, 0.15);
    color: #4CAF50;
}

.chat-status-indicator.thinking {
    background: rgba(255, 152, 0, 0.15);
    color: #FF9800;
}

.chat-status-indicator.searching {
    background: rgba(33, 150, 243, 0.15);
    color: #2196F3;
}

.chat-status-indicator.connection {
    background: rgba(244, 67, 54, 0.15);
    color: #F44336;
}

.chat-status-indicator .status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    margin-right: 8px;
    animation: pulse 1.5s infinite;
}

.chat-status-indicator.typing .status-dot {
    background: #4CAF50;
}

.chat-status-indicator.thinking .status-dot {
    background: #FF9800;
}

.chat-status-indicator.searching .status-dot {
    background: #2196F3;
}

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

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