:root {
    --primary-color: #3b82f6;
    --success-color: #10b981;
    --warning-color: #f59e0b;
    --danger-color: #ef4444;
    --gray-50: #f9fafb;
    --gray-100: #f3f4f6;
    --gray-200: #e5e7eb;
    --gray-300: #d1d5db;
    --gray-400: #9ca3af;
    --gray-500: #6b7280;
    --gray-600: #4b5563;
    --gray-700: #374151;
    --gray-800: #1f2937;
    --gray-900: #111827;
    --border-radius: 8px;
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    padding: 1.5rem 1rem;
    color: var(--gray-900);
}

/* Navbar */
.navbar {
    background: white;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    padding: 1rem 0;
    margin-bottom: 1.5rem;
    border-radius: var(--border-radius);
}

.container {
    max-width: 1600px;
    margin: 0 auto;
    padding: 0 1rem;
}

.navbar-brand h1 {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--primary-color);
}

.navbar-menu {
    display: flex;
    gap: 1.5rem;
    margin-top: 0.75rem;
    align-items: center;
    justify-content: space-between;
}

.nav-link {
    color: var(--gray-700);
    text-decoration: none;
    font-weight: 500;
    transition: color 0.2s;
}

.nav-link:hover {
    color: var(--primary-color);
}

/* Dropdown */
.dropdown {
    position: relative;
    display: inline-block;
}

.dropdown-toggle {
    background: none;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: inherit;
    font-family: inherit;
    padding: 0;
}

.dropdown-toggle svg {
    transition: transform 0.2s;
}

.dropdown.show .dropdown-toggle svg {
    transform: rotate(180deg);
}

.dropdown-menu {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    background: white;
    min-width: 160px;
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.1);
    border-radius: var(--border-radius);
    z-index: 1000;
    margin-top: 0.5rem;
    border: 1px solid var(--gray-200);
}

.dropdown-menu.show {
    display: block;
}

.dropdown-item {
    display: block;
    padding: 0.75rem 1rem;
    color: var(--gray-700);
    text-decoration: none;
    transition: background-color 0.2s;
    border-bottom: 1px solid var(--gray-100);
}

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

.dropdown-item:hover {
    background-color: var(--gray-50);
    color: var(--primary-color);
}

/* User Info */
.user-info {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-left: auto;
    padding: 0.5rem 1rem;
    background: var(--gray-50);
    border-radius: var(--border-radius);
    transition: all 0.2s;
}

.user-info:hover {
    background: var(--gray-100);
}

.user-avatar-container {
    position: relative;
    width: 40px;
    height: 40px;
    flex-shrink: 0;
}

.user-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: 2px solid var(--primary-color);
    object-fit: cover;
    background-color: white;
    display: block;
    position: absolute;
    top: 0;
    left: 0;
}

.user-avatar-placeholder {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--primary-color);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 1.25rem;
    text-transform: uppercase;
    flex-shrink: 0;
    position: absolute;
    top: 0;
    left: 0;
}

.user-details {
    display: flex;
    flex-direction: column;
    gap: 0.125rem;
}

.user-name {
    font-weight: 600;
    color: var(--gray-900);
    font-size: 0.875rem;
}

.user-email {
    font-size: 0.75rem;
    color: var(--gray-600);
}

.logout-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0.5rem;
    border-radius: 6px;
    background: transparent;
    color: var(--gray-600);
    text-decoration: none;
    transition: all 0.2s;
    margin-left: 0.5rem;
}

.logout-btn:hover {
    background: var(--danger-color);
    color: white;
    transform: translateX(2px);
}

.logout-btn svg {
    width: 20px;
    height: 20px;
}

/* Responsive */
@media (max-width: 768px) {
    .navbar-menu {
        flex-direction: column;
        align-items: flex-start;
    }
    
    .user-info {
        margin-left: 0;
        width: 100%;
    }
    
    .user-details {
        flex: 1;
    }
}

/* Loading */
.loading {
    text-align: center;
    padding: 3rem;
    color: white;
    font-size: 1.125rem;
}

.spinner {
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-top-color: white;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    animation: spin 1s linear infinite;
    margin: 0 auto 1rem;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Projects Grid */
#projects-container {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1.5rem;
    max-width: 1600px;
    margin: 0 auto;
}

