/* ===========================
   Qualys ROCon Signage Control
   Dark Theme — Premium Design
   =========================== */

:root {
    /* Qualys Brand */
    --q-blue: #0066CC;
    --q-teal: #00A3A3;
    --q-red: #E74C3C;
    --q-gradient: linear-gradient(135deg, #0066CC, #00A3A3);

    /* Dark Theme */
    --bg-app: #0A0E1A;
    --bg-card: #141929;
    --bg-card-hover: #1A2035;
    --bg-header: #0F1425;
    --bg-input: #1A2035;
    --bg-modal: #141929;

    /* Borders */
    --border: #1E2740;
    --border-light: #2A3555;
    --border-active: var(--q-blue);

    /* Text */
    --text-primary: #FFFFFF;
    --text-secondary: #8892B0;
    --text-muted: #5A6380;

    /* Status */
    --status-online: #2ECC71;
    --status-offline: #E74C3C;
    --status-casting: #F39C12;

    /* Shadows */
    --shadow-sm: 0 2px 8px rgba(0,0,0,0.3);
    --shadow-md: 0 4px 20px rgba(0,0,0,0.4);
    --shadow-glow: 0 0 20px rgba(0,102,204,0.15);

    /* Radius */
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;

    /* Transitions */
    --transition: 0.2s ease;
}

/* ===== Reset & Base ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg-app);
    color: var(--text-primary);
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
    overflow-x: hidden;
}

.hidden { display: none !important; }

/* ===== PIN LOCK SCREEN ===== */
.pin-screen {
    position: fixed; inset: 0; z-index: 1000;
    background: var(--bg-app);
    display: flex; align-items: center; justify-content: center;
    background-image: 
        radial-gradient(ellipse at 20% 50%, rgba(0,102,204,0.08) 0%, transparent 50%),
        radial-gradient(ellipse at 80% 50%, rgba(0,163,163,0.08) 0%, transparent 50%);
}

.pin-container {
    text-align: center;
    width: 100%;
    max-width: 360px;
    padding: 20px;
}

.pin-logo { margin-bottom: 40px; }
.pin-logo-icon {
    font-size: 3rem;
    margin-bottom: 12px;
    filter: drop-shadow(0 0 20px rgba(0,102,204,0.3));
}
.pin-logo h1 {
    font-size: 1.8rem;
    font-weight: 800;
    background: var(--q-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 6px;
}
.pin-logo p { color: var(--text-secondary); font-size: 0.9rem; }

.pin-display { margin-bottom: 30px; }
.pin-dots {
    display: flex; gap: 12px; justify-content: center;
    margin-bottom: 12px;
}
.pin-dot {
    width: 16px; height: 16px;
    border-radius: 50%;
    border: 2px solid var(--border-light);
    transition: var(--transition);
}
.pin-dot.filled {
    background: var(--q-blue);
    border-color: var(--q-blue);
    box-shadow: 0 0 8px rgba(0,102,204,0.4);
}
.pin-dot.error {
    border-color: var(--q-red);
    animation: shake 0.4s ease;
}

.pin-error {
    color: var(--q-red);
    font-size: 0.85rem;
    min-height: 20px;
    font-weight: 500;
}

.pin-keypad {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
    max-width: 280px;
    margin: 0 auto;
}
.pin-key {
    width: 100%; aspect-ratio: 1.4;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    background: var(--bg-card);
    color: var(--text-primary);
    font-size: 1.5rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    font-family: inherit;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}
.pin-key:hover { background: var(--bg-card-hover); border-color: var(--border-light); }
.pin-key:active { transform: scale(0.95); background: var(--q-blue); }
.pin-key-empty { visibility: hidden; }
.pin-key-delete { font-size: 1.3rem; }

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    20%, 60% { transform: translateX(-8px); }
    40%, 80% { transform: translateX(8px); }
}

/* ===== APP HEADER ===== */
.app-header {
    position: sticky; top: 0; z-index: 100;
    display: flex; align-items: center; justify-content: space-between;
    padding: 0 24px;
    height: 60px;
    background: var(--bg-header);
    border-bottom: 1px solid var(--border);
    backdrop-filter: blur(12px);
}

.header-left { display: flex; align-items: center; gap: 12px; }
.header-brand { display: flex; align-items: center; gap: 8px; }
.header-icon { font-size: 1.3rem; }
.header-title {
    font-size: 1rem; font-weight: 700;
    background: var(--q-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

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

.user-badge {
    font-size: 0.8rem;
    color: var(--text-secondary);
    background: var(--bg-card);
    padding: 4px 12px;
    border-radius: 20px;
    border: 1px solid var(--border);
}

/* ===== NAV TABS ===== */
.nav-tabs { display: flex; gap: 4px; }
.nav-tab {
    display: flex; align-items: center; gap: 6px;
    padding: 8px 16px;
    background: transparent;
    border: none;
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    font-family: inherit;
}
.nav-tab:hover { color: var(--text-primary); background: var(--bg-card); }
.nav-tab.active {
    color: var(--text-primary);
    background: var(--q-blue);
}
.nav-icon { font-size: 1rem; }

/* ===== VIEWS ===== */
.view {
    display: none;
    padding: 24px;
    max-width: 1400px;
    margin: 0 auto;
    animation: fadeIn 0.3s ease;
}
.view.active { display: block; }

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ===== TOOLBAR ===== */
.toolbar {
    display: flex; align-items: center; justify-content: space-between;
    flex-wrap: wrap; gap: 12px;
    margin-bottom: 24px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--border);
}
.toolbar-left, .toolbar-right {
    display: flex; align-items: center; gap: 12px;
    flex-wrap: wrap;
}
.view-title {
    font-size: 1.4rem; font-weight: 800;
    color: var(--text-primary);
}

/* ===== SELECT ALL TOGGLE ===== */
.select-all-toggle {
    display: flex; align-items: center; gap: 8px;
    font-size: 0.85rem; color: var(--text-secondary);
    cursor: pointer; user-select: none;
}
.select-all-toggle input[type="checkbox"] {
    width: 18px; height: 18px;
    accent-color: var(--q-blue);
    cursor: pointer;
}

/* ===== BUTTONS ===== */
.btn {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 10px 18px;
    border: none; border-radius: var(--radius-sm);
    font-size: 0.85rem; font-weight: 600;
    cursor: pointer; transition: var(--transition);
    font-family: inherit;
    white-space: nowrap;
}
.btn-sm { padding: 7px 14px; font-size: 0.8rem; }
.btn-primary {
    background: var(--q-blue); color: white;
    box-shadow: 0 2px 8px rgba(0,102,204,0.3);
}
.btn-primary:hover { background: #0055AA; transform: translateY(-1px); }
.btn-outline {
    background: transparent; color: var(--text-secondary);
    border: 1px solid var(--border);
}
.btn-outline:hover { border-color: var(--border-light); color: var(--text-primary); }
.btn-danger {
    background: var(--q-red); color: white;
    box-shadow: 0 2px 8px rgba(231,76,60,0.3);
}
.btn-danger:hover { background: #C0392B; transform: translateY(-1px); }
.btn-icon {
    background: none; border: none; cursor: pointer;
    font-size: 1.1rem; padding: 4px;
    transition: var(--transition);
}
.btn-icon:hover { transform: scale(1.1); }

/* ===== INPUTS ===== */
.input-select, .input-search {
    padding: 8px 12px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 0.85rem;
    font-family: inherit;
    transition: var(--transition);
}
.input-select:focus, .input-search:focus {
    outline: none;
    border-color: var(--q-blue);
    box-shadow: 0 0 0 3px rgba(0,102,204,0.15);
}
.input-search { min-width: 200px; }
.input-search::placeholder { color: var(--text-muted); }

/* ===== SCREEN GRID ===== */
.screen-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
    gap: 20px;
}

.screen-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 20px;
    transition: var(--transition);
    position: relative;
    overflow: hidden;
}
.screen-card::before {
    content: '';
    position: absolute; top: 0; left: 0; right: 0;
    height: 3px;
    background: var(--q-gradient);
    opacity: 0;
    transition: var(--transition);
}
.screen-card:hover {
    border-color: var(--border-light);
    box-shadow: var(--shadow-glow);
}
.screen-card:hover::before { opacity: 1; }
.screen-card.selected {
    border-color: var(--q-blue);
    box-shadow: 0 0 0 1px var(--q-blue), var(--shadow-glow);
}
.screen-card.selected::before { opacity: 1; }

.screen-header {
    display: flex; align-items: center; justify-content: space-between;
    margin-bottom: 16px;
}
.screen-header-left { display: flex; align-items: center; gap: 12px; }
.screen-checkbox {
    width: 20px; height: 20px;
    accent-color: var(--q-blue);
    cursor: pointer;
}
.screen-name {
    font-size: 1.1rem; font-weight: 700;
    color: var(--text-primary);
}
.screen-status {
    display: flex; align-items: center; gap: 6px;
    font-size: 0.75rem; font-weight: 600;
    text-transform: uppercase; letter-spacing: 0.5px;
}
.status-dot {
    width: 8px; height: 8px;
    border-radius: 50%;
}
.status-dot.online { background: var(--status-online); box-shadow: 0 0 6px var(--status-online); }
.status-dot.offline { background: var(--status-offline); }
.status-dot.casting { background: var(--status-casting); animation: pulse 2s infinite; }

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

.screen-current {
    background: var(--bg-app);
    border-radius: var(--radius-sm);
    padding: 12px;
    margin-bottom: 16px;
}
.screen-current-label {
    font-size: 0.75rem; color: var(--text-muted);
    text-transform: uppercase; letter-spacing: 0.5px;
    margin-bottom: 4px;
}
.screen-current-value {
    font-size: 0.9rem; font-weight: 600;
    color: var(--text-secondary);
}
.screen-countdown {
    display: inline-flex; align-items: center; gap: 4px;
    margin-top: 6px;
    font-size: 0.8rem; font-weight: 600;
    color: var(--status-casting);
}

.screen-actions {
    display: flex; flex-wrap: wrap; gap: 8px;
}
.screen-actions .input-select { flex: 1; min-width: 0; }
.screen-actions .btn { flex-shrink: 0; }

.screen-action-row {
    display: flex; gap: 8px; width: 100%;
    align-items: center;
}

/* ===== CONTENT GRID ===== */
.content-tabs { display: flex; gap: 4px; }
.content-tab {
    padding: 6px 14px;
    background: transparent;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    font-family: inherit;
}
.content-tab.active {
    background: var(--q-blue);
    border-color: var(--q-blue);
    color: white;
}

.content-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 16px;
}

.content-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 20px;
    display: flex; align-items: center; justify-content: space-between;
    transition: var(--transition);
    cursor: default;
}
.content-card:hover {
    border-color: var(--border-light);
    box-shadow: var(--shadow-sm);
}
.content-info { display: flex; flex-direction: column; gap: 4px; flex: 1; min-width: 0; }
.content-name {
    font-size: 0.95rem; font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.content-type {
    font-size: 0.75rem; color: var(--text-muted);
    text-transform: uppercase; letter-spacing: 0.5px;
}
.content-push-btn {
    padding: 8px 14px;
    background: var(--q-blue);
    border: none; border-radius: var(--radius-sm);
    color: white;
    font-size: 0.8rem; font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    font-family: inherit;
    white-space: nowrap;
    flex-shrink: 0;
}
.content-push-btn:hover { background: #0055AA; transform: translateY(-1px); }

/* ===== ACTIVITY FEED ===== */
.activity-feed {
    display: flex; flex-direction: column; gap: 8px;
}
.activity-item {
    display: flex; align-items: flex-start; gap: 14px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 14px 18px;
    transition: var(--transition);
}
.activity-item:hover { border-color: var(--border-light); }
.activity-icon {
    font-size: 1.3rem;
    flex-shrink: 0;
    margin-top: 2px;
}
.activity-details { flex: 1; min-width: 0; }
.activity-text {
    font-size: 0.9rem;
    color: var(--text-primary);
    margin-bottom: 4px;
    line-height: 1.4;
}
.activity-text strong { color: var(--q-teal); }
.activity-meta {
    font-size: 0.75rem;
    color: var(--text-muted);
}

/* ===== MODALS ===== */
.modal-overlay {
    position: fixed; inset: 0; z-index: 500;
    background: rgba(0,0,0,0.7);
    display: flex; align-items: center; justify-content: center;
    backdrop-filter: blur(4px);
    animation: fadeIn 0.2s ease;
}
.modal {
    background: var(--bg-modal);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-lg);
    width: 90%; max-width: 480px;
    box-shadow: var(--shadow-md);
    animation: modalIn 0.3s ease;
}
@keyframes modalIn {
    from { opacity: 0; transform: scale(0.95) translateY(10px); }
    to { opacity: 1; transform: scale(1) translateY(0); }
}
.modal-header {
    padding: 20px 24px 0;
}
.modal-header h3 {
    font-size: 1.1rem; font-weight: 700;
    color: var(--text-primary);
}
.modal-body { padding: 16px 24px; }
.modal-body p { color: var(--text-secondary); font-size: 0.9rem; line-height: 1.5; }
.modal-footer {
    padding: 0 24px 20px;
    display: flex; justify-content: flex-end; gap: 10px;
}

.push-content-label {
    font-weight: 700; color: var(--text-primary) !important;
    font-size: 1rem !important;
    margin-bottom: 12px !important;
}

.push-type-row {
    display: flex; align-items: center; gap: 10px;
    margin-bottom: 16px;
}
.push-type-row label {
    font-size: 0.85rem; color: var(--text-secondary);
    white-space: nowrap;
}

.screen-checklist {
    display: flex; flex-direction: column; gap: 8px;
    max-height: 240px; overflow-y: auto;
    margin-bottom: 12px;
}
.screen-check-item {
    display: flex; align-items: center; gap: 10px;
    padding: 8px 12px;
    background: var(--bg-app);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: var(--transition);
}
.screen-check-item:hover { background: var(--bg-card-hover); }
.screen-check-item input {
    width: 18px; height: 18px;
    accent-color: var(--q-blue);
    cursor: pointer;
}
.screen-check-item span {
    font-size: 0.9rem; color: var(--text-primary);
}

.push-select-all { margin-top: 4px; }

/* ===== TOASTS ===== */
#toast-container {
    position: fixed; bottom: 20px; right: 20px;
    z-index: 9999;
    display: flex; flex-direction: column-reverse; gap: 10px;
}
.toast {
    min-width: 280px; max-width: 400px;
    padding: 14px 18px;
    border-radius: var(--radius-md);
    font-size: 0.9rem; font-weight: 500;
    color: white;
    box-shadow: var(--shadow-md);
    display: flex; align-items: center; gap: 10px;
    animation: toastIn 0.4s ease;
}
.toast.success { background: #27ae60; }
.toast.error { background: #c0392b; }
.toast.info { background: var(--q-blue); }
.toast.removing { animation: toastOut 0.3s ease forwards; }

@keyframes toastIn {
    from { opacity: 0; transform: translateX(40px); }
    to { opacity: 1; transform: translateX(0); }
}
@keyframes toastOut {
    from { opacity: 1; transform: translateX(0); }
    to { opacity: 0; transform: translateX(40px); }
}

/* ===== LOADING ===== */
.loading-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-secondary);
    grid-column: 1 / -1;
}
.spinner {
    width: 40px; height: 40px;
    border: 3px solid var(--border);
    border-top-color: var(--q-blue);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin: 0 auto 16px;
}
@keyframes spin { to { transform: rotate(360deg); } }

