:root {
    --bg-color: #ffffff;
    --text-color: #1a1a1a;
    --card-bg: #f8f9fa;
    --border-color: #e9ecef;
    --success-color: #10b981;
    --warning-color: #f59e0b;
    --danger-color: #ef4444;
    --secondary-text: #6b7280;
    --table-header-bg: #f1f5f9;
    --table-hover-bg: #f8fafc;
    --table-border: #e2e8f0;
    --font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    
    /* Column widths for desktop */
    --col-service-width: 10%;
    --col-description-width: 55%;
    --col-status-width: 5%;
}

[data-theme="dark"] {
    --bg-color: #0f0f0f;
    --text-color: #f8fafc;
    --card-bg: #1a1a1a;
    --border-color: #374151;
    --secondary-text: #9ca3af;
    --table-header-bg: #1e293b;
    --table-hover-bg: #334155;
    --table-border: #4b5563;
}

/* ===== BASE STYLES ===== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: var(--font-family);
    background-color: var(--bg-color);
    color: var(--text-color);
    line-height: 1.6;
    font-weight: 400;
    transition: all 0.3s ease;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    width: 100%;
    overflow-x: hidden;
    font-size: 0.9rem; /* Base font size 0.9rem */
}

.container {
    max-width: none;
    margin: 0 7%;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* ===== HEADER STYLES ===== */
.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.5rem 0; /* Top & bottom: 0.5rem */
    border-bottom: 1px solid var(--border-color);
}

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

.logo {
    height: 40px;
}

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

.header-controls {
    display: flex;
    align-items: center;
    gap: 1.5rem;
}

.last-update {
    font-size: 0.9rem;
    color: var(--secondary-text);
    white-space: nowrap;
}

.time-ago {
    font-weight: 500;
    color: var(--text-color);
}

.separator {
    color: var(--border-color);
    font-size: 0.9rem;
}

.refresh-controls {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.refresh-label {
    font-size: 0.9rem;
    color: var(--secondary-text);
    font-weight: 500;
    white-space: nowrap;
}

.refresh-select {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    color: var(--text-color);
    padding: 0.5rem 1rem; /* Top & bottom: 0.5rem */
    border-radius: 6px;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    min-width: 110px;
}

.refresh-select:hover {
    border-color: var(--secondary-text);
}

.refresh-select:focus {
    outline: none;
    border-color: var(--success-color);
}

/* ===== CONTENT STYLES ===== */
.page-description {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 0.5rem 1.5rem; /* Top & bottom: 0.5rem */
    margin: 0.5rem 0; /* Top & bottom: 0.5rem */
}

.page-description p {
    margin: 0;
    color: var(--secondary-text);
    font-size: 0.9rem;
    line-height: 1.5;
}

/* ===== STATUS LEGEND STYLES ===== */
.status-legend {
    display: flex;
    align-items: center;
    gap: 1.5rem;
    margin-bottom: 0.5rem; /* Bottom: 0.5rem */
    padding: 0.5rem 1.5rem; /* Top & bottom: 0.5rem */
    background: var(--card-bg);
    border-radius: 8px;
    border: 1px solid var(--border-color);
}

.legend-title {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--secondary-text);
}

.legend-items {
    display: flex;
    gap: 1.5rem;
    align-items: center;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    position: relative;
    cursor: help;
}

.legend-icon {
    font-size: 1rem;
}

.legend-icon.up {
    color: var(--success-color);
}

.legend-icon.down {
    color: var(--danger-color);
}

.legend-icon.maintenance {
    color: #3b82f6;
}

.legend-text {
    font-size: 0.9rem;
    color: var(--text-color);
    font-weight: 500;
}

/* Tooltip Styles */
.legend-item::before {
    content: attr(data-tooltip);
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.9);
    color: white;
    padding: 0.5rem 0.8rem; /* Top & bottom: 0.5rem */
    border-radius: 8px;
    font-size: 0.9rem;
    font-weight: 400;
    white-space: normal;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
    z-index: 1000;
    pointer-events: none;
    max-width: 200px;
    width: max-content;
    text-align: center;
    line-height: 1.4;
    word-wrap: break-word;
}

.legend-item::after {
    content: '';
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%) translateY(100%);
    border: 5px solid transparent;
    border-top-color: rgba(0, 0, 0, 0.9);
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
    z-index: 1000;
    pointer-events: none;
}

.legend-item:hover::before,
.legend-item:hover::after {
    opacity: 1;
    visibility: visible;
    transform: translateX(-50%) translateY(-5px);
}

.legend-item:hover::after {
    transform: translateX(-50%) translateY(0);
}

[data-theme="dark"] .legend-item::before {
    background: rgba(255, 255, 255, 0.95);
    color: #1a1a1a;
    font-weight: 500;
}

[data-theme="dark"] .legend-item::after {
    border-top-color: rgba(255, 255, 255, 0.95);
}