/* Project Card */
.project-card {
    background: white;
    border-radius: var(--border-radius);
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    overflow: hidden;
    transition: transform 0.2s, box-shadow 0.2s;
}

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

.project-header {
    background: linear-gradient(135deg, var(--primary-color) 0%, #2563eb 100%);
    color: white;
    padding: 1rem 1.25rem;
}

.project-header h3 {
    font-size: 1.25rem;
    font-weight: 700;
    margin-bottom: 0.25rem;
}

.project-description {
    font-size: 0.875rem;
    opacity: 0.95;
}

.applications-list {
    padding: 1rem;
}

/* Application Container */
.app-container {
    background: var(--gray-50);
    border-radius: 6px;
    padding: 1rem;
    margin-bottom: 1rem;
    border: 1px solid var(--gray-200);
}

.app-container:last-child {
    margin-bottom: 0;
}

/* App Header */
.app-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    padding-bottom: 0.75rem;
    border-bottom: 2px solid var(--gray-300);
}

.app-info {
    flex: 1;
}

.app-name {
    font-size: 1.125rem;
    font-weight: 700;
    color: var(--gray-900);
    margin-bottom: 0.25rem;
}

.app-namespace {
    font-size: 0.75rem;
    color: var(--gray-500);
    font-family: 'Monaco', 'Courier New', monospace;
}

.app-nodes {
    display: flex;
    gap: 0.5rem;
}

.node-badges {
    display: flex;
    gap: 0.375rem;
    flex-wrap: wrap;
}

.node-label {
    background-color: var(--success-color);
    color: white;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    font-size: 0.7rem;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    cursor: help;
    white-space: nowrap;
}

.node-label.node-not-ready {
    background-color: var(--danger-color);
}

.node-label.node-unknown {
    background-color: var(--gray-500);
}

.node-count {
    background-color: rgba(0, 0, 0, 0.2);
    padding: 0.1rem 0.3rem;
    border-radius: 3px;
    font-size: 0.65rem;
}

/* Metrics Grid - HORIZONTAL LAYOUT */
.metrics-grid {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-start;
    /* Prevent cards in the same row from stretching to tallest height */
    align-items: flex-start;
    gap: 0.75rem;
}

/* Metric Card - COMPACT */
.metric-card {
    background: white;
    border-radius: 6px;
    padding: 0.75rem;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
    transition: all 0.2s;
    border: 1px solid var(--gray-200);
    display: flex;
    flex-direction: column;
    /* Largura automática até 300px, ajustando ao conteúdo */
    width: auto;
    max-width: 300px;
    box-sizing: border-box;
    flex: 0 0 auto;
}

/* Fixar tamanho de 200px para métricas de recursos (CPU/Memória/Disco) */
.metric-card.resource-card {
    width: 200px;
    min-width: 200px;
    max-width: 200px;
}

.metric-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 3px 8px rgba(0, 0, 0, 0.12);
    border-color: var(--primary-color);
}

.metric-card-label {
    display: flex;
    align-items: center;
    gap: 0.375rem;
    font-size: 0.65rem;
    font-weight: 700;
    color: var(--gray-600);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 0.625rem;
    /* Allow label text to wrap within constrained width */
    flex-wrap: wrap;
    /* Ensure flex children can shrink and wrap */
    min-width: 0;
}

/* Constrain the label text (excluding icon) and enable wrapping */
.metric-card-label span:not(.metric-icon) {
    display: block;
    max-width: 300px;
    white-space: normal;
    word-break: break-word;
    overflow-wrap: anywhere;
    /* Avoid truncation inside flex */
    overflow: visible;
    min-width: 0;
}

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

.metric-card-content {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    flex: 1;
}

/* Pod Indicators */
.pod-indicators {
    display: flex;
    gap: 0.375rem;
    flex-wrap: wrap;
}

.pod-count {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    font-weight: 700;
    cursor: help;
    line-height: 1;
    text-align: center;
}

.pod-running {
    background-color: var(--success-color);
    color: white;
}

.pod-warning {
    background-color: var(--warning-color);
    color: white;
}

.pod-pending {
    background-color: var(--gray-300);
    color: var(--gray-700);
}

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

