/* MailflowMon - Custom Styles */

/* -----------------------------------------------------------------------
   Layout
   ----------------------------------------------------------------------- */

/* Sidebar */
.sidebar {
    min-height: calc(100vh - 56px);
    border-right: 1px solid var(--bs-border-color);
    background-color: var(--bs-body-bg);
}

.sidebar .nav-link {
    color: var(--bs-body-color);
    padding: 0.6rem 1rem;
    border-radius: 0.375rem;
    margin: 0.1rem 0.5rem;
    transition: background-color 0.15s ease, color 0.15s ease;
    font-size: 0.9rem;
}

.sidebar .nav-link:hover {
    background-color: var(--bs-tertiary-bg);
}

.sidebar .nav-link.active {
    background-color: var(--bs-primary);
    color: #fff;
}

.sidebar .nav-link i {
    width: 1.25rem;
    text-align: center;
    margin-right: 0.5rem;
}

/* Sidebar footer */
.sidebar-footer {
    padding: 0.75rem 1rem;
    border-top: 1px solid var(--bs-border-color);
    font-size: 0.75rem;
    color: var(--bs-secondary-color);
}

/* -----------------------------------------------------------------------
   Cards
   ----------------------------------------------------------------------- */
.card {
    transition: box-shadow 0.15s ease, transform 0.15s ease;
}

.card:hover {
    box-shadow: 0 0.25rem 0.75rem rgba(0, 0, 0, 0.08) !important;
}

/* Stat card number animation */
.card .h3, .card h3 {
    transition: color 0.15s ease;
}

/* -----------------------------------------------------------------------
   Status indicators
   ----------------------------------------------------------------------- */
.badge {
    font-weight: 500;
}

.status-dot {
    display: inline-block;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    vertical-align: middle;
}

.status-dot.success { background-color: var(--bs-success); }
.status-dot.danger { background-color: var(--bs-danger); }
.status-dot.warning { background-color: var(--bs-warning); }
.status-dot.secondary { background-color: var(--bs-secondary); }

/* Pulsing status dot for active monitors */
.status-dot.pulse {
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0% { box-shadow: 0 0 0 0 rgba(25, 135, 84, 0.5); }
    70% { box-shadow: 0 0 0 6px rgba(25, 135, 84, 0); }
    100% { box-shadow: 0 0 0 0 rgba(25, 135, 84, 0); }
}

/* -----------------------------------------------------------------------
   Tables
   ----------------------------------------------------------------------- */
.table > :not(caption) > * > * {
    vertical-align: middle;
}

.table-hover > tbody > tr {
    transition: background-color 0.1s ease;
}

/* Compact table variant */
.table-compact th,
.table-compact td {
    padding: 0.4rem 0.5rem;
    font-size: 0.85rem;
}

/* -----------------------------------------------------------------------
   Charts
   ----------------------------------------------------------------------- */
.chart-container {
    position: relative;
    height: 300px;
    width: 100%;
}

/* Responsive chart height */
@media (max-width: 767.98px) {
    .chart-container {
        height: 220px;
    }
}

/* -----------------------------------------------------------------------
   Code & Technical Display
   ----------------------------------------------------------------------- */
.dns-record {
    font-family: 'SF Mono', 'Monaco', 'Inconsolata', 'Fira Code', 'Courier New', monospace;
    background-color: var(--bs-tertiary-bg);
    padding: 1rem;
    border-radius: 0.375rem;
    border: 1px solid var(--bs-border-color);
    word-break: break-all;
    font-size: 0.85rem;
}

.header-raw {
    font-family: 'SF Mono', 'Monaco', 'Inconsolata', 'Fira Code', 'Courier New', monospace;
    font-size: 0.8rem;
    max-height: 400px;
    overflow-y: auto;
    white-space: pre-wrap;
    word-break: break-all;
    background-color: var(--bs-tertiary-bg);
    padding: 1rem;
    border-radius: 0.375rem;
    border: 1px solid var(--bs-border-color);
}

