/**
 * PM2 EID Dashboard
 * Main Stylesheet
 * 
 * Color Palette:
 * - Primary Red: #dc3545
 * - Dark Red: #a71d2a
 * - Background: #0d0d0d
 * - Surface: #1a1a1a
 * - Surface Light: #2d2d2d
 * - Border: #3d3d3d
 * - Text Primary: #e0e0e0
 * - Text Secondary: #888888
 */

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

html {
    font-size: 14px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    font-family: 'SF Mono', 'Monaco', 'Inconsolata', 'Roboto Mono', 'Consolas', monospace;
    background-color: #0d0d0d;
    color: #e0e0e0;
    line-height: 1.5;
    min-height: 100vh;
}

/* === Layout === */
.dashboard {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

.main {
    flex: 1;
    padding: 1.5rem;
    max-width: 1600px;
    width: 100%;
    margin: 0 auto;
}

/* === Header === */
.header {
    background-color: #1a1a1a;
    border-bottom: 1px solid #3d3d3d;
    padding: 1rem 1.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.header-content {
    display: flex;
    align-items: baseline;
    gap: 1.5rem;
}

.logo {
    font-size: 1.5rem;
    font-weight: 700;
    letter-spacing: -0.5px;
}

.logo .accent {
    color: #dc3545;
}

.header-meta {
    display: flex;
    gap: 1rem;
    font-size: 0.85rem;
    color: #888888;
}

.header-subtitle {
    border-right: 1px solid #3d3d3d;
    padding-right: 1rem;
}

.header-org {
    color: #dc3545;
}

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

/* === Sections === */
.section {
    background-color: #1a1a1a;
    border: 1px solid #3d3d3d;
    border-radius: 4px;
    margin-bottom: 1.5rem;
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid #3d3d3d;
}

.section-header h2 {
    font-size: 1rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* === Process Table === */
.process-table {
    width: 100%;
    border-collapse: collapse;
}

.process-table th,
.process-table td {
    padding: 0.875rem 1rem;
    text-align: left;
    border-bottom: 1px solid #2d2d2d;
}

.process-table th {
    background-color: #141414;
    font-weight: 600;
    text-transform: uppercase;
    font-size: 0.75rem;
    letter-spacing: 0.5px;
    color: #888888;
}

.process-table tbody tr:hover {
    background-color: #222222;
}

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

/* Column widths */
.col-id { width: 50px; }
.col-name { width: auto; }
.col-status { width: 100px; }
.col-cpu { width: 80px; }
.col-memory { width: 100px; }
.col-restarts { width: 80px; }
.col-uptime { width: 100px; }
.col-actions { width: 280px; }

.process-name {
    font-weight: 500;
}

/* === Status Badges === */
.status-badge {
    display: inline-block;
    padding: 0.25rem 0.5rem;
    border-radius: 3px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.status-online {
    background-color: rgba(40, 167, 69, 0.2);
    color: #28a745;
    border: 1px solid rgba(40, 167, 69, 0.3);
}

.status-stopped {
    background-color: rgba(108, 117, 125, 0.2);
    color: #6c757d;
    border: 1px solid rgba(108, 117, 125, 0.3);
}

.status-errored {
    background-color: rgba(220, 53, 69, 0.2);
    color: #dc3545;
    border: 1px solid rgba(220, 53, 69, 0.3);
}

.status-launching {
    background-color: rgba(255, 193, 7, 0.2);
    color: #ffc107;
    border: 1px solid rgba(255, 193, 7, 0.3);
}

.status-unknown {
    background-color: rgba(108, 117, 125, 0.2);
    color: #6c757d;
    border: 1px solid rgba(108, 117, 125, 0.3);
}

/* === Buttons === */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.5rem 0.875rem;
    font-family: inherit;
    font-size: 0.8rem;
    font-weight: 500;
    border: 1px solid #3d3d3d;
    border-radius: 3px;
    background-color: #2d2d2d;
    color: #e0e0e0;
    cursor: pointer;
    transition: all 0.15s ease;
    white-space: nowrap;
}

.btn:hover {
    background-color: #3d3d3d;
    border-color: #4d4d4d;
}

.btn:active {
    transform: translateY(1px);
}

.btn:disabled,
.btn.loading {
    opacity: 0.6;
    cursor: not-allowed;
}

.action-buttons {
    display: flex;
    gap: 0.5rem;
}

/* Button variants */
.btn-start {
    background-color: rgba(40, 167, 69, 0.15);
    border-color: rgba(40, 167, 69, 0.3);
    color: #28a745;
}

.btn-start:hover {
    background-color: rgba(40, 167, 69, 0.25);
    border-color: rgba(40, 167, 69, 0.5);
}

.btn-stop {
    background-color: rgba(255, 193, 7, 0.15);
    border-color: rgba(255, 193, 7, 0.3);
    color: #ffc107;
}

.btn-stop:hover {
    background-color: rgba(255, 193, 7, 0.25);
    border-color: rgba(255, 193, 7, 0.5);
}

.btn-restart {
    background-color: rgba(0, 123, 255, 0.15);
    border-color: rgba(0, 123, 255, 0.3);
    color: #007bff;
}

.btn-restart:hover {
    background-color: rgba(0, 123, 255, 0.25);
    border-color: rgba(0, 123, 255, 0.5);
}

.btn-delete {
    background-color: rgba(220, 53, 69, 0.15);
    border-color: rgba(220, 53, 69, 0.3);
    color: #dc3545;
}

.btn-delete:hover {
    background-color: rgba(220, 53, 69, 0.25);
    border-color: rgba(220, 53, 69, 0.5);
}

.btn-logs {
    background-color: rgba(108, 117, 125, 0.15);
    border-color: rgba(108, 117, 125, 0.3);
    color: #adb5bd;
}

.btn-logs:hover {
    background-color: rgba(108, 117, 125, 0.25);
    border-color: rgba(108, 117, 125, 0.5);
}

.btn-refresh {
    background-color: rgba(220, 53, 69, 0.15);
    border-color: rgba(220, 53, 69, 0.3);
    color: #dc3545;
}

.btn-refresh:hover {
    background-color: rgba(220, 53, 69, 0.25);
    border-color: rgba(220, 53, 69, 0.5);
}

.btn-secondary {
    background-color: #2d2d2d;
    border-color: #3d3d3d;
    color: #888888;
}

.btn-secondary:hover {
    background-color: #3d3d3d;
    color: #e0e0e0;
}

.btn-tab {
    background-color: transparent;
    border-color: transparent;
    color: #888888;
    padding: 0.375rem 0.75rem;
}

.btn-tab:hover {
    color: #e0e0e0;
    background-color: transparent;
    border-color: transparent;
}

.btn-tab.active {
    color: #dc3545;
    border-bottom: 2px solid #dc3545;
    border-radius: 0;
}

/* === Logs Section === */
.logs-section {
    position: sticky;
    bottom: 0;
}

.logs-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.logs-container {
    max-height: 400px;
    overflow: hidden;
}

.logs-content {
    height: 400px;
    overflow-y: auto;
    padding: 1rem;
}

.log-content {
    font-family: 'SF Mono', 'Monaco', 'Inconsolata', 'Roboto Mono', 'Consolas', monospace;
    font-size: 0.8rem;
    line-height: 1.6;
    white-space: pre-wrap;
    word-wrap: break-word;
    margin: 0;
    color: #adb5bd;
}

.log-content.log-error {
    color: #dc3545;
}

.log-content.log-stdout {
    color: #adb5bd;
}

/* === States === */
.empty-state,
.loading-state {
    padding: 3rem 2rem;
    text-align: center;
    color: #888888;
}

.empty-state p,
.loading-state p {
    margin: 0.5rem 0;
}

.hint {
    font-size: 0.85rem;
    color: #6c757d;
}

/* === Alerts === */
.alert {
    padding: 1rem;
    border-radius: 3px;
    margin: 1rem;
}

.alert-error {
    background-color: rgba(220, 53, 69, 0.15);
    border: 1px solid rgba(220, 53, 69, 0.3);
    color: #dc3545;
}

.alert-success {
    background-color: rgba(40, 167, 69, 0.15);
    border: 1px solid rgba(40, 167, 69, 0.3);
    color: #28a745;
}

/* === HTMX Indicator === */
.htmx-indicator {
    display: none;
    color: #888888;
    font-size: 0.85rem;
}

.htmx-request .htmx-indicator,
.htmx-request.htmx-indicator {
    display: inline-block;
}

/* === Auto Refresh Toggle === */
.auto-refresh {
    display: flex;
    align-items: center;
    font-size: 0.85rem;
    color: #888888;
}

.auto-refresh label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
}

.auto-refresh input[type="checkbox"] {
    appearance: none;
    width: 16px;
    height: 16px;
    border: 1px solid #3d3d3d;
    border-radius: 3px;
    background-color: #2d2d2d;
    cursor: pointer;
    position: relative;
}

.auto-refresh input[type="checkbox"]:checked {
    background-color: #dc3545;
    border-color: #dc3545;
}

.auto-refresh input[type="checkbox"]:checked::after {
    content: '';
    position: absolute;
    left: 4px;
    top: 1px;
    width: 5px;
    height: 9px;
    border: solid #fff;
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
}

/* === Footer === */
.footer {
    background-color: #141414;
    border-top: 1px solid #3d3d3d;
    padding: 0.75rem 1.5rem;
    font-size: 0.75rem;
    color: #6c757d;
}

.footer-content {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.separator {
    color: #3d3d3d;
}

/* === Scrollbar === */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: #1a1a1a;
}

::-webkit-scrollbar-thumb {
    background: #3d3d3d;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: #4d4d4d;
}

/* === Responsive === */
@media (max-width: 1200px) {
    .col-actions {
        width: auto;
    }
    
    .action-buttons {
        flex-wrap: wrap;
    }
}

@media (max-width: 900px) {
    .header {
        flex-direction: column;
        gap: 1rem;
        align-items: flex-start;
    }
    
    .header-content {
        flex-direction: column;
        gap: 0.5rem;
    }
    
    .header-meta {
        flex-direction: column;
        gap: 0.25rem;
    }
    
    .header-subtitle {
        border-right: none;
        padding-right: 0;
    }
    
    .process-table {
        font-size: 0.85rem;
    }
    
    .process-table th,
    .process-table td {
        padding: 0.75rem 0.5rem;
    }
    
    .col-uptime,
    .col-restarts {
        display: none;
    }
}

@media (max-width: 600px) {
    .main {
        padding: 1rem;
    }
    
    .section-header {
        flex-direction: column;
        gap: 0.75rem;
        align-items: flex-start;
    }
    
    .btn {
        padding: 0.4rem 0.6rem;
        font-size: 0.75rem;
    }
    
    .action-buttons {
        gap: 0.25rem;
    }
    
    .col-cpu,
    .col-memory {
        display: none;
    }
}
