:root {
    --primary-color: #2c3e50;
    --success-color: #4CAF50;
    --danger-color: #FF6B6B;
    --warning-color: #FFA500;
    --info-color: #3498db;
    --light-bg: #f5f5f5;
    --light-text: #333333;
    --dark-bg: #1e1e1e;
    --dark-text: #e0e0e0;
    --border-color: #ddd;
    --shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.dark-mode {
    --light-bg: #1e1e1e;
    --light-text: #e0e0e0;
    --border-color: #333;
    --shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background-color: var(--light-bg);
    color: var(--light-text);
    transition: background-color 0.3s, color 0.3s;
    line-height: 1.6;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
}

/* Navbar */
.navbar {
    background-color: var(--primary-color);
    color: white;
    padding: 1rem 0;
    box-shadow: var(--shadow);
    margin-bottom: 2rem;
}

.navbar .container {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.navbar-brand h1 {
    font-size: 1.5rem;
}

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

.user-info {
    font-size: 0.9rem;
}

/* Main Content */
.main-content {
    padding-bottom: 2rem;
}

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

.header h2 {
    font-size: 2rem;
}

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

/* Buttons */
.btn {
    display: inline-block;
    padding: 0.5rem 1rem;
    background-color: var(--primary-color);
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    text-decoration: none;
    font-size: 0.9rem;
    transition: background-color 0.3s;
}

.btn:hover {
    background-color: #1a252f;
}

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

.btn-primary:hover {
    background-color: #2980b9;
}

.btn-secondary {
    background-color: #95a5a6;
}

.btn-secondary:hover {
    background-color: #7f8c8d;
}

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

.btn-danger:hover {
    background-color: #e55039;
}

.btn-outline {
    background-color: transparent;
    border: 1px solid var(--border-color);
    color: var(--light-text);
}

.btn-outline:hover {
    background-color: var(--light-bg);
}

.btn-sm {
    padding: 0.3rem 0.8rem;
    font-size: 0.85rem;
}

/* Stats Grid */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 1rem;
    margin-bottom: 2rem;
}

.stat-card {
    background: white;
    padding: 1.5rem;
    border-radius: 8px;
    box-shadow: var(--shadow);
    text-align: center;
    transition: transform 0.3s, box-shadow 0.3s;
}

.dark-mode .stat-card {
    background: #2a2a2a;
}

.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2);
}

.stat-card h3 {
    font-size: 0.85rem;
    text-transform: uppercase;
    color: #666;
    margin-bottom: 0.5rem;
}

.dark-mode .stat-card h3 {
    color: #aaa;
}

.stat-value {
    font-size: 2rem;
    font-weight: bold;
    color: var(--primary-color);
}

.stat-online .stat-value {
    color: var(--success-color);
}

.stat-offline .stat-value {
    color: var(--danger-color);
}

.stat-never .stat-value {
    color: var(--warning-color);
}

.stat-inactive .stat-value {
    color: #999;
}

.stat-outage .stat-value {
    color: var(--danger-color);
}

/* Charts Grid */
.charts-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 2rem;
    margin-bottom: 2rem;
}

.chart-container {
    background: white;
    padding: 1.5rem;
    border-radius: 8px;
    box-shadow: var(--shadow);
}

.dark-mode .chart-container {
    background: #2a2a2a;
}

.chart-container h3 {
    margin-bottom: 1rem;
}

/* Equipment Section */
.equipment-section {
    background: white;
    padding: 2rem;
    border-radius: 8px;
    box-shadow: var(--shadow);
}

.dark-mode .equipment-section {
    background: #2a2a2a;
}

.equipment-section h2 {
    margin-bottom: 1.5rem;
}

/* Table */
.table-responsive {
    overflow-x: auto;
}

.equipment-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 1rem;
}

.equipment-table thead {
    background-color: #f9f9f9;
    border-bottom: 2px solid var(--border-color);
}

.dark-mode .equipment-table thead {
    background-color: #333;
}

.equipment-table th {
    padding: 1rem;
    text-align: left;
    font-weight: 600;
    color: var(--light-text);
}

.equipment-table td {
    padding: 1rem;
    border-bottom: 1px solid var(--border-color);
}

.equipment-table tr:hover {
    background-color: #f5f5f5;
}

.dark-mode .equipment-table tr:hover {
    background-color: #333;
}

.equipment-table .actions {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.equipment-table .btn-sm {
    white-space: nowrap;
    font-size: 0.8rem;
    padding: 0.25rem 0.6rem;
}

/* Badges */
.badge {
    display: inline-block;
    padding: 0.25rem 0.75rem;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 600;
}

.state-online {
    background-color: #c8e6c9;
    color: #2e7d32;
}

.state-sem-comunicacao {
    background-color: #ffcdd2;
    color: #c62828;
}

.state-nunca-visto {
    background-color: #ffe0b2;
    color: #e65100;
}

.state-inativo {
    background-color: #eeeeee;
    color: #616161;
}

/* Login Page */
.login-page {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
}

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

.login-box {
    background: white;
    padding: 2rem;
    border-radius: 8px;
    box-shadow: var(--shadow);
}

.dark-mode .login-box {
    background: #2a2a2a;
}

.login-box h1 {
    text-align: center;
    margin-bottom: 0.5rem;
    color: var(--primary-color);
}

.subtitle {
    text-align: center;
    color: #666;
    margin-bottom: 2rem;
    font-size: 0.9rem;
}

.dark-mode .subtitle {
    color: #aaa;
}

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

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

.login-form input {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    font-size: 1rem;
    transition: border-color 0.3s;
}

.dark-mode .login-form input {
    background-color: #333;
    color: var(--light-text);
}

.login-form input:focus {
    outline: none;
    border-color: var(--info-color);
    box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.1);
}