/* API key display */
.api-key-display {
    font-family: 'SF Mono', 'Monaco', 'Inconsolata', 'Fira Code', 'Courier New', monospace;
    font-size: 0.85rem;
    letter-spacing: 0.5px;
}

/* -----------------------------------------------------------------------
   Auth Pages
   ----------------------------------------------------------------------- */
.min-vh-100 {
    padding: 2rem 0;
}

.auth-card {
    max-width: 420px;
    width: 100%;
}

.auth-logo {
    font-size: 2.5rem;
    color: var(--bs-primary);
}

/* -----------------------------------------------------------------------
   Loading & Spinners
   ----------------------------------------------------------------------- */
.spinner-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
    border-radius: inherit;
}

/* Skeleton loading placeholder */
.skeleton {
    background: linear-gradient(90deg, var(--bs-tertiary-bg) 25%, var(--bs-secondary-bg) 50%, var(--bs-tertiary-bg) 75%);
    background-size: 200% 100%;
    animation: skeleton-loading 1.5s infinite;
    border-radius: 0.25rem;
}

@keyframes skeleton-loading {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* -----------------------------------------------------------------------
   Auto-refresh indicator
   ----------------------------------------------------------------------- */
.refresh-indicator {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    font-size: 0.75rem;
    color: var(--bs-success);
}

.refresh-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background-color: var(--bs-success);
    animation: blink 2s infinite;
}

@keyframes blink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.3; }
}

/* -----------------------------------------------------------------------
   Responsive Adjustments
   ----------------------------------------------------------------------- */
@media (max-width: 767.98px) {
    .sidebar {
        min-height: auto;
        border-right: none;
        border-bottom: 1px solid var(--bs-border-color);
    }

    main {
        padding-top: 1rem !important;
    }

    /* Stack action buttons on mobile */
    .d-flex.gap-2 {
        flex-wrap: wrap;
    }

    /* Responsive table text */
    .table-responsive {
        font-size: 0.85rem;
    }

    /* Compact stat cards on mobile */
    .card-body h3 {
        font-size: 1.4rem;
    }
}

@media (max-width: 575.98px) {
    /* Full-width buttons on very small screens */
    .btn-group-sm > .btn {
        font-size: 0.75rem;
        padding: 0.2rem 0.5rem;
    }
}

/* -----------------------------------------------------------------------
   Dark Mode Support
   ----------------------------------------------------------------------- */
[data-bs-theme="dark"] .spinner-overlay {
    background: rgba(33, 37, 41, 0.8);
}

[data-bs-theme="dark"] .card:hover {
    box-shadow: 0 0.25rem 0.75rem rgba(0, 0, 0, 0.25) !important;
}

[data-bs-theme="dark"] .dns-record,
[data-bs-theme="dark"] .header-raw {
    border-color: var(--bs-border-color);
}

/* -----------------------------------------------------------------------
   Utility Classes
   ----------------------------------------------------------------------- */

/* Truncate with ellipsis */
.text-truncate-2 {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* Smooth scroll */
html {
    scroll-behavior: smooth;
}

/* Focus styles for accessibility */
*:focus-visible {
    outline: 2px solid var(--bs-primary);
    outline-offset: 2px;
}

/* No-wrap helper for table cells */
.text-nowrap-sm {
    white-space: nowrap;
}

@media (max-width: 767.98px) {
    .text-nowrap-sm {
        white-space: normal;
    }
}

/* Transition all for smooth state changes */
.transition-all {
    transition: all 0.2s ease;
}

/* Empty state illustration */
.empty-state {
    padding: 3rem 1rem;
    text-align: center;
    color: var(--bs-secondary-color);
}

.empty-state i {
    font-size: 3rem;
    margin-bottom: 1rem;
    opacity: 0.5;
}
