/* Variables CSS */
:root {
    --primary-color: #5138ee;
    --primary-gradient: linear-gradient(135deg, #5138ee 0%, #6b56f1 50%, #8e7ef4 100%);
    --secondary-color: #6c757d;
    --success-color: #28a745;
    --danger-color: #dc3545;
    --warning-color: #ffc107;
    --info-color: #17a2b8;
    --light-color: #f8f9fa;
    --dark-color: #343a40;
    --sidebar-width: 280px;
    --topbar-height: 70px;
    --border-radius: 12px;
    --box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --transition: all 0.3s ease;
}

/* Reset y base */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Poppins', sans-serif;
    background-color: #f5f6fa;
    color: var(--dark-color);
    line-height: 1.6;
}

/* Login Page */
.login-container {
    min-height: 100vh;
}

.bg-primary-gradient {
    background: var(--primary-gradient);
}

.login-form-container {
    max-width: 400px;
    width: 100%;
    padding: 2rem;
}

.logo {
    max-width: 200px;
    height: auto;
}

.login-form .form-control {
    border: 2px solid rgba(255, 255, 255, 0.2);
    background: rgba(255, 255, 255, 0.1);
    color: white;
    border-radius: var(--border-radius);
    padding: 12px 16px;
    transition: var(--transition);
}

.login-form .form-control:focus {
    border-color: rgba(255, 255, 255, 0.5);
    background: rgba(255, 255, 255, 0.15);
    box-shadow: 0 0 0 0.2rem rgba(255, 255, 255, 0.25);
    color: white;
}

.login-form .form-control::placeholder {
    color: rgba(255, 255, 255, 0.7);
}

.login-form .form-label {
    font-weight: 500;
    margin-bottom: 8px;
}

/* Sidebar */
.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: var(--sidebar-width);
    height: 100vh;
    background: white;
    box-shadow: var(--box-shadow);
    z-index: 1000;
    transition: var(--transition);
    display: flex;
    flex-direction: column;
}

.sidebar-header {
    padding: 1.5rem;
    border-bottom: 1px solid #e9ecef;
    display: flex;
    align-items: center;
    gap: 12px;
}

.sidebar-header .logo {
    width: 40px;
    height: 40px;
}

.sidebar-header h4 {
    margin: 0;
    color: var(--primary-color);
    font-weight: 600;
}

.sidebar-menu {
    list-style: none;
    padding: 1rem 0;
    flex: 1;
}

.sidebar-menu li {
    margin: 0;
}

.sidebar-menu a {
    display: flex;
    align-items: center;
    padding: 12px 1.5rem;
    color: var(--dark-color);
    text-decoration: none;
    transition: var(--transition);
    font-weight: 500;
}

.sidebar-menu a:hover {
    background: rgba(81, 56, 238, 0.1);
    color: var(--primary-color);
}

.sidebar-menu a.active {
    background: var(--primary-color);
    color: white;
    border-right: 4px solid var(--primary-color);
}

.sidebar-menu a i {
    width: 20px;
    margin-right: 12px;
    text-align: center;
}

.sidebar-footer {
    padding: 1.5rem;
    border-top: 1px solid #e9ecef;
}

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

.user-avatar {
    width: 40px;
    height: 40px;
    background: var(--primary-gradient);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
}

.user-details {
    flex: 1;
}

.user-name {
    display: block;
    font-weight: 600;
    color: var(--dark-color);
}

.user-credits {
    color: var(--secondary-color);
    font-size: 0.875rem;
}

/* Main Content */
.main-content {
    margin-left: var(--sidebar-width);
    min-height: 100vh;
    transition: var(--transition);
}

.top-bar {
    height: var(--topbar-height);
    background: white;
    box-shadow: var(--box-shadow);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 1.5rem;
    position: sticky;
    top: 0;
    z-index: 999;
}

.sidebar-toggle {
    display: none;
    border: none;
    background: none;
    font-size: 1.25rem;
    color: var(--dark-color);
}

