/* ========================================
   KVM Panel - Professional Theme
   ======================================== */

:root {
    --sidebar-width: 260px;
    --header-height: 60px;
    --gradient-primary: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    --gradient-accent: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
    --gradient-success: linear-gradient(135deg, #00e676 0%, #00b0ff 100%);
    --gradient-info: linear-gradient(135deg, #43e97b 0%, #38f9d7 100%);
    --gradient-warning: linear-gradient(135deg, #f7971e 0%, #ffd200 100%);
    --gradient-danger: linear-gradient(135deg, #ff512f 0%, #f09819 100%);
    --gradient-cyan: linear-gradient(135deg, #00d2ff 0%, #3a7bd5 100%);
    --gradient-purple: linear-gradient(135deg, #a18cd1 0%, #fbc2eb 100%);
    --shadow-card: 0 4px 20px rgba(0, 0, 0, 0.08);
    --shadow-hover: 0 8px 30px rgba(0, 0, 0, 0.12);
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Light Theme */
[data-theme="light"] {
    --bg-primary: #f0f2f5;
    --bg-secondary: #ffffff;
    --bg-sidebar: #1a1d29;
    --bg-header: #ffffff;
    --bg-card: #ffffff;
    --text-primary: #2d3436;
    --text-secondary: #636e72;
    --text-sidebar: #b2bec3;
    --text-sidebar-active: #ffffff;
    --border-color: #e9ecef;
    --log-bg: #f8f9fa;
    --log-text: #495057;
}

/* Dark Theme */
[data-theme="dark"] {
    --bg-primary: #0f1117;
    --bg-secondary: #1a1d29;
    --bg-sidebar: #0d0f15;
    --bg-header: #1a1d29;
    --bg-card: #1e2235;
    --text-primary: #e4e6eb;
    --text-secondary: #8b92a5;
    --text-sidebar: #6c7293;
    --text-sidebar-active: #ffffff;
    --border-color: #2a2d3a;
    --log-bg: #141620;
    --log-text: #a0a8c0;
    --shadow-card: 0 4px 20px rgba(0, 0, 0, 0.3);
}

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

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    overflow-x: hidden;
    transition: var(--transition);
}

/* ---- Scrollbar ---- */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #4a4d5e; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #5a5d6e; }

/* ---- Sidebar ---- */
.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: var(--sidebar-width);
    height: 100vh;
    background: var(--bg-sidebar);
    z-index: 1000;
    transition: var(--transition);
    border-right: 1px solid rgba(255,255,255,0.05);
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}

.sidebar-brand {
    height: var(--header-height);
    display: flex;
    align-items: center;
    padding: 0 24px;
    border-bottom: 1px solid rgba(255,255,255,0.06);
}

.sidebar-brand h2 {
    font-size: 1.2rem;
    font-weight: 700;
    background: var(--gradient-primary);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    letter-spacing: 0.5px;
}

.sidebar-brand .brand-icon {
    width: 36px;
    height: 36px;
    background: var(--gradient-primary);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-right: 12px;
    color: #fff;
    font-size: 1.1rem;
}

.sidebar-menu {
    padding: 16px 0;
    flex: 1;
}

.menu-label {
    padding: 12px 24px 8px;
    font-size: 0.68rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    color: var(--text-sidebar);
    opacity: 0.5;
}

.menu-item {
    display: flex;
    align-items: center;
    padding: 11px 24px;
    color: var(--text-sidebar);
    text-decoration: none;
    font-size: 0.875rem;
    font-weight: 500;
    transition: var(--transition);
    position: relative;
    margin: 2px 12px;
    border-radius: 10px;
}

.menu-item i {
    width: 20px;
    margin-right: 14px;
    font-size: 1rem;
    text-align: center;
}

.menu-item:hover {
    color: var(--text-sidebar-active);
    background: rgba(255,255,255,0.05);
}

.menu-item.active {
    color: var(--text-sidebar-active);
    background: rgba(102, 126, 234, 0.15);
}

.menu-item.active::before {
    content: '';
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 3px;
    height: 60%;
    background: var(--gradient-primary);
    border-radius: 0 3px 3px 0;
}

.sidebar-footer {
    padding: 20px 24px;
    margin-top: auto;
    border-top: 1px solid rgba(255,255,255,0.06);
    text-align: center;
}

.sidebar-footer-label {
    font-size: 0.62rem;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    color: rgba(255,255,255,0.45);
    margin-bottom: 6px;
}

.sidebar-footer-brand {
    font-size: 0.9rem;
    font-weight: 800;
    color: #00e676;
    text-decoration: none;
    letter-spacing: 0.3px;
    display: block;
    margin-bottom: 3px;
}

.sidebar-footer-brand:hover {
    color: #69f0ae;
}

.sidebar-footer-desc {
    font-size: 0.65rem;
    color: rgba(255,255,255,0.5);
    letter-spacing: 0.3px;
}

.menu-item .badge-count {
    margin-left: auto;
    background: var(--gradient-accent);
    color: #fff;
    font-size: 0.7rem;
    padding: 2px 8px;
    border-radius: 12px;
    font-weight: 600;
}

/* ---- Header ---- */
.top-header {
    position: fixed;
    top: 0;
    left: var(--sidebar-width);
    right: 0;
    height: var(--header-height);
    background: var(--bg-header);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 28px;
    z-index: 999;
    transition: var(--transition);
    backdrop-filter: blur(20px);
}

.header-left {
    display: flex;
    align-items: center;
    gap: 16px;
}

.header-left h5 {
    font-weight: 600;
    font-size: 1.05rem;
    background: var(--gradient-primary);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 18px;
}

.datetime-display {
    text-align: right;
    line-height: 1.3;
}

.datetime-display .time {
    font-size: 1rem;
    font-weight: 700;
    background: var(--gradient-success);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.datetime-display .date {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.theme-toggle {
    width: 40px;
    height: 40px;
    border-radius: 12px;
    border: 1px solid var(--border-color);
    background: var(--bg-card);
    color: var(--text-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: var(--transition);
    font-size: 1.1rem;
}

.theme-toggle:hover {
    background: var(--gradient-primary);
    color: #fff;
    border-color: transparent;
}

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

/* ---- Stat Cards ---- */
.stat-card {
    background: var(--bg-card);
    border-radius: 16px;
    padding: 22px;
    box-shadow: var(--shadow-card);
    transition: var(--transition);
    border: 1px solid var(--border-color);
    position: relative;
    overflow: hidden;
}

.stat-card:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-hover);
}

.stat-card .card-icon {
    width: 48px;
    height: 48px;
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    color: #fff;
    margin-bottom: 16px;
}

.stat-card .card-label {
    font-size: 0.78rem;
    color: var(--text-secondary);
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 6px;
}

.stat-card .card-value {
    font-size: 1.6rem;
    font-weight: 700;
    line-height: 1.2;
}

.stat-card .card-sub {
    font-size: 0.78rem;
    color: var(--text-secondary);
    margin-top: 4px;
}

/* Gradient text helpers */
.text-gradient-primary { background: var(--gradient-primary); -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text; }
.text-gradient-accent { background: var(--gradient-accent); -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text; }
.text-gradient-success { background: var(--gradient-success); -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text; }
.text-gradient-info { background: var(--gradient-info); -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text; }
.text-gradient-warning { background: var(--gradient-warning); -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text; }
.text-gradient-danger { background: var(--gradient-danger); -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text; }
.text-gradient-cyan { background: var(--gradient-cyan); -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text; }
.text-gradient-purple { background: var(--gradient-purple); -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text; }

/* Icon backgrounds */
.icon-bg-primary { background: var(--gradient-primary); }
.icon-bg-accent { background: var(--gradient-accent); }
.icon-bg-success { background: var(--gradient-success); }
.icon-bg-info { background: var(--gradient-info); }
.icon-bg-warning { background: var(--gradient-warning); }
.icon-bg-danger { background: var(--gradient-danger); }
.icon-bg-cyan { background: var(--gradient-cyan); }
.icon-bg-purple { background: var(--gradient-purple); }

/* ---- Progress Bar ---- */
.progress-thin {
    height: 6px;
    border-radius: 3px;
    background: var(--border-color);
    overflow: hidden;
    margin-top: 12px;
}

.progress-thin .bar {
    height: 100%;
    border-radius: 3px;
    transition: width 0.6s ease;
}

/* ---- Panel Card ---- */
.panel-card {
    background: var(--bg-card);
    border-radius: 16px;
    box-shadow: var(--shadow-card);
    border: 1px solid var(--border-color);
    transition: var(--transition);
    overflow: hidden;
}

.panel-card .panel-header {
    padding: 18px 22px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.panel-card .panel-header h6 {
    font-weight: 600;
    font-size: 0.95rem;
    display: flex;
    align-items: center;
    gap: 10px;
}

.panel-card .panel-body {
    padding: 22px;
}

/* ---- Table ---- */
.table-custom {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
}

.table-custom thead th {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-secondary);
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-color);
}

.table-custom tbody td {
    padding: 12px 16px;
    font-size: 0.875rem;
    border-bottom: 1px solid var(--border-color);
    color: var(--text-primary);
    vertical-align: middle;
}

.table-custom tbody tr:last-child td {
    border-bottom: none;
}

.table-custom tbody tr:hover td {
    background: rgba(102, 126, 234, 0.04);
}

/* ---- Status Badge ---- */
.status-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
}

.status-running {
    background: rgba(0, 230, 118, 0.12);
    color: #00e676;
}

.status-stopped {
    background: rgba(255, 23, 68, 0.12);
    color: #ff1744;
}

.status-paused {
    background: rgba(255, 171, 0, 0.12);
    color: #ffab00;
}

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

.status-running .dot { animation: pulse-green 2s infinite; }

@keyframes pulse-green {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; }
}

/* ---- Log Container ---- */
.log-container {
    background: var(--log-bg);
    border-radius: 10px;
    padding: 16px;
    max-height: 320px;
    overflow-y: auto;
    font-family: 'JetBrains Mono', 'Fira Code', monospace;
    font-size: 0.78rem;
    line-height: 1.7;
    color: var(--log-text);
}

.log-container .log-line {
    padding: 2px 0;
    border-bottom: 1px solid rgba(128,128,128,0.06);
}

/* ---- Circular Progress ---- */
.circular-progress {
    position: relative;
    width: 90px;
    height: 90px;
}

.circular-progress svg {
    transform: rotate(-90deg);
}

.circular-progress .percentage {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 1.2rem;
    font-weight: 700;
}

/* ---- Info List ---- */
.info-list .info-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 0;
    border-bottom: 1px solid var(--border-color);
}

.info-list .info-item:last-child {
    border-bottom: none;
}

.info-list .info-label {
    font-size: 0.82rem;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: 8px;
}

.info-list .info-label i {
    width: 16px;
    text-align: center;
}

.info-list .info-value {
    font-size: 0.875rem;
    font-weight: 600;
}

/* ---- Network Card ---- */
.net-iface {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 12px;
    background: var(--bg-primary);
    border-radius: 10px;
    margin-bottom: 10px;
}

.net-iface:last-child {
    margin-bottom: 0;
}

.net-iface .iface-icon {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 1rem;
}

.net-iface .iface-name {
    font-weight: 600;
    font-size: 0.875rem;
}

.net-iface .iface-ip {
    font-size: 0.78rem;
    color: var(--text-secondary);
}

/* ---- Dashboard Grid Layouts ---- */
.grid-stats {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 20px;
    margin-bottom: 28px;
}

.grid-info {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 20px;
    margin-bottom: 28px;
}

.grid-bottom {
    display: grid;
    grid-template-columns: 1.4fr 1fr;
    gap: 20px;
}

/* ---- Table Responsive ---- */
.table-responsive {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

/* ---- Sidebar Overlay ---- */
.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 999;
}

.sidebar-overlay.show {
    display: block;
}

/* ---- Mobile Menu Button ---- */
.mobile-menu-btn {
    width: 40px;
    height: 40px;
    border-radius: 12px;
    border: 1px solid var(--border-color);
    background: var(--bg-card);
    color: var(--text-primary);
    display: none;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: var(--transition);
    font-size: 1.1rem;
}

/* ---- Header User Info ---- */
.header-user {
    display: flex;
    align-items: center;
    gap: 8px;
    padding-left: 10px;
    border-left: 1px solid var(--border-color);
}

.header-user .user-avatar {
    width: 32px;
    height: 32px;
    background: var(--gradient-primary);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 0.8rem;
    font-weight: 700;
    flex-shrink: 0;
}

.header-user .user-name {
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--text-primary);
}

/* ---- Responsive ---- */

/* Large tablets / small desktops */
@media (max-width: 1200px) {
    .grid-stats {
        grid-template-columns: repeat(2, 1fr);
    }

    .grid-info {
        grid-template-columns: 1fr 1fr;
    }

    .grid-bottom {
        grid-template-columns: 1fr;
    }
}

/* Tablets */
@media (max-width: 992px) {
    .sidebar {
        transform: translateX(-100%);
        z-index: 1001;
    }

    .sidebar.show {
        transform: translateX(0);
    }

    .top-header {
        left: 0;
        padding: 0 16px;
    }

    .main-content {
        margin-left: 0;
        padding: 20px;
    }

    .mobile-menu-btn {
        display: flex;
    }

    .grid-info {
        grid-template-columns: 1fr;
    }
}

/* Mobile */
@media (max-width: 576px) {
    :root {
        --header-height: 56px;
    }

    .top-header {
        padding: 0 12px;
        gap: 8px;
    }

    .header-left h5 {
        font-size: 0.9rem;
    }

    .header-right {
        gap: 10px;
    }

    .datetime-display .time {
        font-size: 0.85rem;
    }

    .datetime-display .date {
        font-size: 0.68rem;
    }

    .header-user .user-name {
        display: none;
    }

    .header-user {
        padding-left: 8px;
    }

    .theme-toggle {
        width: 36px;
        height: 36px;
        font-size: 0.95rem;
    }

    .mobile-menu-btn {
        width: 36px;
        height: 36px;
        font-size: 0.95rem;
    }

    .main-content {
        padding: 14px;
    }

    .grid-stats {
        grid-template-columns: 1fr 1fr;
        gap: 12px;
        margin-bottom: 16px;
    }

    .stat-card {
        padding: 16px;
        border-radius: 12px;
    }

    .stat-card .card-icon {
        width: 38px;
        height: 38px;
        border-radius: 10px;
        font-size: 1rem;
        margin-bottom: 12px;
    }

    .stat-card .card-value {
        font-size: 1.3rem;
    }

    .stat-card .card-label {
        font-size: 0.7rem;
    }

    .stat-card .card-sub {
        font-size: 0.7rem;
    }

    .grid-info {
        grid-template-columns: 1fr;
        gap: 12px;
        margin-bottom: 16px;
    }

    .grid-bottom {
        grid-template-columns: 1fr;
        gap: 12px;
    }

    .panel-card {
        border-radius: 12px;
    }

    .panel-card .panel-header {
        padding: 14px 16px;
    }

    .panel-card .panel-header h6 {
        font-size: 0.85rem;
    }

    .panel-card .panel-body {
        padding: 16px;
    }

    .table-custom thead th {
        padding: 10px 12px;
        font-size: 0.7rem;
    }

    .table-custom tbody td {
        padding: 10px 12px;
        font-size: 0.8rem;
    }

    .info-list .info-item {
        padding: 8px 0;
    }

    .info-list .info-label {
        font-size: 0.78rem;
    }

    .info-list .info-value {
        font-size: 0.8rem;
    }

    .log-container {
        padding: 12px;
        font-size: 0.72rem;
        max-height: 250px;
    }

    .net-iface {
        padding: 10px;
        gap: 10px;
    }

    .net-iface .iface-icon {
        width: 34px;
        height: 34px;
        font-size: 0.85rem;
    }

    .net-iface .iface-name {
        font-size: 0.8rem;
    }

    .net-iface .iface-ip {
        font-size: 0.72rem;
        word-break: break-all;
    }

    .sidebar {
        width: 260px;
    }
}

/* Extra small */
@media (max-width: 380px) {
    .grid-stats {
        grid-template-columns: 1fr;
    }

    .datetime-display {
        display: none;
    }
}
