/* Bootstrap Custom Theme for Parental Control App */

:root {
    --bs-primary: #4f46e5;
    --bs-primary-rgb: 79, 70, 229;
    --bs-secondary: #6b7280;
    --bs-success: #10b981;
    --bs-danger: #ef4444;
    --bs-warning: #f59e0b;
    --bs-info: #3b82f6;
    --bs-light: #f9fafb;
    --bs-dark: #1f2937;

    --bs-body-font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    --bs-body-line-height: 1.6;

    /* Custom variables */
    --sidebar-width: 280px;
    --header-height: 70px;
}

/* Dark mode colors */
[data-bs-theme="dark"] {
    --bs-body-bg: #111827;
    --bs-body-color: #f9fafb;
    --bs-border-color: #374151;
}

/* ===== Global Enhancements ===== */
body {
    font-size: 0.95rem;
}

.app-container {
    min-height: 100vh;
}

/* ===== Sidebar Styling ===== */
/* ===== Sidebar (HTML-Vorlage: bootstrapexamples.com collapsible-sidebar) =====
 * Markup ist Bootstrap-first (d-flex flex-column position-fixed, sidebar-link
 * .text-decoration-none .p-3, profile-section mt-auto p-4). Diese Datei traegt
 * nur die Theme-Faerbung (lila Gradient, weisser Text).
 */