/* ===== SERVICES TABLE STYLES ===== */
.services-container {
    background: var(--card-bg);
    border-radius: 12px;
    padding: 0;
    margin-bottom: 0.5rem; /* Bottom: 0.5rem */
    border: 1px solid var(--border-color);
    overflow: hidden;
}

.table-wrapper {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    width: 100%;
}

.services-table {
    width: 100%;
    border-collapse: collapse;
    background: var(--bg-color);
    table-layout: fixed;
}

.services-table th {
    background: var(--table-header-bg);
    padding: 0.5rem; /* Top & bottom: 0.5rem */
    font-weight: 700;
    font-size: 0.9rem;
    color: var(--text-color);
    border-bottom: 2px solid var(--table-border);
    letter-spacing: 0.025em;
}

.services-table td {
    padding: 0.5rem; /* Top & bottom: 0.5rem */
    border-bottom: 1px solid var(--table-border);
    vertical-align: middle;
}

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

.services-table tr {
    transition: all 0.2s ease;
}

.services-table tr:hover {
    background: var(--table-hover-bg);
}

/* ===== TABLE COLUMNS - DESKTOP ===== */
.col-service {
    width: var(--col-service-width);
    font-weight: 500;
    font-size: 0.9rem;
    color: var(--text-color);
    text-align: left;
}

.col-description {
    width: var(--col-description-width);
    font-size: 0.9rem;
    color: var(--secondary-text);
    text-align: left;
    line-height: 1.4;
}

.col-status {
    width: var(--col-status-width);
    text-align: center;
    font-size: 1rem;
}

.services-table th.col-status {
    text-align: center;
    font-size: 0.9rem;
}

.services-table th.col-service,
.services-table th.col-description {
    text-align: left;
    font-size: 0.9rem;
}

/* Description Text Styles */
.service-description {
    font-size: 0.9rem;
    color: var(--secondary-text);
    line-height: 1.4;
    max-height: 3.6em;
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
}

.no-description {
    font-style: italic;
    color: var(--secondary-text);
    opacity: 0.7;
    font-size: 0.9rem;
}

/* Status Icons */
.status-icon-cell {
    display: flex;
    align-items: center;
    justify-content: center;
}

.status-icon-only {
    font-size: 1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: all 0.2s ease;
}

.status-icon-only.up {
    color: var(--success-color);
    background: rgba(16, 185, 129, 0.1);
}

.status-icon-only.down {
    color: var(--danger-color);
    background: rgba(239, 68, 68, 0.1);
}

.status-icon-only.maintenance {
    color: #3b82f6;
    background: rgba(59, 130, 246, 0.1);
}

/* ===== MOBILE DROPDOWN STYLES ===== */
.description-dropdown {
    display: none;
    background: var(--card-bg);
    padding: 0.5rem; /* Top & bottom: 0.5rem */
    border-top: 1px solid var(--table-border);
    font-size: 0.9rem;
    color: var(--secondary-text);
    line-height: 1.5;
}

.description-dropdown.show {
    display: table-row;
}

.description-content {
    padding: 0.5rem 0; /* Top & bottom: 0.5rem */
}

.description-content p {
    margin: 0;
}

/* ===== UTILITY STYLES ===== */
.loading-row,
.no-data-row {
    text-align: center;
    color: var(--secondary-text);
    font-style: italic;
    padding: 0.5rem !important; /* Top & bottom: 0.5rem */
    font-size: 0.9rem;
    cursor: default;
}