.login-form .btn {
    width: 100%;
    padding: 0.75rem;
    font-size: 1rem;
}

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

.alert-danger {
    background-color: #ffcdd2;
    color: #c62828;
    border-left: 4px solid #c62828;
}

.alert-success {
    background-color: #c8e6c9;
    color: #2e7d32;
    border-left: 4px solid #2e7d32;
}

.alert-warning {
    background-color: #ffe0b2;
    color: #e65100;
    border-left: 4px solid #e65100;
}

/* Forms */
.form-container {
    background: white;
    padding: 2rem;
    border-radius: 8px;
    box-shadow: var(--shadow);
}

.dark-mode .form-container {
    background: #2a2a2a;
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.form-full {
    grid-column: 1 / -1;
}

.form-group {
    display: flex;
    flex-direction: column;
}

.form-group label {
    margin-bottom: 0.5rem;
    font-weight: 600;
}

.form-group input,
.form-group textarea {
    padding: 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    font-size: 1rem;
    font-family: inherit;
    transition: border-color 0.3s;
}

.dark-mode .form-group input,
.dark-mode .form-group textarea {
    background-color: #333;
    color: var(--light-text);
}

.form-group input:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--info-color);
    box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.1);
}

.form-actions {
    display: flex;
    gap: 1rem;
}

/* Detail Page */
.detail-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 2rem;
    margin-bottom: 2rem;
}

.detail-card {
    background: white;
    padding: 1.5rem;
    border-radius: 8px;
    box-shadow: var(--shadow);
}

.dark-mode .detail-card {
    background: #2a2a2a;
}

.detail-card.full-width {
    grid-column: 1 / -1;
}

.detail-card h3 {
    margin-bottom: 1.5rem;
}

.detail-content {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.detail-row {
    display: flex;
    justify-content: space-between;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--border-color);
}

.detail-row:last-child {
    border-bottom: none;
    padding-bottom: 0;
}

.detail-label {
    font-weight: 600;
    min-width: 150px;
}

.token-display,
.url-display,
.command-display {
    background-color: #f5f5f5;
    padding: 0.5rem 1rem;
    border-radius: 4px;
    font-family: 'Courier New', monospace;
    font-size: 0.9rem;
    word-break: break-all;
}

.dark-mode .token-display,
.dark-mode .url-display,
.dark-mode .command-display {
    background-color: #333;
    color: #4CAF50;
}

.ua-display {
    max-width: 300px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Heartbeat Config */
.heartbeat-config {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.config-section {
    border-left: 4px solid var(--info-color);
    padding-left: 1rem;
}

.config-section h4 {
    margin-bottom: 0.5rem;
}

.config-section p {
    font-size: 0.9rem;
    color: #666;
    margin-bottom: 0.5rem;
}

.dark-mode .config-section p {
    color: #aaa;
}

.config-section .btn {
    align-self: flex-start;
    margin-top: 0.5rem;
}

.powershell-script {
    width: 100%;
    padding: 1rem;
    background-color: #f5f5f5;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    font-family: 'Courier New', monospace;
    font-size: 0.8rem;
    min-height: 150px;
    margin: 0.5rem 0;
}

.dark-mode .powershell-script {
    background-color: #333;
    color: #4CAF50;
}

/* History Section */
.history-section {
    background: white;
    padding: 2rem;
    border-radius: 8px;
    box-shadow: var(--shadow);
    margin-bottom: 2rem;
}

.dark-mode .history-section {
    background: #2a2a2a;
}

.history-section h2 {
    margin-bottom: 1.5rem;
}

.history-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 1rem;
}

.history-table thead {
    background-color: #f9f9f9;
    border-bottom: 2px solid var(--border-color);
}

.dark-mode .history-table thead {
    background-color: #333;
}

.history-table th {
    padding: 1rem;
    text-align: left;
    font-weight: 600;
}

.history-table td {
    padding: 1rem;
    border-bottom: 1px solid var(--border-color);
}

.history-table tr:hover {
    background-color: #f5f5f5;
}

.dark-mode .history-table tr:hover {
    background-color: #333;
}

.text-center {
    text-align: center;
    color: #666;
}

.dark-mode .text-center {
    color: #aaa;
}

/* Responsive */
@media (max-width: 768px) {
    .navbar .container {
        flex-direction: column;
        gap: 1rem;
    }

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

    .stats-grid {
        grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    }

    .stat-card {
        padding: 1rem;
    }

    .stat-value {
        font-size: 1.5rem;
    }

    .equipment-table {
        font-size: 0.9rem;
    }

    .equipment-table th,
    .equipment-table td {
        padding: 0.75rem 0.5rem;
    }

    .equipment-table .actions {
        flex-direction: column;
    }

    .equipment-table .btn-sm {
        width: 100%;
        text-align: center;
    }

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

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

    .detail-row {
        flex-direction: column;
        gap: 0.5rem;
    }

    .detail-label {
        font-weight: 600;
        margin-bottom: 0.25rem;
    }

    .table-responsive {
        font-size: 0.85rem;
    }

    .history-table th,
    .history-table td {
        padding: 0.75rem 0.5rem;
    }
}
