/* ============================================
   VARIABLES CSS Y RESET (Estilo Minimalista B&W)
============================================ */

:root {
    /* Shadcn/UI inspired variables */
    --background: #ffffff;
    --foreground: #09090b;
    
    --card: #ffffff;
    --card-foreground: #09090b;
    
    --popover: #ffffff;
    --popover-foreground: #09090b;
    
    --primary: #09090b; /* Negro intenso */
    --primary-foreground: #fafafa; /* Blanco */
    
    --secondary: #f4f4f5; /* Gris muy claro */
    --secondary-foreground: #18181b;
    
    --muted: #f4f4f5;
    --muted-foreground: #71717a;
    
    --accent: #f4f4f5;
    --accent-foreground: #18181b;
    
    --destructive: #ef4444;
    --destructive-foreground: #fafafa;
    
    --border: #e4e4e7;
    --input: #e4e4e7;
    --ring: #18181b;
    
    --radius: 0.5rem;
    --radius-lg: 0.75rem;
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow: 0 1px 3px 0 rgb(0 0 0 / 0.1), 0 1px 2px -1px rgb(0 0 0 / 0.1);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);

    /* Mapeo a variables legacy (para compatibilidad) */
    --primary-color: var(--primary);
    --primary-dark: #000000;
    --secondary-color: #52525b;
    --accent-color: #27272a;
    --danger-color: var(--destructive);
    --warning-color: #f59e0b;
    --success-color: #10b981; /* Mantener verde solo para estados de éxito */
    --info-color: #3b82f6;
    --dark-color: var(--foreground);
    --light-color: var(--background);
    --border-color: var(--border);
    
    --font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

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

body {
    font-family: var(--font-family);
    background-color: var(--background);
    color: var(--foreground);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    min-height: 100vh;
    display: flex;
}

/* ============================================
   SIDEBAR GLOBAL
============================================ */

.sidebar {
    width: 260px;
    background: var(--card);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    position: fixed;
    height: 100vh;
    left: 0;
    top: 0;
    z-index: 50;
    transition: transform 0.3s ease;
}

.sidebar.collapsed {
    width: 70px;
}

.sidebar.collapsed .sidebar-logo span,
.sidebar.collapsed .sidebar-user-info,
.sidebar.collapsed .sidebar-menu-item span,
.sidebar.collapsed .sidebar-logout span {
    display: none;
}

.sidebar.collapsed .sidebar-header {
    justify-content: center;
    padding: 1rem;
}

.sidebar.collapsed .sidebar-user {
    justify-content: center;
    padding: 1rem;
}

.sidebar.collapsed .sidebar-menu-item {
    justify-content: center;
    padding: 0.75rem;
}

.sidebar.collapsed .sidebar-menu-item i {
    font-size: 1.25rem;
    margin: 0;
}

.sidebar.collapsed .sidebar-logout {
    justify-content: center;
    padding: 0.75rem;
}

.desktop-toggle-btn {
    background: transparent;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    cursor: pointer;
    padding: 0.25rem 0.5rem;
    display: none; /* Hidden on mobile */
    color: var(--muted-foreground);
    transition: all 0.2s;
}

.desktop-toggle-btn:hover {
    background: var(--accent);
    color: var(--foreground);
}

@media (min-width: 769px) {
    .desktop-toggle-btn {
        display: flex;
        align-items: center;
        justify-content: center;
        margin-left: auto;
    }
    
    .sidebar.collapsed ~ .main-content {
        margin-left: 70px;
        width: calc(100% - 70px);
    }
}

.sidebar-header {
    padding: 1.5rem;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: center;
}

.sidebar-logo {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--foreground);
    text-decoration: none;
    letter-spacing: -0.025em;
}

.sidebar-logo i {
    font-size: 1.5rem;
    color: var(--primary);
}

.sidebar-user {
    padding: 1.5rem;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 1rem;
}

.sidebar-user-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--secondary);
    color: var(--secondary-foreground);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 1rem;
}

.sidebar-user-info {
    flex: 1;
    overflow: hidden;
}