.loading {
    opacity: 0.7;
    pointer-events: none;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.spin {
    animation: spin 1s linear infinite;
}

/* ===== FOOTER STYLES ===== */
.footer {
    margin-top: auto;
    padding: 0.5rem 0; /* Top & bottom: 0.5rem */
    border-top: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.footer-left p {
    color: var(--secondary-text);
    font-size: 0.9rem;
    font-weight: 400;
}

.footer-right {
    display: flex;
    align-items: center;
}

.btn-theme,
.btn-monitoring {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    color: var(--text-color);
    padding: 0.5rem 1.25rem; /* Top & bottom: 0.5rem */
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.9rem;
    font-weight: 500;
    transition: all 0.2s ease;
}

.btn-theme:hover,
.btn-monitoring:hover {
    background: var(--border-color);
    transform: translateY(-1px);
}

.btn-monitoring {
    margin-right: 0.75rem;
}

/* Monitoring Wall States */
.btn-monitoring.active {
    background: var(--success-color);
    color: white;
    border-color: var(--success-color);
}

.btn-monitoring.active:hover {
    background: #0da271;
    border-color: #0da271;
}

.btn-monitoring.paused {
    background: var(--warning-color);
    color: white;
    border-color: var(--warning-color);
}

.btn-monitoring.paused:hover {
    background: #d97706;
    border-color: #d97706;
}

/* Focus states for accessibility */
.btn-theme:focus,
.btn-monitoring:focus,
.refresh-select:focus {
    outline: 2px solid var(--success-color);
    outline-offset: 2px;
}

/* ===== RESPONSIVE DESIGN ===== */

/* Tablet */
@media (max-width: 1024px) {
    .container {
        margin: 0 5%;
    }
    
    :root {
        --col-service-width: 35%;
        --col-description-width: 50%;
        --col-status-width: 15%;
    }
}

/* Mobile */
@media (max-width: 768px) {
    .container {
        margin: 0 1rem;
        width: calc(100% - 2rem);
    }

    .header {
        flex-direction: row;
        align-items: center;
        padding: 0.5rem 0; /* Top & bottom: 0.5rem */
        gap: 1rem;
    }

    .logo {
        height: 35px;
    }

    /* Sembunyikan refresh controls dan separator di mobile */
    .refresh-controls {
        display: none;
    }

    .separator {
        display: none;
    }

    .header-controls {
        justify-content: flex-end;
    }

    .last-update {
        font-size: 0.9rem;
        white-space: nowrap;
    }

    .page-description {
        margin: 0.5rem 0; /* Top & bottom: 0.5rem */
        padding: 0.5rem 1rem; /* Top & bottom: 0.5rem */
    }

    .status-legend {
        flex-direction: column;
        align-items: flex-start;
        gap: 1rem;
    }

    .legend-items {
        flex-wrap: wrap;
        gap: 1rem;
    }

    /* Mobile Table - Hide description column, show dropdown */
    .col-description {
        display: none;
    }
    
    .services-table {
        table-layout: auto;
        min-width: 300px;
    }

    .services-table th {
        font-size: 0.9rem;
        padding: 0.5rem; /* Top & bottom: 0.5rem */
    }

    .col-service {
        font-size: 0.9rem;
        width: 70%;
        cursor: pointer;
    }

    .col-status {
        font-size: 1rem;
        width: 30%;
    }

    .status-icon-only {
        font-size: 1rem;
    }

    .services-table th,
    .services-table td {
        padding: 0.5rem; /* Top & bottom: 0.5rem */
    }

    .description-dropdown {
        font-size: 0.9rem;
        padding: 0.5rem; /* Top & bottom: 0.5rem */
    }

    .footer {
        flex-direction: column;
        gap: 1rem;
        text-align: center;
    }

    .footer-right {
        justify-content: center;
        width: 100%;
        gap: 0.75rem;
    }
    
    .btn-monitoring,
    .btn-theme {
        padding: 0.5rem 1rem; /* Top & bottom: 0.5rem */
        font-size: 0.9rem;
    }
    
    /* Hide Monitoring Wall on mobile */
    .btn-monitoring {
        display: none;
    }
}

/* Small Mobile */
@media (max-width: 480px) {
    .container {
        margin: 0 0.5rem;
        width: calc(100% - 1rem);
    }

    .header {
        padding: 0.5rem 0; /* Top & bottom: 0.5rem */
        gap: 0.8rem;
    }

    .logo {
        height: 30px;
    }

    .last-update {
        font-size: 0.9rem;
    }

    .page-description {
        margin: 0.5rem 0; /* Top & bottom: 0.5rem */
        padding: 0.5rem 0.8rem; /* Top & bottom: 0.5rem */
    }
    
    .page-description p {
        font-size: 0.9rem;
    }

    .status-legend {
        padding: 0.5rem 1rem; /* Top & bottom: 0.5rem */
    }

    .legend-items {
        gap: 0.8rem;
    }

    .legend-item {
        gap: 0.4rem;
    }

    .legend-icon {
        font-size: 1rem;
    }

    .legend-text {
        font-size: 0.9rem;
    }

    .services-table {
        min-width: 280px;
    }

    .services-table th {
        font-size: 0.9rem;
        padding: 0.5rem; /* Top & bottom: 0.5rem */
    }

    .col-service {
        font-size: 0.9rem;
        width: 65%;
        max-width: 200px;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .col-status {
        font-size: 1rem;
        width: 35%;
    }

    .status-icon-only {
        font-size: 1rem;
    }

    .services-table th,
    .services-table td {
        padding: 0.5rem; /* Top & bottom: 0.5rem */
    }

    .description-dropdown {
        font-size: 0.9rem;
        padding: 0.5rem; /* Top & bottom: 0.5rem */
    }

    .footer-right {
        flex-direction: column;
        width: 100%;
        gap: 0.5rem;
    }
    
    .btn-theme {
        width: 100%;
        justify-content: center;
    }
}

/* Desktop Only Styles */
@media (min-width: 769px) {
    .header-controls {
        display: flex;
        align-items: center;
        gap: 1.5rem;
    }
    
    .refresh-controls {
        display: flex;
    }
    
    .separator {
        display: block;
    }
    
    .btn-monitoring {
        display: flex;
    }
    
    .footer-right {
        gap: 0;
    }
    
    /* Hide dropdown and make rows non-clickable on desktop */
    .description-dropdown {
        display: none !important;
    }
    
    .service-row {
        cursor: default;
    }
}