.sidebar {
    width: var(--sidebar-width);
    background: linear-gradient(180deg, #4f46e5 0%, #6366f1 100%);
    top: 0;
    left: 0;
    height: 100vh;
    overflow-y: auto;
    z-index: 1000;
}

[data-bs-theme="dark"] .sidebar {
    background: linear-gradient(180deg, #1e293b 0%, #334155 100%);
}

.logo-text { color: white; }

/* Marken-Logo in der Sidebar - hoehe an die Texthoehe gekoppelt, damit es
   automatisch mitwaechst, wenn die Sidebar-Schrift sich aendert. */
.logo-text .brand-logo {
    height: 1.4em;
    width: auto;
    vertical-align: -0.25em;
    margin-right: 0.4em;
}

/* Login/Register: groesseres Logo ueber dem Titel. */
.login-logo {
    width: 96px;
    height: 96px;
    object-fit: contain;
    display: inline-block;
}

.sidebar-link {
    display: flex;
    align-items: center;
    color: rgba(255, 255, 255, 0.85);
    transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
    border-left: 3px solid transparent;
}
.sidebar-link:hover {
    background: rgba(255, 255, 255, 0.1);
    color: white;
    border-left-color: rgba(255, 255, 255, 0.5);
}
.sidebar-link.active {
    background: rgba(255, 255, 255, 0.15);
    color: white;
    border-left-color: white;
    font-weight: 500;
}
.sidebar-link i { font-size: 1.05rem; width: 1.25rem; text-align: center; }

.profile-section {
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    cursor: pointer;
    transition: background 0.15s ease;
}
.profile-section:hover { background: rgba(255, 255, 255, 0.08); }

.profile-avatar {
    width: 44px;
    height: 44px;
    background: rgba(255, 255, 255, 0.15);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-size: 1.25rem;
}

/* Helle Sidebar braucht hellere "muted"-Toene als der Bootstrap-Default. */
.sidebar .text-muted { color: rgba(255, 255, 255, 0.6) !important; }

/* ===== Mobile-Navigation (Burger) =====
 * Button + Backdrop sind im Markup mit .d-lg-none versehen, erscheinen also nur
 * unter 992px. Die eigentliche Ein-/Ausfahr-Logik der Sidebar steht im
 * Responsive-Block weiter unten. */
.sidebar-toggle {
    display: inline-flex;
    position: fixed;
    top: 1rem;
    left: 1rem;
    z-index: 1030;
    width: 2.75rem;
    height: 2.75rem;
    align-items: center;
    justify-content: center;
    border: none;
    border-radius: 0.5rem;
    background: linear-gradient(135deg, var(--bs-primary) 0%, #6366f1 100%);
    color: #fff;
    font-size: 1.1rem;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
    cursor: pointer;
}

.sidebar-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 1040;
    background: rgba(0, 0, 0, 0.5);
}
.sidebar-backdrop.show { display: block; }

/* ===== Main Content Area ===== */
.main-content {
    margin-left: var(--sidebar-width);
    min-height: 100vh;
    background: #f9fafb;
    padding: 2rem;
}

[data-bs-theme="dark"] .main-content {
    background: #111827;
}

/* .page-header traegt bewusst kein eigenes Styling mehr (Hintergrund, Border,
   Innen-/Aussenabstand und Schatten entfernt) - der Seitenkopf fliesst direkt
   in den Content-Bereich ein. h1-Groesse + Mobile-Padding regelt der
   Responsive-Block weiter unten. */

/* ===== Cards Enhancement ===== */
.card {
    border: none;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

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

[data-bs-theme="dark"] .card {
    background: #1f2937;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}

.child-card {
    border-left: 4px solid var(--bs-primary);
}

.device-card {
    border-left: 4px solid var(--bs-info);
}

/* ===== Status Badges ===== */
.status-online {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

.status-online::before {
    content: '';
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--bs-success);
    box-shadow: 0 0 8px var(--bs-success);
    animation: pulse 2s infinite;
}

.status-offline::before {
    content: '';
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--bs-secondary);
}

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

/* ===== Buttons Enhancement ===== */
.btn {
    font-weight: 500;
    padding: 0.5rem 1.25rem;
    border-radius: 0.5rem;
    transition: all 0.2s ease;
}

.btn-primary {
    background: linear-gradient(135deg, var(--bs-primary) 0%, #6366f1 100%);
    border: none;
}

.btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(79, 70, 229, 0.4);
}

/* ===== Forms Enhancement ===== */
.form-control,
.form-select {
    border-radius: 0.5rem;
    border: 1px solid #d1d5db;
    padding: 0.625rem 0.875rem;
}

.form-control:focus,
.form-select:focus {
    border-color: var(--bs-primary);
    box-shadow: 0 0 0 0.2rem rgba(79, 70, 229, 0.25);
}

[data-bs-theme="dark"] .form-control,
[data-bs-theme="dark"] .form-select {
    background: #374151;
    border-color: #4b5563;
    color: #f9fafb;
}

/* ===== Toggle Switch (Bootstrap Form Switch) ===== */
.form-check-input {
    width: 3rem;
    height: 1.5rem;
    cursor: pointer;
}

.form-check-input:checked {
    background-color: var(--bs-primary);
    border-color: var(--bs-primary);
}

/* ===== Modal Enhancement ===== */
.modal-content {
    border: none;
    border-radius: 1rem;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
}

.modal-header {
    border-bottom: 1px solid #e5e7eb;
    padding: 1.5rem;
}

[data-bs-theme="dark"] .modal-content {
    background: #1f2937;
}

[data-bs-theme="dark"] .modal-header {
    border-bottom-color: #374151;
}

/* ===== Login Page =====
 * Nur Dark-Variante - die App laeuft durchgaengig mit data-bs-theme="dark".
 */
.login-page {
    background: linear-gradient(135deg, #1e3a8a 0%, #581c87 100%);
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
}

.login-card {
    max-width: 450px;
    border: none;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    border-radius: 1rem;
}

.logo h1 {
    color: var(--bs-primary);
    font-weight: 700;
}

/* ===== Pairing Code Display ===== */
.pairing-code {
    font-size: 3rem;
    font-weight: 700;
    color: var(--bs-primary);
    font-family: 'Courier New', monospace;
    letter-spacing: 0.5rem;
    text-align: center;
    padding: 1rem;
    background: linear-gradient(135deg, #eef2ff 0%, #e0e7ff 100%);
    border-radius: 0.75rem;
    border: 2px dashed var(--bs-primary);
}

[data-bs-theme="dark"] .pairing-code {
    background: linear-gradient(135deg, #1e293b 0%, #334155 100%);
    border-color: #6366f1;
}

/* ===== Table Enhancement ===== */
.table {
    border-radius: 0.5rem;
    overflow: hidden;
}

.table thead th {
    background: #f9fafb;
    border-bottom: 2px solid #e5e7eb;
    font-weight: 600;
    text-transform: uppercase;
    font-size: 0.75rem;
    letter-spacing: 0.05em;
}

[data-bs-theme="dark"] .table thead th {
    background: #1f2937;
    border-bottom-color: #374151;
}

.table tbody tr:hover {
    background: #f9fafb;
}

[data-bs-theme="dark"] .table tbody tr:hover {
    background: #1f2937;
}

/* ===== Alert Enhancement ===== */
.alert {
    border: none;
    border-radius: 0.75rem;
    border-left: 4px solid;
}

.alert-success {
    border-left-color: var(--bs-success);
    background: #ecfdf5;
    color: #065f46;
}

.alert-danger {
    border-left-color: var(--bs-danger);
    background: #fef2f2;
    color: #991b1b;
}

[data-bs-theme="dark"] .alert-success {
    background: #064e3b;
    color: #d1fae5;
}

[data-bs-theme="dark"] .alert-danger {
    background: #7f1d1d;
    color: #fecaca;
}

/* ===== Dark Mode Toggle Button ===== */
/* ===== Responsive Design ===== */
@media (max-width: 991.98px) {
    /* Sidebar wird zum Off-Canvas-Panel, das per Burger-Button (.sidebar-toggle)
       ein- und ausgefahren wird. Default: nach links ausgeblendet. */
    .sidebar {
        z-index: 1045;
        transform: translateX(-100%);
        transition: transform 0.3s ease;
        box-shadow: 0 0 24px rgba(0, 0, 0, 0.25);
    }

    .sidebar.show {
        transform: translateX(0);
    }

    .main-content {
        margin-left: 0;
        padding-top: 4.5rem; /* Platz fuer den fixierten Burger-Button */
    }
}

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

    .page-header h1 {
        font-size: 1.5rem;
    }

    .logo-text {
        font-size: 1.1rem;
    }

    .pairing-code {
        font-size: 2rem;
        letter-spacing: 0.25rem;
    }
}

/* ===== Apply to Devices Section ===== */
.device-checkbox {
    cursor: pointer;
    transition: all 0.2s ease;
}

.device-checkbox:hover {
    background: #f9fafb;
}

[data-bs-theme="dark"] .device-checkbox:hover {
    background: #1f2937;
}

.device-checkbox.current-device {
    background: #eef2ff;
    border: 2px solid var(--bs-primary);
}

[data-bs-theme="dark"] .device-checkbox.current-device {
    background: #1e293b;
}

/* ===== Loading States ===== */
.spinner-border-sm {
    width: 1rem;
    height: 1rem;
}

/* ===== Grid Layouts ===== */
.children-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(350px, 1fr));
    gap: 1.5rem;
    margin-top: 1.5rem;
}

.devices-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(400px, 1fr));
    gap: 1.5rem;
    margin-top: 1.5rem;
}

.screenshots-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 1.5rem;
    margin-top: 1.5rem;
}