.pod-count-more {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.7rem;
    font-weight: 700;
    background-color: var(--gray-200);
    color: var(--gray-600);
    line-height: 1;
    text-align: center;
}

/* Status Badge - COMPACT */
.status-badge {
    display: flex;
    align-items: center;
    gap: 0.375rem;
    padding: 0.4rem 0.625rem;
    border-radius: 5px;
    font-size: 0.75rem;
    font-weight: 600;
    cursor: help;
}

.status-ok {
    background-color: #d1fae5;
    color: #065f46;
    border: 1.5px solid var(--success-color);
}

.status-warning {
    background-color: #fef3c7;
    color: #92400e;
    border: 1.5px solid var(--warning-color);
}

.status-error {
    background-color: #fee2e2;
    color: #991b1b;
    border: 1.5px solid var(--danger-color);
}

.status-unknown {
    background-color: var(--gray-100);
    color: var(--gray-600);
    border: 1.5px solid var(--gray-300);
}

.status-icon {
    font-size: 0.9rem;
    line-height: 1;
}

.status-text {
    flex: 1;
    font-size: 0.7rem;
}

.status-time {
    font-size: 0.7rem;
    opacity: 0.8;
}

/* Resource Bar - COMPACT */
.resource-bar-container {
    display: flex;
    align-items: center;
    gap: 0.375rem;
    cursor: help;
}

.resource-bar {
    flex: 1;
    height: 6px;
    background-color: var(--gray-200);
    border-radius: 3px;
    overflow: hidden;
}

.resource-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--success-color) 0%, var(--warning-color) 70%, var(--danger-color) 100%);
    transition: width 0.3s ease;
    border-radius: 3px;
}

.resource-value {
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--gray-700);
    min-width: 38px;
    text-align: right;
}

/* Metric Detail */
.metric-detail {
    font-size: 0.65rem;
    color: var(--gray-500);
    font-family: 'Monaco', 'Courier New', monospace;
    /* Permitir quebra de linha para URLs longas */
    white-space: normal;
    word-break: break-word;
    overflow-wrap: anywhere;
    line-height: 1.2;
}

/* Kafka card specific tweaks: increase max width and compact fonts */
.metric-card.kafka-card {
    /* Make Kafka card occupy a full isolated row */
    flex: 1 0 100%;
    width: 100%;
    max-width: none;
}

.kafka-card .metric-card-content {
    font-size: 0.75rem;
}

/* Kafka columns layout: show multiple small tables side by side */
.kafka-columns {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.kafka-table {
    flex: 1 1 300px;
    max-width: 380px;
}

/* Table styling for Kafka group lags with wrapping */
.metric-table-container {
    overflow-x: auto;
    /* Constrain height to avoid overly tall card; enable vertical scrolling */
    max-height: 320px;
    overflow-y: auto;
}

.metric-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.75rem;
}

.metric-table th,
.metric-table td {
    padding: 0.25rem 0.375rem;
    text-align: left;
    vertical-align: top;
    word-break: break-word;
    overflow-wrap: anywhere;
}

.metric-table thead th {
    color: var(--gray-600);
    font-weight: 700;
    border-bottom: 1px solid var(--gray-200);
}

.metric-table tbody tr + tr {
    border-top: 1px dashed var(--gray-200);
}

.metric-no-data {
    font-size: 0.75rem;
    color: var(--gray-400);
    font-style: italic;
}

/* Connections Section */
.connections-section {
    margin-top: 0.75rem;
    padding: 0.875rem;
    background: white;
    border-radius: 6px;
    border: 1px solid var(--gray-200);
}

.connections-header {
    display: flex;
    align-items: center;
    gap: 0.375rem;
    font-size: 0.65rem;
    font-weight: 700;
    color: var(--gray-600);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 0.625rem;
}

.connections-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: 0.625rem;
}

/* Connection Card - COMPACT */
.connection-card {
    background: var(--gray-50);
    border-radius: 5px;
    padding: 0.625rem;
    border: 1px solid var(--gray-200);
}

.connection-label {
    font-size: 0.65rem;
    font-weight: 600;
    color: var(--gray-600);
    text-transform: uppercase;
    margin-bottom: 0.375rem;
    letter-spacing: 0.3px;
}