.sidebar-user-name {
    font-weight: 600;
    color: var(--foreground);
    font-size: 0.875rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar-user-email {
    font-size: 0.75rem;
    color: var(--muted-foreground);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar-menu {
    flex: 1;
    padding: 1rem;
    overflow-y: auto;
}

.sidebar-menu-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    color: var(--muted-foreground);
    text-decoration: none;
    border-radius: var(--radius);
    transition: all 0.2s ease;
    font-weight: 500;
    font-size: 0.875rem;
    margin-bottom: 0.25rem;
}

.sidebar-menu-item:hover {
    background: var(--accent);
    color: var(--accent-foreground);
}

.sidebar-menu-item.active {
    background: var(--primary);
    color: var(--primary-foreground);
}

.sidebar-menu-item i {
    width: 1.25rem;
    text-align: center;
    font-size: 1rem;
}

.sidebar-footer {
    padding: 1rem;
    border-top: 1px solid var(--border);
}

.sidebar-logout {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.75rem;
    background: var(--secondary);
    color: var(--secondary-foreground);
    border-radius: var(--radius);
    cursor: pointer;
    transition: all 0.2s ease;
    border: none;
    width: 100%;
    font-size: 0.875rem;
    font-weight: 500;
}

.sidebar-logout:hover {
    background: #e4e4e7; /* slightly darker gray */
}

/* ============================================
   MAIN CONTENT
============================================ */

.main-content {
    margin-left: 260px;
    flex: 1;
    padding: 2rem;
    width: calc(100% - 260px);
    background-color: var(--background);
    min-height: 100vh;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
}

/* ============================================
   COMPONENTS
============================================ */

/* Panels / Cards */
.panel {
    background: var(--card);
    color: var(--card-foreground);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    margin-bottom: 1.5rem;
    overflow: hidden;
}

.panel-header {
    background: transparent;
    padding: 1.5rem;
    border-bottom: 1px solid var(--border);
}

.panel-header h2 {
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--foreground);
    letter-spacing: -0.025em;
    margin: 0;
}

.panel-body {
    padding: 1.5rem;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius);
    font-size: 0.875rem;
    font-weight: 500;
    padding: 0.5rem 1rem;
    cursor: pointer;
    transition: color 0.2s, background-color 0.2s;
    border: 1px solid transparent;
    text-decoration: none;
    gap: 0.5rem;
}

.btn-primary {
    background-color: var(--primary);
    color: var(--primary-foreground);
}

.btn-primary:hover {
    background-color: rgba(9, 9, 11, 0.9);
}

.btn-secondary, .btn-default {
    background-color: var(--secondary);
    color: var(--secondary-foreground);
}

.btn-secondary:hover {
    background-color: rgba(244, 244, 245, 0.8);
}

.btn-danger {
    background-color: var(--destructive);
    color: var(--destructive-foreground);
}

.btn-danger:hover {
    background-color: rgba(239, 68, 68, 0.9);
}

/* Forms */
.form-group {
    margin-bottom: 1.25rem;
}

.form-group label {
    display: block;
    font-size: 0.875rem;
    font-weight: 500;
    margin-bottom: 0.5rem;
    color: var(--foreground);
}

.form-control {
    width: 100%;
    padding: 0.5rem 0.75rem;
    font-size: 0.875rem;
    border: 1px solid var(--input);
    background-color: transparent;
    border-radius: var(--radius);
    transition: border-color 0.2s;
    color: var(--foreground);
}

.form-control:focus {
    outline: none;
    border-color: var(--ring);
    box-shadow: 0 0 0 1px var(--ring);
}

/* Status Badges */
.status-badge {
    display: inline-flex;
    align-items: center;
    padding: 0.25rem 0.75rem;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 500;
    gap: 0.375rem;
}

.status-badge.connected {
    background-color: rgba(16, 185, 129, 0.1);
    color: #059669;
    border: 1px solid rgba(16, 185, 129, 0.2);
}

.status-badge.disconnected {
    background-color: rgba(239, 68, 68, 0.1);
    color: #dc2626;
    border: 1px solid rgba(239, 68, 68, 0.2);
}

/* Toggle Switch (Custom styled) */
.toggle-switch {
    position: relative;
    display: inline-block;
    width: 44px;
    height: 24px;
}

.toggle-input {
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: var(--input);
    transition: .4s;
    border-radius: 24px;
}

.toggle-slider:before {
    position: absolute;
    content: "";
    height: 18px;
    width: 18px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: .4s;
    border-radius: 50%;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.toggle-input:checked + .toggle-slider {
    background-color: var(--primary);
}

.toggle-input:checked + .toggle-slider:before {
    transform: translateX(20px);
}

/* Notifications */
.notification-container {
    position: fixed;
    top: 1.5rem;
    right: 1.5rem;
    z-index: 100;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    pointer-events: none;
}

.toast-notification {
    pointer-events: auto;
    background: var(--background);
    border: 1px solid var(--border);
    padding: 1rem;
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    min-width: 300px;
    max-width: 400px;
    animation: slideIn 0.3s ease-out;
}

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

.toast-title {
    font-weight: 600;
    font-size: 0.875rem;
    color: var(--foreground);
}

.toast-message {
    font-size: 0.875rem;
    color: var(--muted-foreground);
    margin-top: 0.25rem;
}

/* Responsive */
@media (max-width: 768px) {
    .main-content {
        margin-left: 0;
        width: 100%;
        padding: 1rem;
    }
    
    .sidebar {
        transform: translateX(-100%);
    }
    
    .sidebar.active {
        transform: translateX(0);
    }
}
