:root {
    --primary: #3b82f6;
    --primary-dark: #2563eb;
    --secondary: #1e293b;
    --secondary-light: #334155;
    --success: #10b981;
    --danger: #ef4444;
    --warning: #f59e0b;
    --purple: #8b5cf6;
    --light: #f8fafc;
    --gray: #64748b;
    --gray-light: #94a3b8;
    --gray-lighter: #e2e8f0;
    --gray-lightest: #f1f5f9;
}

* {
    box-sizing: border-box;
    max-width: 100%;
}

html, body {
    font-family: 'Inter', 'Segoe UI', -apple-system, BlinkMacSystemFont, sans-serif;
    background: linear-gradient(135deg, #f5f7fa 0%, #e8eef5 100%);
    margin: 0;
    padding: 0;
    color: #1e293b;
    overflow-x: hidden !important;
    width: 100vw;
    position: relative;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 20px;
}

/* ========== HEADER ========== */
header {
    display: flex;
    flex-direction: column;
    gap: 15px;
    margin-bottom: 30px;
    background: white;
    padding: 20px;
    border-radius: 16px;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
}

@media (min-width: 768px) {
    header {
        flex-direction: row;
        justify-content: space-between;
        align-items: center;
    }
}

h1 { 
    color: var(--secondary); 
    margin: 0; 
    font-size: 1.8rem; 
    font-weight: 800;
    background: linear-gradient(135deg, #3b82f6 0%, #8b5cf6 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

h2 { 
    font-size: 1.3rem; 
    margin-bottom: 20px; 
    color: var(--secondary); 
    border-bottom: 3px solid var(--primary);
    padding-bottom: 12px;
    font-weight: 700;
}

/* ========== BUTTONS ========== */
.btn {
    display: inline-block;
    padding: 12px 20px;
    border-radius: 10px;
    text-decoration: none;
    font-weight: 600;
    font-size: 0.875rem;
    cursor: pointer;
    border: none;
    transition: all 0.3s ease;
    text-align: center;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

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

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

.btn-blue { 
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    color: white; 
}

.btn-green { 
    background: linear-gradient(135deg, var(--success) 0%, #059669 100%);
    color: white; 
}

.btn-red { 
    background: linear-gradient(135deg, var(--danger) 0%, #dc2626 100%);
    color: white; 
}

.btn-gray { 
    background: linear-gradient(135deg, var(--gray) 0%, var(--secondary-light) 100%);
    color: white; 
}

.nav-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    width: 100%;
}

.nav-buttons .btn {
    flex: 1 1 calc(25% - 10px);
    min-width: 90px;
    padding: 10px 8px;
    font-size: 0.7rem;
}

@media (min-width: 768px) {
    .nav-buttons {
        display: flex;
        flex-direction: row;
        flex-wrap: nowrap;
    }
    .nav-buttons .btn {
        flex: 0 1 auto;
        font-size: 0.875rem;
        padding: 12px 20px;
    }
}

/* ========== GRID ========== */
.grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 20px;
    margin-bottom: 25px;
}

@media (min-width: 992px) {
    .grid {
        grid-template-columns: 1fr 1fr;
    }
}

/* ========== CARDS ========== */
.card {
    background: white;
    padding: 25px;
    border-radius: 16px;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    width: 100%;
    border: 1px solid var(--gray-lighter);
}

/* ========== FORMS ========== */
input, select, textarea {
    width: 100%;
    padding: 12px 16px;
    margin-bottom: 15px;
    border: 2px solid var(--gray-lighter);
    border-radius: 10px;
    box-sizing: border-box;
    font-size: 0.95rem;
    transition: all 0.3s ease;
    background: var(--light);
}

input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--primary);
    background: white;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    font-size: 0.85rem;
    color: var(--secondary-light);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* ========== SERVER BOX ========== */
.srv-box {
    background: var(--gray-lightest);
    padding: 18px;
    border-radius: 12px;
    margin-bottom: 15px;
    border: 2px solid var(--gray-lighter);
    transition: all 0.3s ease;
}

.srv-box:hover {
    border-color: var(--primary);
    box-shadow: 0 4px 8px rgba(59, 130, 246, 0.1);
}

/* ========== BADGES ========== */
.badge {
    padding: 6px 12px;
    border-radius: 8px;
    font-size: 0.75rem;
    font-weight: 700;
    display: inline-block;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.badge-active { 
    background: linear-gradient(135deg, #d1fae5 0%, #a7f3d0 100%);
    color: #065f46; 
    border: 1px solid #6ee7b7;
}

.badge-pending { 
    background: linear-gradient(135deg, #fef3c7 0%, #fde68a 100%);
    color: #92400e; 
    border: 1px solid #fbbf24;
}

.badge-connected { 
    background: linear-gradient(135deg, #dbeafe 0%, #bfdbfe 100%);
    color: #1e40af; 
    border: 1px solid #60a5fa;
}

/* ========== CLIENT GROUP CARDS ========== */
.client-group-card {
    background: white;
    border-radius: 16px;
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    margin-bottom: 25px;
    border: 2px solid var(--gray-lighter);
    overflow: hidden;
    transition: all 0.3s ease;
}

.client-group-card:hover {
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
    transform: translateY(-2px);
}

.client-group-header {
    background: linear-gradient(135deg, #3b82f6 0%, #8b5cf6 100%);
    padding: 20px 25px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
}

.client-group-header h3 {
    margin: 0;
    color: white;
    font-size: 1.25rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 10px;
}

.client-group-header .client-id {
    font-family: 'Courier New', monospace;
    font-size: 0.8rem;
    color: rgba(255, 255, 255, 0.9);
    background: rgba(255, 255, 255, 0.2);
    padding: 6px 12px;
    border-radius: 8px;
    font-weight: 600;
    backdrop-filter: blur(10px);
}

/* ========== DEVICE SUB ITEMS ========== */
.device-sub-item {
    border-bottom: 2px solid var(--gray-lightest);
    padding: 20px 25px;
    transition: all 0.3s ease;
    background: white;
}

.device-sub-item:last-child {
    border-bottom: none;
}

.device-sub-item:hover {
    background: var(--light);
    padding-left: 30px;
}

/* ========== LIST STRUCTURE ========== */
.list-container {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.list-item {
    background: transparent;
    border: none;
    border-radius: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 20px;
    box-shadow: none;
}

@media (min-width: 768px) {
    .list-item {
        flex-direction: row;
        justify-content: space-between;
        align-items: flex-start;
    }
}

.item-info {
    display: grid;
    grid-template-columns: 1fr;
    gap: 20px;
    flex: 1;
}

@media (min-width: 768px) {
    .item-info {
        grid-template-columns: 1.2fr 2fr 1.5fr;
        align-items: start;
    }
}

.info-group {
    word-break: break-word;
    overflow-wrap: break-word;
}

.info-group label {
    font-size: 0.7rem;
    color: var(--gray);
    margin-bottom: 8px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.item-actions {
    display: flex;
    gap: 10px;
    align-items: flex-start;
}

@media (max-width: 767px) {
    .item-actions {
        border-top: 2px solid var(--gray-lightest);
        padding-top: 15px;
    }
    .item-actions .btn {
        flex: 1;
    }
}

/* ========== DEVICE INFO STYLES ========== */
.device-name-badge {
    display: inline-block;
    background: linear-gradient(135deg, #e0e7ff 0%, #c7d2fe 100%);
    color: #3730a3;
    padding: 8px 16px;
    border-radius: 10px;
    font-size: 0.85rem;
    font-weight: 700;
    border: 2px solid #a5b4fc;
    margin-top: 8px;
}

.server-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 12px;
    border-radius: 10px;
    font-size: 0.8rem;
    font-weight: 600;
    margin-right: 8px;
    margin-bottom: 8px;
    border: 2px solid;
    transition: all 0.3s ease;
}

.server-badge:hover {
    transform: scale(1.05);
}

.server-badge.connected {
    background: linear-gradient(135deg, #d1fae5 0%, #a7f3d0 100%);
    color: #065f46;
    border-color: #34d399;
}

.server-badge.forced {
    background: linear-gradient(135deg, #e9d5ff 0%, #d8b4fe 100%);
    color: #581c87;
    border-color: #a78bfa;
}

.server-badge.offline {
    background: linear-gradient(135deg, #f1f5f9 0%, #e2e8f0 100%);
    color: #475569;
    border-color: #cbd5e1;
}

.status-info {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    align-items: center;
    font-size: 0.8rem;
    color: var(--secondary-light);
}

.status-info-item {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 6px 10px;
    background: var(--gray-lightest);
    border-radius: 8px;
    font-weight: 600;
}

.status-info-item strong {
    color: var(--secondary);
}

.status-info-item.highlight {
    background: linear-gradient(135deg, #dbeafe 0%, #bfdbfe 100%);
    color: #1e40af;
}

/* ========== SEARCH BOX ========== */
.search-box {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 20px;
}

@media (min-width: 768px) {
    .search-box {
        flex-direction: row;
    }
    .search-box input { margin-bottom: 0; }
}

/* ========== TOGGLE SWITCH ========== */
.switch-container {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-top: 10px;
    background: var(--gray-lightest);
    padding: 12px 16px;
    border-radius: 12px;
    border: 2px solid var(--gray-lighter);
}

.switch {
    position: relative;
    display: inline-block;
    width: 52px;
    height: 28px;
}

.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #cbd5e1;
    transition: .4s;
    border-radius: 28px;
}

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

input:checked + .slider {
    background: linear-gradient(135deg, var(--purple) 0%, #7c3aed 100%);
}

input:focus + .slider {
    box-shadow: 0 0 1px var(--purple);
}

input:checked + .slider:before {
    transform: translateX(24px);
}

.switch-label {
    font-size: 0.9rem;
    font-weight: 700;
    color: var(--purple);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.warning-text {
    display: block;
    font-size: 0.75rem;
    color: var(--danger);
    margin-top: 5px;
    font-weight: 600;
}

/* ========== PROGRESS BAR ========== */
.progress-container {
    width: 100%;
    background: var(--gray-lightest);
    border-radius: 10px;
    overflow: hidden;
    margin-top: 10px;
    border: 2px solid var(--gray-lighter);
}

.progress-bar {
    height: 30px;
    background: linear-gradient(135deg, var(--primary) 0%, var(--purple) 100%);
    text-align: center;
    line-height: 30px;
    color: white;
    font-weight: 700;
    transition: width 0.3s ease;
}

/* ========== MODAL ========== */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(5px);
}

.modal-content {
    background: white;
    margin: 5% auto;
    padding: 30px;
    border-radius: 20px;
    width: 90%;
    max-width: 600px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
    border: 2px solid var(--gray-lighter);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 2px solid var(--gray-lighter);
    padding-bottom: 15px;
    margin-bottom: 20px;
}

.modal-header h3 {
    margin: 0;
    color: var(--secondary);
    font-weight: 700;
}

/* ========== RESPONSIVE ========== */
@media (max-width: 900px) {
    .desktop-row, .desktop-columns {
        grid-template-columns: 1fr;
    }
    
    .container {
        padding: 15px;
    }
    
    h1 {
        font-size: 1.5rem;
    }
    
    .client-group-header h3 {
        font-size: 1.1rem;
    }
}
