/* Reset & Base */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary: #3b82f6;
    --primary-dark: #2563eb;
    --success: #22c55e;
    --warning: #f59e0b;
    --danger: #ef4444;
    --dark: #1e293b;
    --light: #f1f5f9;
    --gray: #64748b;
    --card-bg: #ffffff;
    --border: #e2e8f0;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background-color: var(--light);
    color: var(--dark);
    line-height: 1.5;
}

/* Header */
.header {
    background: var(--dark);
    color: white;
    padding: 1rem 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 100;
}

.header h1 {
    font-size: 1.5rem;
    font-weight: 600;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.hostname {
    background: var(--primary);
    padding: 0.25rem 0.75rem;
    border-radius: 4px;
    font-size: 0.875rem;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 1rem;
    font-size: 0.875rem;
}

.last-update {
    color: var(--gray);
}

/* Main Content */
.main-content {
    max-width: 1600px;
    margin: 0 auto;
    padding: 2rem;
}

/* Section */
.section {
    margin-bottom: 2rem;
}

.section h2 {
    font-size: 1.25rem;
    margin-bottom: 1rem;
    color: var(--dark);
}

/* Cards */
.card {
    background: var(--card-bg);
    border-radius: 8px;
    padding: 1.5rem;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.card h3 {
    font-size: 1rem;
    color: var(--gray);
    margin-bottom: 1rem;
}

/* Grid */
.grid {
    display: grid;
    gap: 1rem;
}

.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }

@media (max-width: 1200px) {
    .grid-4 { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 768px) {
    .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
}

/* Gauge */
.gauge-container {
    position: relative;
    width: 120px;
    height: 120px;
    margin: 0 auto;
}

.gauge-value {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 1.5rem;
    font-weight: 700;
}

/* Status */
.status-indicator {
    display: inline-block;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    margin-right: 0.5rem;
}

.status-running .status-indicator { background: var(--success); }
.status-stopped .status-indicator { background: var(--danger); }

.status-badge {
    display: inline-block;
    padding: 0.25rem 0.75rem;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
}

.status-badge.running { background: var(--success); color: white; }
.status-badge.stopped { background: var(--danger); color: white; }

/* Services Grid */
.services-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 1rem;
}

.service-card {
    background: var(--card-bg);
    border-radius: 8px;
    padding: 1rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.service-card.running { border-left: 4px solid var(--success); }
.service-card.stopped { border-left: 4px solid var(--danger); }

.service-name {
    font-weight: 500;
    font-size: 0.875rem;
}

/* Components Grid (GitLab) */
.components-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 0.75rem;
}

.component-card {
    background: var(--card-bg);
    border-radius: 6px;
    padding: 0.75rem 1rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 0.875rem;
}

.component-card.running { border-left: 3px solid var(--success); }
.component-card.stopped { border-left: 3px solid var(--danger); }

/* Disk */
.disk-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 1rem;
}

.disk-card {
    background: var(--card-bg);
    border-radius: 8px;
    padding: 1rem;
}

.disk-bar {
    height: 8px;
    background: var(--light);
    border-radius: 4px;
    overflow: hidden;
    margin: 0.5rem 0;
}

.disk-bar-fill {
    height: 100%;
    background: var(--primary);
    transition: width 0.3s;
}

.disk-bar-fill.warning { background: var(--warning); }
.disk-bar-fill.danger { background: var(--danger); }

/* Ports Grid */
.ports-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 0.75rem;
}

.port-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem;
    background: var(--light);
    border-radius: 4px;
}

.port-item.active { background: #dcfce7; }
.port-item.inactive { background: #fee2e2; }

/* Alerts */
.alerts-section {
    background: #fef3c7;
    border: 1px solid #f59e0b;
    border-radius: 8px;
    padding: 1rem;
    margin-bottom: 2rem;
}

.alerts-section.hidden { display: none; }

.alert-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem;
    background: white;
    border-radius: 4px;
    margin-bottom: 0.5rem;
}

.alert-item.critical { border-left: 4px solid var(--danger); }
.alert-item.warning { border-left: 4px solid var(--warning); }

/* Buttons */
.btn {
    display: inline-block;
    padding: 0.5rem 1rem;
    border-radius: 6px;
    border: none;
    cursor: pointer;
    font-size: 0.875rem;
    font-weight: 500;
    text-decoration: none;
    transition: background 0.2s;
}

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

.btn-primary:hover { background: var(--primary-dark); }

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

.btn-sm {
    padding: 0.25rem 0.75rem;
    font-size: 0.75rem;
}

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

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
}

.form-group input,
.form-group select {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 1rem;
}

.form-inline {
    display: flex;
    gap: 1rem;
    align-items: flex-end;
    flex-wrap: wrap;
}

.form-inline .form-group {
    margin-bottom: 0;
}

/* Tables */
.table {
    width: 100%;
    border-collapse: collapse;
}

.table th,
.table td {
    padding: 0.75rem;
    text-align: left;
    border-bottom: 1px solid var(--border);
}

.table th {
    background: var(--light);
    font-weight: 600;
}

/* Alerts */
.alert {
    padding: 0.75rem 1rem;
    border-radius: 6px;
    margin-bottom: 1rem;
}