.connection-status {
    display: flex;
    align-items: center;
    gap: 0.3rem;
    padding: 0.3rem 0.4rem;
    border-radius: 4px;
    font-size: 0.7rem;
    font-weight: 600;
    cursor: help;
}

/* Responsive Breakpoints */
@media (max-width: 1400px) {
    .metrics-grid {
        grid-template-columns: repeat(auto-fill, minmax(300px, 300px));
    }
}

@media (max-width: 1100px) {
    .metrics-grid {
        grid-template-columns: repeat(auto-fill, minmax(300px, 300px));
    }
}

@media (max-width: 768px) {
    body {
        padding: 1rem 0.5rem;
    }
    
    .metrics-grid {
        grid-template-columns: repeat(auto-fill, minmax(300px, 300px));
    }
    
    .app-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
    }
}

@media (max-width: 480px) {
    .metrics-grid {
        grid-template-columns: repeat(auto-fill, minmax(300px, 300px));
    }
    
    .connections-grid {
        grid-template-columns: 1fr;
    }
}

/* Animations */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.app-container {
    animation: fadeIn 0.3s ease-out;
}

/* Footer */
.footer {
    background: rgba(255, 255, 255, 0.1);
    color: white;
    text-align: center;
    padding: 1rem 0;
    margin-top: 2rem;
    border-radius: var(--border-radius);
}

/* Form Styles */
.form-container {
    max-width: 1300px;
    margin: 0 auto;
}

.form-header {
    text-align: center;
    margin-bottom: 2rem;
    color: white;
}

.form-header h2 {
    font-size: 2rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
}

.form-header p {
    font-size: 1.125rem;
    opacity: 0.9;
}

.form-card {
    background: white;
    border-radius: var(--border-radius);
    padding: 2rem;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    margin-bottom: 2rem;
}

.form-group {
    margin-bottom: 1.5rem;
}

.form-group label {
    display: block;
    font-weight: 600;
    color: var(--gray-700);
    margin-bottom: 0.5rem;
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 0.75rem;
    border: 2px solid var(--gray-200);
    border-radius: var(--border-radius);
    font-size: 1rem;
    transition: border-color 0.2s, box-shadow 0.2s;
}

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

.form-group textarea {
    resize: vertical;
    min-height: 80px;
}

.form-actions {
    display: flex;
    gap: 1rem;
    justify-content: flex-end;
    margin-top: 2rem;
}

.btn {
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: var(--border-radius);
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

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

.btn-primary:hover {
    background: #2563eb;
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(59, 130, 246, 0.3);
}

.btn-secondary {
    background: var(--gray-200);
    color: var(--gray-700);
}

.btn-secondary:hover {
    background: var(--gray-300);
}

.result-container {
    margin-top: 1rem;
}

.alert {
    padding: 1rem;
    border-radius: var(--border-radius);
    margin-bottom: 1rem;
    font-weight: 500;
}

.alert-success {
    background: #d1fae5;
    color: #065f46;
    border: 1px solid #a7f3d0;
}

.alert-error {
    background: #fee2e2;
    color: #991b1b;
    border: 1px solid #fecaca;
}

.projects-list,
.applications-list,
.metrics-list {
    background: white;
    border-radius: var(--border-radius);
    padding: 2rem;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.projects-list h3,
.applications-list h3,
.metrics-list h3 {
    color: var(--gray-800);
    margin-bottom: 1.5rem;
    font-size: 1.25rem;
}

.list-item {
    padding: 1rem;
    border: 1px solid var(--gray-200);
    border-radius: var(--border-radius);
    margin-bottom: 1rem;
    transition: all 0.2s;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
}

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

.list-item-content {
    flex: 1;
}

.list-item-actions {
    margin-left: 1rem;
    display: flex;
    gap: 0.5rem;
}

.list-item h4 {
    color: var(--gray-800);
    margin-bottom: 0.5rem;
}

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

.btn-sm {
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
}

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

.btn-danger:hover {
    background: #dc2626;
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(239, 68, 68, 0.3);
}

.dropdown-item.active {
    background-color: var(--primary-color);
    color: white;
}

.dropdown-item.active:hover {
    background-color: #2563eb;
    color: white;
}

@media (max-width: 768px) {
    .form-actions {
        flex-direction: column;
    }
    
    .btn {
        width: 100%;
    }
}
