:root {
    --primary: #1976d2;
    --primary-dark: #1565c0;
    --success: #4caf50;
    --warning: #ff9800;
    --danger: #f44336;
    --text: #212121;
    --text-secondary: #757575;
    --bg: #f5f5f5;
    --card-bg: #ffffff;
    --border: #e0e0e0;
    --radius: 12px;
    --shadow: 0 2px 8px rgba(0,0,0,0.1);
    --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body { height: 100%; }

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    -webkit-font-smoothing: antialiased;
    user-select: none;
    -webkit-user-select: none;
}

/* App container */
.app-container {
    display: flex;
    flex-direction: column;
    height: 100vh;
    height: 100dvh;
}

/* Top bar */
.top-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    background: var(--primary);
    color: white;
}

.app-title { font-weight: 700; font-size: 18px; }

.connectivity-badge {
    font-size: 11px;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 10px;
}
.connectivity-badge.lan { background: var(--success); }
.connectivity-badge.wan { background: var(--warning); color: #333; }

/* Page content */
.page-content {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    padding-bottom: calc(72px + var(--safe-bottom));
}

/* Bottom tabs */
.bottom-tabs {
    display: flex;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--card-bg);
    border-top: 1px solid var(--border);
    padding-bottom: var(--safe-bottom);
    z-index: 100;
}

.tab {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 8px 0;
    text-decoration: none;
    color: var(--text-secondary);
    font-size: 11px;
    transition: color 0.2s;
}

.tab.active, .tab:hover { color: var(--primary); }
.tab-icon { font-size: 22px; line-height: 1; }
.tab-label { margin-top: 2px; }

/* Page header */
.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
}
.page-header h3 { font-size: 20px; font-weight: 600; }

/* Buttons */
.btn-primary {
    width: 100%;
    padding: 14px;
    background: var(--primary);
    color: white;
    border: none;
    border-radius: var(--radius);
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    margin-top: 16px;
}
.btn-primary:hover { background: var(--primary-dark); }
.btn-primary:disabled { opacity: 0.6; cursor: not-allowed; }

.btn-secondary {
    width: 100%;
    padding: 12px;
    background: transparent;
    color: var(--primary);
    border: 1px solid var(--primary);
    border-radius: var(--radius);
    font-size: 14px;
    cursor: pointer;
    margin-bottom: 8px;
}

.btn-danger {
    width: 100%;
    padding: 12px;
    background: transparent;
    color: var(--danger);
    border: 1px solid var(--danger);
    border-radius: var(--radius);
    font-size: 14px;
    cursor: pointer;
    margin-top: 16px;
}

.btn-back {
    background: none;
    border: none;
    color: var(--primary);
    font-size: 16px;
    cursor: pointer;
    padding: 8px 0;
    margin-bottom: 8px;
}

.btn-refresh {
    background: none;
    border: none;
    font-size: 22px;
    cursor: pointer;
    color: var(--text-secondary);
}

/* Call card */
.call-card {
    background: var(--card-bg);
    border-radius: var(--radius);
    padding: 14px;
    margin-bottom: 10px;
    box-shadow: var(--shadow);
    cursor: pointer;
    transition: transform 0.15s;
}
.call-card:active { transform: scale(0.98); }

.call-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
}

.call-type {
    color: white;
    font-size: 12px;
    font-weight: 600;
    padding: 3px 10px;
    border-radius: 16px;
}

.call-priority { font-size: 12px; font-weight: 600; }

.escalation-badge {
    background: var(--danger);
    color: white;
    font-size: 10px;
    font-weight: 700;
    padding: 2px 6px;
    border-radius: 8px;
}

.call-description {
    font-size: 14px;
    color: var(--text);
    margin-bottom: 8px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.call-footer {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 12px;
    color: var(--text-secondary);
}

.call-sla { font-weight: 600; }
.call-sla.overdue { color: var(--danger); }

.call-actions {
    display: flex;
    gap: 8px;
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px solid var(--border);
}

.btn-action {
    flex: 1;
    padding: 8px;
    border: none;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    color: white;
}
.btn-action.accept { background: var(--primary); }
.btn-action.start { background: var(--success); }
.btn-action.pause { background: var(--warning); color: #333; }
.btn-action.resolve { background: #2e7d32; }

/* Call list */
.call-list { display: flex; flex-direction: column; }

/* Forms */
.form-group {
    margin-bottom: 16px;
}
.form-group label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 6px;
}
.form-group input, .form-group textarea {
    width: 100%;
    padding: 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 16px;
    background: var(--card-bg);
    color: var(--text);
}
.form-group input:focus, .form-group textarea:focus {
    outline: none;
    border-color: var(--primary);
}

/* Error */
.error-message {
    background: #fce4e4;
    color: var(--danger);
    padding: 10px 14px;
    border-radius: 8px;
    font-size: 14px;
    margin-bottom: 12px;
}

/* Login */
.login-layout {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 24px;
    background: var(--bg);
}

.login-card {
    width: 100%;
    max-width: 360px;
    text-align: center;
}
.login-card h2 {
    font-size: 32px;
    color: var(--primary);
    margin-bottom: 4px;
}
.login-subtitle {
    color: var(--text-secondary);
    margin-bottom: 32px;
}

/* Loading */
.loading {
    display: flex;
    justify-content: center;
    padding: 40px;
}

.spinner {
    width: 32px;
    height: 32px;
    border: 3px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

.spinner-small {
    display: inline-block;
    width: 18px;
    height: 18px;
    border: 2px solid rgba(255,255,255,0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
    vertical-align: middle;
}

@keyframes spin { to { transform: rotate(360deg); } }

.loading-screen {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100vh;
    gap: 16px;
    color: var(--text-secondary);
}

/* Empty state */
.empty-state {
    text-align: center;
    padding: 40px 20px;
    color: var(--text-secondary);
    font-size: 16px;
}

/* Detail page */
.detail-page { padding-bottom: 24px; }
.detail-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
}
.detail-type {
    font-size: 13px;
    color: var(--text-secondary);
    background: var(--bg);
    padding: 4px 12px;
    border-radius: 16px;
}
.detail-section {
    background: var(--card-bg);
    border-radius: var(--radius);
    padding: 14px;
    margin-bottom: 12px;
    box-shadow: var(--shadow);
}
.detail-section h4 {
    font-size: 14px;
    color: var(--text-secondary);
    margin-bottom: 10px;
}

/* Timeline */
.timeline { display: flex; flex-direction: column; gap: 12px; }
.timeline-item { display: flex; align-items: center; gap: 10px; }
.timeline-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
}
.timeline-content {
    display: flex;
    justify-content: space-between;
    flex: 1;
    font-size: 13px;
}
.timeline-time { color: var(--text-secondary); }

/* Profile */
.profile-card {
    background: var(--card-bg);
    border-radius: var(--radius);
    padding: 16px;
    margin-bottom: 20px;
    box-shadow: var(--shadow);
}
.profile-field { margin-bottom: 12px; }
.profile-field label {
    display: block;
    font-size: 12px;
    color: var(--text-secondary);
    margin-bottom: 2px;
}
.profile-field span { font-size: 15px; }
.profile-actions { display: flex; flex-direction: column; }

/* Blazor error UI */
#blazor-error-ui {
    display: none;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 12px;
    background: var(--danger);
    color: white;
    text-align: center;
    z-index: 1000;
}
#blazor-error-ui .reload { color: white; }
