/* === Szerver Analytics - Dashboard CSS === */

:root {
    --bg: #f5f7fa;
    --bg-card: #ffffff;
    --text: #1a1a2e;
    --text-muted: #6b7280;
    --border: #e5e7eb;
    --primary: #3b82f6;
    --primary-hover: #2563eb;
    --success: #10b981;
    --danger: #ef4444;
    --warning: #f59e0b;
    --radius: 8px;
    --shadow: 0 1px 3px rgba(0,0,0,0.08);
    --shadow-lg: 0 4px 12px rgba(0,0,0,0.1);
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
    min-height: 100vh;
}

/* === Header === */

.header {
    background: var(--bg-card);
    border-bottom: 1px solid var(--border);
    padding: 0.75rem 1.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: var(--shadow);
}

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

.logo {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--primary);
    white-space: nowrap;
}

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

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

.select {
    padding: 0.4rem 0.6rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg-card);
    font-size: 0.85rem;
    color: var(--text);
    cursor: pointer;
}

.period-selector {
    display: flex;
    gap: 2px;
    background: var(--bg);
    border-radius: var(--radius);
    padding: 2px;
}

.period-btn {
    padding: 0.35rem 0.75rem;
    border-radius: 6px;
    text-decoration: none;
    font-size: 0.8rem;
    color: var(--text-muted);
    transition: all 0.2s;
}

.period-btn:hover {
    background: var(--bg-card);
    color: var(--text);
}

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

.realtime-badge {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.35rem 0.75rem;
    background: #ecfdf5;
    border: 1px solid #a7f3d0;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 600;
    color: #065f46;
}

.realtime-dot {
    width: 8px;
    height: 8px;
    background: var(--success);
    border-radius: 50%;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; }
}

.btn-logout {
    padding: 0.35rem 0.75rem;
    border-radius: var(--radius);
    text-decoration: none;
    font-size: 0.8rem;
    color: var(--text-muted);
    border: 1px solid var(--border);
    transition: all 0.2s;
}

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

/* === Main === */

.main {
    max-width: 1400px;
    margin: 0 auto;
    padding: 1.5rem;
}

/* === KPI kártyák === */

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

.kpi-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.25rem;
    box-shadow: var(--shadow);
}

.kpi-label {
    font-size: 0.8rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 0.35rem;
}

.kpi-value {
    font-size: 1.8rem;
    font-weight: 700;
    color: var(--text);
}

/* === Cards === */

.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    margin-bottom: 1.5rem;
}

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--border);
}

.card-header h3 {
    font-size: 0.95rem;
    font-weight: 600;
}

.card-body {
    padding: 1.25rem;
}

.chart-card .card-body {
    padding: 1rem;
}

.chart-toggle {
    display: flex;
    gap: 2px;
    background: var(--bg);
    border-radius: 6px;
    padding: 2px;
}

.chart-btn {
    padding: 0.3rem 0.6rem;
    border: none;
    background: transparent;
    border-radius: 4px;
    font-size: 0.75rem;
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.2s;
}

.chart-btn.active {
    background: var(--bg-card);
    color: var(--text);
    box-shadow: var(--shadow);
}

/* === Grid === */

.grid-2col {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
    gap: 1.5rem;
}
.grid-6col {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(600px, 1fr));
    gap: 1.5rem;
}

.grid-2col .card {
    margin-bottom: 0;
}

/* === Táblázatok === */

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
}

.data-table th {
    text-align: left;
    padding: 0.5rem 0.75rem;
    color: var(--text-muted);
    font-weight: 500;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 1px solid var(--border);
}

.data-table td {
    padding: 0.6rem 0.75rem;
    border-bottom: 1px solid #f3f4f6;
}

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

.data-table tr:hover td {
    background: #f9fafb;
}

.data-table td:nth-child(2),
.data-table td:nth-child(3),
.data-table th:nth-child(2),
.data-table th:nth-child(3) {
    text-align: right;
    white-space: nowrap;
}