.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-muted);
    grid-column: 1 / -1;
    font-size: 0.95rem;
}

/* ===== OFFLINE BANNER ===== */
.offline-banner {
    position: sticky; top: 0; z-index: 200;
    background: linear-gradient(90deg, #c0392b, #e74c3c);
    color: white;
    text-align: center;
    padding: 10px 20px;
    font-size: 0.85rem;
    font-weight: 600;
    animation: slideDown 0.3s ease;
}
@keyframes slideDown {
    from { transform: translateY(-100%); }
    to { transform: translateY(0); }
}

.toast.warning {
    background: #e67e22;
}

/* ===== RESPONSIVE ===== */
@media (max-width: 768px) {
    .app-header {
        flex-wrap: wrap;
        height: auto;
        padding: 10px 16px;
        gap: 8px;
    }
    .header-left { order: 1; }
    .header-right { order: 2; margin-left: auto; }
    .header-center { order: 3; width: 100%; justify-content: center; }
    .nav-label { display: none; }
    .nav-tab { padding: 8px 12px; }

    .view { padding: 16px; }
    .toolbar { flex-direction: column; align-items: flex-start; }
    .toolbar-right { width: 100%; flex-wrap: wrap; }

    .screen-grid { grid-template-columns: 1fr; }
    .content-grid { grid-template-columns: 1fr; }

    .bulk-actions { flex-wrap: wrap; }
    .input-search { min-width: unset; width: 100%; }

    .screen-action-row { flex-wrap: wrap; }
    .screen-actions .input-select { min-width: 100px; }

    .modal { width: 95%; max-width: none; margin: 20px; }
}

@media (max-width: 480px) {
    .pin-key { font-size: 1.3rem; }
    .pin-keypad { gap: 8px; max-width: 240px; }
    .header-title { display: none; }
}