.top-bar-right {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.credits-badge {
    background: var(--primary-gradient);
    color: white;
    padding: 8px 16px;
    border-radius: 20px;
    font-weight: 500;
    font-size: 0.875rem;
    display: flex;
    align-items: center;
    gap: 6px;
}

.connection-status {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.875rem;
    color: var(--secondary-color);
}

.page-content {
    padding: 2rem;
}

/* Cards */
.card {
    border: none;
    border-radius: var(--border-radius);
    box-shadow: var(--box-shadow);
    transition: var(--transition);
}

.card:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px -8px rgba(0, 0, 0, 0.15);
}

.card-header {
    background: transparent;
    border-bottom: 1px solid #e9ecef;
    padding: 1.5rem;
    font-weight: 600;
}

.card-body {
    padding: 1.5rem;
}

/* Stats Cards */
.stats-card {
    background: var(--primary-gradient);
    color: black;
    border-radius: var(--border-radius);
    padding: 1.5rem;
    text-align: center;
    transition: var(--transition);
}

.stats-card:hover {
    transform: translateY(-4px);
}

.stats-card .stats-icon {
    font-size: 2.5rem;
    margin-bottom: 1rem;
    opacity: 0.8;
}

.stats-card .stats-value {
    font-size: 2rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
}

.stats-card .stats-label {
    font-size: 0.875rem;
    opacity: 0.9;
}

/* Buttons */
.btn {
    border-radius: var(--border-radius);
    font-weight: 500;
    padding: 10px 20px;
    transition: var(--transition);
    border: none;
}

.btn-primary {
    background: var(--primary-gradient);
    border: none;
}

.btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(81, 56, 238, 0.4);
}

/* Tables */
.table {
    border-radius: var(--border-radius);
    overflow: hidden;
    box-shadow: var(--box-shadow);
    background: white;
}

.table thead th {
    background: var(--light-color);
    border: none;
    font-weight: 600;
    color: var(--dark-color);
    padding: 1rem;
}

.table tbody td {
    padding: 1rem;
    border-color: #e9ecef;
    vertical-align: middle;
}

.table tbody tr:hover {
    background: rgba(81, 56, 238, 0.05);
}

/* Status badges */
.status-badge {
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
}

.status-connected {
    background: rgba(40, 167, 69, 0.1);
    color: var(--success-color);
}

.status-disconnected {
    background: rgba(220, 53, 69, 0.1);
    color: var(--danger-color);
}

.status-pending {
    background: rgba(255, 193, 7, 0.1);
    color: var(--warning-color);
}

/* Forms */
.form-control {
    border: 2px solid #e9ecef;
    border-radius: var(--border-radius);
    padding: 12px 16px;
    transition: var(--transition);
}

.form-control:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 0.2rem rgba(81, 56, 238, 0.25);
}

.form-label {
    font-weight: 500;
    margin-bottom: 8px;
    color: var(--dark-color);
}

/* Loading */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.9);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
}

/* QR Code */
.qr-container {
    text-align: center;
    padding: 2rem;
}

.qr-code {
    max-width: 300px;
    width: 100%;
    height: auto;
    border-radius: var(--border-radius);
    box-shadow: var(--box-shadow);
}

/* Responsive */
@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
    }
    
    .sidebar.show {
        transform: translateX(0);
    }
    
    .main-content {
        margin-left: 0;
    }
    
    .sidebar-toggle {
        display: block;
    }
    
    .page-content {
        padding: 1rem;
    }
    
    .top-bar-right {
        gap: 0.5rem;
    }
    
    .credits-badge {
        padding: 6px 12px;
        font-size: 0.75rem;
    }
}

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

.fade-in {
    animation: fadeIn 0.5s ease-out;
}

/* Toast customization */
.toast {
    border-radius: var(--border-radius);
    box-shadow: var(--box-shadow);
}

/* Chart container */
.chart-container {
    position: relative;
    height: 300px;
    margin: 1rem 0;
}

/* Device card */
.device-card {
    border-left: 4px solid var(--primary-color);
}

.device-card.connected {
    border-left-color: var(--success-color);
}

.device-card.disconnected {
    border-left-color: var(--danger-color);
}