.data-table td:first-child {
    max-width: 300px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.loading {
    text-align: center !important;
    color: var(--text-muted);
    padding: 2rem !important;
}

.chart-small {
    max-width: 300px;
    margin: 0 auto;
}

/* === Code block === */

.code-block {
    background: #1e293b;
    color: #e2e8f0;
    padding: 1rem;
    border-radius: var(--radius);
    overflow-x: auto;
    font-size: 0.8rem;
    line-height: 1.6;
}

/* === Login === */

.login-container {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 80vh;
}

.login-box {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 2.5rem;
    width: 100%;
    max-width: 380px;
    box-shadow: var(--shadow-lg);
    text-align: center;
}

.login-box h2 {
    font-size: 1.4rem;
    margin-bottom: 0.25rem;
    color: var(--primary);
}

.login-subtitle {
    color: var(--text-muted);
    font-size: 0.85rem;
    margin-bottom: 1.5rem;
}

.form-group {
    margin-bottom: 1rem;
    text-align: left;
}

.form-group label {
    display: block;
    font-size: 0.85rem;
    font-weight: 500;
    margin-bottom: 0.35rem;
    color: var(--text);
}

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

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

.btn {
    display: inline-block;
    padding: 0.6rem 1.25rem;
    border: none;
    border-radius: var(--radius);
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    text-decoration: none;
    transition: all 0.2s;
}

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

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

.btn-full {
    width: 100%;
}

.alert {
    padding: 0.75rem 1rem;
    border-radius: var(--radius);
    margin-bottom: 1rem;
    font-size: 0.85rem;
}

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

/* === Footer === */

.footer {
    text-align: center;
    padding: 1.5rem;
    color: var(--text-muted);
    font-size: 0.75rem;
}

/* === Responsive === */

@media (max-width: 768px) {
    .header {
        padding: 0.5rem 1rem;
    }

    .header-nav {
        order: 3;
        width: 100%;
    }

    .period-selector {
        width: 100%;
        overflow-x: auto;
    }

    .main {
        padding: 1rem;
    }

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

    .grid-2col {
        grid-template-columns: 1fr;
    }

    .kpi-value {
        font-size: 1.4rem;
    }
}

/* === Install page === */

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

.install-box {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 2rem;
    box-shadow: var(--shadow-lg);
}

.install-box h2 {
    font-size: 1.3rem;
    margin-bottom: 1.5rem;
    color: var(--primary);
}

.install-step {
    margin-bottom: 1.5rem;
}

.install-step h3 {
    font-size: 1rem;
    margin-bottom: 0.75rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--border);
}

.success-msg,
.alert-success {
    background: #ecfdf5;
    color: #065f46;
    border: 1px solid #a7f3d0;
    padding: 1rem;
    border-radius: var(--radius);
    margin-bottom: 1rem;
}

/* === Sites kezelő oldal === */

.sites-page {
    max-width: 1000px;
    margin: 0 auto;
}

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

.page-header h2 {
    font-size: 1.3rem;
}

.btn-secondary {
    background: var(--bg);
    color: var(--text);
    border: 1px solid var(--border);
}

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

.btn-sites {
    padding: 0.35rem 0.75rem;
    border-radius: var(--radius);
    text-decoration: none;
    font-size: 0.8rem;
    color: var(--primary);
    border: 1px solid var(--primary);
    transition: all 0.2s;
}

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

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

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

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

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

.btn-danger:hover {
    background: #dc2626;
}

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

.btn-success:hover {
    background: #059669;
}

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

.form-row .form-group {
    flex: 1;
    min-width: 180px;
    margin-bottom: 0;
}

.form-row .form-action {
    flex: 0 0 auto;
    min-width: auto;
}

.inline-form {
    display: inline;
}

.text-muted {
    color: var(--text-muted);
    font-size: 0.85rem;
}

/* Site lista */

.sites-list {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.site-item {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1rem 1.25rem;
    transition: box-shadow 0.2s;
}

.site-item:hover {
    box-shadow: var(--shadow);
}

.site-inactive {
    opacity: 0.6;
    background: #f9fafb;
}

.site-info {
    margin-bottom: 0.75rem;
}

.site-name-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.35rem;
    flex-wrap: wrap;
}

.site-status-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
}

.site-status-dot.active {
    background: var(--success);
}

.site-status-dot.inactive {
    background: var(--text-muted);
}

.site-name {
    font-size: 1rem;
}

.site-domain {
    color: var(--text-muted);
    font-size: 0.85rem;
}

.site-stats-row {
    display: flex;
    gap: 1.5rem;
    font-size: 0.8rem;
    color: var(--text-muted);
    flex-wrap: wrap;
}

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

.site-code-panel,
.site-edit-panel {
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border);
}

.site-code-panel .code-block {
    margin: 0.5rem 0;
    font-size: 0.75rem;
}

.checkbox-label {
    display: flex !important;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
    font-size: 0.85rem;
    padding-top: 1.5rem;
}

.checkbox-label input[type="checkbox"] {
    width: 16px;
    height: 16px;
}

@media (max-width: 768px) {
    .page-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
    }

    .form-row {
        flex-direction: column;
    }

    .form-row .form-group {
        min-width: 100%;
    }

    .site-actions {
        flex-wrap: wrap;
    }

    .site-stats-row {
        flex-direction: column;
        gap: 0.25rem;
    }
}