/* ===== Child Card ===== */
.child-card {
    background: var(--bs-body-bg);
    color: var(--bs-body-color);
    border: 1px solid var(--bs-border-color);
    border-radius: 0.75rem;
    padding: 1.5rem;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

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

[data-bs-theme="dark"] .child-card {
    background: #1f2937;
    border-color: #374151;
}

.child-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid #e5e7eb;
}

[data-bs-theme="dark"] .child-card-header {
    border-bottom-color: #374151;
}

.child-card-header h3 {
    margin: 0;
    font-size: 1.25rem;
    font-weight: 600;
}

/* ===== Device Card ===== */
.device-card {
    background: var(--bs-body-bg);
    color: var(--bs-body-color);
    border: 1px solid var(--bs-border-color);
    border-radius: 0.75rem;
    padding: 1.5rem;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

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

[data-bs-theme="dark"] .device-card {
    background: #1f2937;
    border-color: #374151;
}

.device-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid #e5e7eb;
}

[data-bs-theme="dark"] .device-header {
    border-bottom-color: #374151;
}

.device-header h3 {
    margin: 0;
    font-size: 1.25rem;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

.device-status-indicator {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    display: inline-block;
    margin-right: 0.5rem;
}

.device-status-indicator.online {
    background: var(--bs-success);
    box-shadow: 0 0 8px var(--bs-success);
    animation: pulse 2s infinite;
}

.device-status-indicator.offline {
    background: var(--bs-secondary);
}

.device-info {
    margin: 1rem 0;
}

.info-row {
    display: flex;
    justify-content: space-between;
    padding: 0.5rem 0;
    border-bottom: 1px solid #f3f4f6;
}

[data-bs-theme="dark"] .info-row {
    border-bottom-color: #374151;
}

.info-label {
    font-weight: 500;
    color: #6b7280;
}

[data-bs-theme="dark"] .info-label {
    color: #9ca3af;
}

.device-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-top: 1rem;
}

.device-actions .btn {
    flex: 1;
    min-width: fit-content;
}

.device-id {
    font-family: 'Courier New', monospace;
    font-size: 0.75rem;
    color: #6b7280;
}

.lock-indicator {
    font-size: 1.25rem;
    margin-left: 0.5rem;
}

/* ===== Badges ===== */
.badge {
    padding: 0.25rem 0.75rem;
    border-radius: 0.375rem;
    font-size: 0.75rem;
    font-weight: 600;
}

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

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

.badge-warning {
    background: var(--bs-warning);
    color: #000;
}

.badge-info {
    background: var(--bs-info);
    color: white;
}

/* ===== Devices List (in child card) ===== */
.devices-list {
    list-style: none;
    padding: 0;
    margin: 0.5rem 0 0 0;
}

.device-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem;
    margin: 0.5rem 0;
    background: #f9fafb;
    border-radius: 0.5rem;
    border-left: 3px solid var(--bs-info);
}

[data-bs-theme="dark"] .device-item {
    background: #374151;
}

.device-status {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    display: inline-block;
    margin-right: 8px;
}

.device-status.online {
    background: var(--bs-success);
    box-shadow: 0 0 6px var(--bs-success);
}

.device-status.offline {
    background: var(--bs-secondary);
}

.last-seen {
    font-size: 0.75rem;
    color: #6b7280;
    margin-left: 16px;
}

/* ===== Utility Classes ===== */
.text-gradient {
    background: linear-gradient(135deg, var(--bs-primary) 0%, #6366f1 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.shadow-sm-hover {
    transition: box-shadow 0.2s ease;
}

.shadow-sm-hover:hover {
    box-shadow: 0 0.125rem 0.5rem rgba(0, 0, 0, 0.15) !important;
}

/* ===== Custom ===== */

.child-devices ol, ul {
    padding-left: 0rem;
}