.alert-error {
    background: #fee2e2;
    color: #b91c1c;
}

.alert-success {
    background: #dcfce7;
    color: #166534;
}

/* Badge */
.badge {
    display: inline-block;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    font-size: 0.75rem;
}

.badge-primary { background: var(--primary); color: white; }
.badge-secondary { background: var(--gray); color: white; }

/* Login Page */
.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--dark) 0%, #334155 100%);
}

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

.login-box {
    background: white;
    padding: 2rem;
    border-radius: 12px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.2);
}

.login-box h1 {
    text-align: center;
    margin-bottom: 0.5rem;
}

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

/* Utilities */
.mt-2 { margin-top: 1rem; }
.hidden { display: none; }

/* Footer */
.footer {
    text-align: center;
    padding: 2rem;
    color: var(--gray);
    font-size: 0.875rem;
}

/* GitLab Header */
.gitlab-header {
    display: flex;
    justify-content: space-between;
    margin-bottom: 1rem;
    padding: 0.75rem;
    background: var(--card-bg);
    border-radius: 6px;
}

.health-status.healthy { color: var(--success); }
.health-status.unhealthy { color: var(--danger); }

/* DB Info */
.db-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.db-info {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1rem;
    margin-bottom: 1rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--border);
}

.db-info-grid {
    display: grid;
    gap: 0.75rem;
}

.db-info-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.5rem 0;
    border-bottom: 1px solid var(--border);
}

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

.db-info-item .label {
    color: var(--gray);
    font-size: 0.875rem;
}

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

.db-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 0.5rem;
}

.db-item {
    display: flex;
    justify-content: space-between;
    padding: 0.75rem;
    background: var(--light);
    border-radius: 4px;
}

.db-item .db-name {
    font-weight: 500;
}

.db-item .db-size {
    color: var(--gray);
    font-size: 0.875rem;
}

.db-item .db-connections {
    background: var(--primary);
    color: white;
    padding: 0.1rem 0.4rem;
    border-radius: 10px;
    font-size: 0.7rem;
    margin-left: 0.5rem;
}

/* Session Status */
.session-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 0.75rem;
}

.session-item {
    text-align: center;
    padding: 0.75rem;
    background: var(--light);
    border-radius: 6px;
}

.session-item.active {
    background: #dcfce7;
    border-left: 3px solid var(--success);
}

.session-item.idle {
    background: #e0f2fe;
    border-left: 3px solid #3b82f6;
}

.session-item.idle-tx {
    background: #fef3c7;
    border-left: 3px solid var(--warning);
}

.session-item.waiting {
    background: #fee2e2;
    border-left: 3px solid var(--danger);
}

.session-count {
    display: block;
    font-size: 1.5rem;
    font-weight: 700;
}

.session-label {
    display: block;
    font-size: 0.7rem;
    color: var(--gray);
    margin-top: 0.25rem;
}

/* Uptime */
.uptime-display {
    font-size: 1.75rem;
    font-weight: 700;
    text-align: center;
    color: var(--primary);
}

/* Network */
.network-stats {
    font-size: 1rem;
}

.network-stats .label {
    color: var(--gray);
}

.net-speed {
    font-size: 0.75rem;
    color: var(--primary);
    font-weight: 500;
}

/* Refresh Indicator */
.refresh-indicator {
    font-size: 0.75rem;
    color: var(--gray);
    transition: color 0.2s;
}

/* Section Badge (count) */
.section h2 .badge {
    background: var(--primary);
    color: white;
    padding: 0.25rem 0.75rem;
    border-radius: 12px;
    font-size: 0.875rem;
    font-weight: 600;
    margin-left: 0.5rem;
}

/* Websites Grid */
.websites-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1rem;
}

.website-card {
    background: var(--card-bg);
    border-radius: 8px;
    padding: 1rem;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    transition: transform 0.2s, box-shadow 0.2s;
}

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

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

.website-domain {
    font-weight: 600;
    color: var(--primary);
    text-decoration: none;
    font-size: 0.9rem;
}

.website-domain:hover {
    text-decoration: underline;
}

.ssl-badge {
    padding: 0.2rem 0.5rem;
    border-radius: 4px;
    font-size: 0.7rem;
    font-weight: 600;
}

.ssl-badge.ssl-yes {
    background: #dcfce7;
    color: var(--success);
}

.ssl-badge.ssl-no {
    background: #fee2e2;
    color: var(--danger);
}

.website-info {
    font-size: 0.8rem;
    color: var(--gray);
}

.website-user {
    display: inline-block;
    background: var(--light);
    padding: 0.2rem 0.5rem;
    border-radius: 4px;
}

/* Service Category */
.service-category {
    background: var(--card-bg);
    border-radius: 8px;
    padding: 1rem;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.service-category h4 {
    color: var(--gray);
    font-size: 0.75rem;
    margin-bottom: 0.75rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--border);
}

/* Network Chart Container */
#network-chart {
    height: 150px !important;
}

/* Settings Page */
.account-info {
    display: grid;
    gap: 0.75rem;
}

.info-row {
    display: flex;
    justify-content: space-between;
    padding: 0.75rem;
    background: var(--light);
    border-radius: 4px;
}

.info-row .label {
    color: var(--gray);
}

.info-row .value {
    font-weight: 600;
}
