/* Custom styles for Customer Management Tool */

/* CSS Variables for Dark Mode */
:root {
    --bs-body-bg: #ffffff;
    --bs-body-color: #212529;
    --bs-primary: #0d6efd;
    --bs-light: #f8f9fa;
    --bs-dark: #212529;
    --bs-border-color: #dee2e6;
    --card-bg: #ffffff;
    --card-shadow: rgba(0, 0, 0, 0.075);
    --card-shadow-hover: rgba(0, 0, 0, 0.15);
    --table-hover-bg: rgba(0, 123, 255, 0.05);
    --note-border-color: #007bff;
    --code-bg: #f8f9fa;
    --code-color: #e83e8c;
    --pre-bg: #f8f9fa;
    --pre-border-color: #dee2e6;
    --blockquote-border-color: #dee2e6;
    --blockquote-color: #6c757d;
    --table-border-color: #dee2e6;
    --table-header-bg: #f8f9fa;
    --footer-bg: #ffffff;
    --footer-border-color: #dee2e6;
}

[data-bs-theme="dark"] {
    --bs-body-bg: #0d1117;
    --bs-body-color: #e6edf3;
    --bs-primary: #58a6ff;
    --bs-light: #21262d;
    --bs-dark: #0d1117;
    --bs-border-color: #30363d;
    --card-bg: #21262d;
    --card-shadow: rgba(0, 0, 0, 0.3);
    --card-shadow-hover: rgba(0, 0, 0, 0.5);
    --table-hover-bg: rgba(88, 166, 255, 0.1);
    --note-border-color: #58a6ff;
    --code-bg: #161b22;
    --code-color: #ff7b72;
    --pre-bg: #161b22;
    --pre-border-color: #30363d;
    --blockquote-border-color: #30363d;
    --blockquote-color: #8b949e;
    --table-border-color: #30363d;
    --table-header-bg: #161b22;
    --footer-bg: #21262d;
    --footer-border-color: #30363d;
}

body {
    background-color: var(--bs-body-bg);
    color: var(--bs-body-color);
    transition: background-color 0.3s ease, color 0.3s ease;
}

.navbar-brand {
    font-weight: 600;
    display: inline-block;
    text-decoration: none !important;
}

.brand-text {
    display: inline-block;
    transition: transform 0.8s ease;
}

.letter {
    display: inline-block;
    transition: opacity 0.3s ease;
}

#brand-link:hover .brand-text {
    transform: rotateY(180deg);
}

#brand-link:hover .letter:nth-child(1) { animation: letter-fade 0.3s ease 0.8s both; }
#brand-link:hover .letter:nth-child(2) { animation: letter-fade 0.3s ease 0.9s both; }
#brand-link:hover .letter:nth-child(3) { animation: letter-fade 0.3s ease 1.0s both; }
#brand-link:hover .letter:nth-child(4) { animation: letter-fade 0.3s ease 1.1s both; }
#brand-link:hover .letter:nth-child(5) { animation: letter-fade 0.3s ease 1.2s both; }
#brand-link:hover .letter:nth-child(6) { animation: letter-fade 0.3s ease 1.3s both; }
#brand-link:hover .letter:nth-child(7) { animation: letter-fade 0.3s ease 1.4s both; }
#brand-link:hover .letter:nth-child(8) { animation: letter-fade 0.3s ease 1.5s both; }
#brand-link:hover .letter:nth-child(9) { animation: letter-fade 0.3s ease 1.6s both; }
#brand-link:hover .letter:nth-child(10) { animation: letter-fade 0.3s ease 1.7s both; }
#brand-link:hover .letter:nth-child(11) { animation: letter-fade 0.3s ease 1.8s both; }
#brand-link:hover .letter:nth-child(12) { animation: letter-fade 0.3s ease 1.9s both; }
#brand-link:hover .letter:nth-child(13) { animation: letter-fade 0.3s ease 2.0s both; }
#brand-link:hover .letter:nth-child(14) { animation: letter-fade 0.3s ease 2.1s both; }
#brand-link:hover .letter:nth-child(15) { animation: letter-fade 0.3s ease 2.2s both; }
#brand-link:hover .letter:nth-child(16) { animation: letter-fade 0.3s ease 2.3s both; }

@keyframes letter-fade {
    0% { opacity: 1; transform: translateY(0); }
    50% { opacity: 0; transform: translateY(-10px); }
    100% { opacity: 1; transform: translateY(0); }
}

.card {
    border: none;
    background-color: var(--card-bg);
    box-shadow: 0 0.125rem 0.25rem var(--card-shadow);
    transition: box-shadow 0.15s ease-in-out, background-color 0.3s ease;
}

.card:hover {
    box-shadow: 0 0.5rem 1rem var(--card-shadow-hover);
}

.table-hover tbody tr:hover {
    background-color: var(--table-hover-bg) !important;
}

.status-indicator {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    display: inline-block;
}

.status-green {
    background-color: #28a745;
}

.status-yellow {
    background-color: #ffc107;
}

.status-red {
    background-color: #dc3545;
}

.breadcrumb {
    background-color: transparent;
    padding: 0;
    margin-bottom: 1rem;
}

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

.footer {
    background-color: var(--footer-bg);
    border-top: 1px solid var(--footer-border-color);
}

/* Dark Mode Toggle Button */
#dark-mode-toggle {
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
}

#dark-mode-toggle:hover {
    background-color: rgba(255, 255, 255, 0.1);
}

[data-bs-theme="dark"] #dark-mode-toggle {
    border-color: rgba(255, 255, 255, 0.2);
    color: rgba(255, 255, 255, 0.7);
}

[data-bs-theme="dark"] #dark-mode-toggle:hover {
    background-color: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.4);
    color: white;
}

/* Navbar alignment improvements */
.navbar-nav .nav-item .nav-link {
    display: flex;
    align-items: center;
    min-height: 40px;
    border-radius: 0.375rem;
    margin: 0.125rem 0.25rem;
    transition: all 0.2s ease-in-out;
}

/* Active navigation state */
.navbar-nav .nav-item .nav-link.active {
    background-color: #0d6efd;
    color: white !important;
    font-weight: 600;
    box-shadow: 0 2px 4px rgba(13, 110, 253, 0.3);
}

.navbar-nav .nav-item .nav-link:hover:not(.active) {
    background-color: #0d6efd;
    color: white !important;
    font-weight: 500;
}

/* Dark mode active navigation state */
[data-bs-theme="dark"] .navbar-nav .nav-item .nav-link.active {
    background-color: #58a6ff;
    color: white !important;
    box-shadow: 0 2px 4px rgba(88, 166, 255, 0.4);
}

[data-bs-theme="dark"] .navbar-nav .nav-item .nav-link:hover:not(.active) {
    background-color: rgba(88, 166, 255, 0.25);
    color: #58a6ff !important;
    font-weight: 500;
}

/* Completely disable browser default tooltips */
[data-bs-toggle*="tooltip"] {
    pointer-events: auto !important;
}

[data-bs-toggle*="tooltip"]:hover::before,
[data-bs-toggle*="tooltip"]:hover::after,
[data-bs-toggle*="tooltip"]::before,
[data-bs-toggle*="tooltip"]::after {
    display: none !important;
    content: none !important;
    visibility: hidden !important;
}

/* Additional tooltip suppression */
button[data-bs-toggle*="tooltip"]:hover {
    position: relative;
}

button[data-bs-toggle*="tooltip"]:hover::after {
    content: "" !important;
    display: none !important;
}

/* Disable browser default tooltips for Bootstrap tooltip elements */
[data-bs-toggle*="tooltip"]:hover::before,
[data-bs-toggle*="tooltip"]:hover::after {
    display: none !important;
}

/* Specific fix for persistent browser tooltip */
[data-bs-toggle*="tooltip"][title] {
    position: relative !important;
}

[data-bs-toggle*="tooltip"][title]::after {
    content: none !important;
    display: none !important;
}

/* Custom form controls */
.form-select:focus,
.form-control:focus {
    border-color: #86b7fe;
    box-shadow: 0 0 0 0.25rem rgba(13, 110, 253, 0.25);
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .table-responsive {
        font-size: 0.875rem;
    }
    
    .btn-sm {
        padding: 0.25rem 0.5rem;
        font-size: 0.75rem;
    }
    
    /* Hide some table columns on mobile */
    .table td:nth-child(n+4), 
    .table th:nth-child(n+4) {
        display: none;
    }
    
    /* Show only first 3 columns on mobile */
    .table .mobile-show {
        display: table-cell !important;
    }
    
    /* Adjust card spacing on mobile */
    .card {
        margin-bottom: 1rem;
    }
    
    /* Stack dashboard cards vertically on mobile */
    .row .col-md-3 {
        margin-bottom: 1rem;
    }
}

@media (max-width: 576px) {
    /* Further mobile optimizations */
    .container-fluid {
        padding-left: 0.75rem;
        padding-right: 0.75rem;
    }
    
    .navbar-brand {
        font-size: 1rem;
    }
    
    .card-body {
        padding: 0.75rem;
    }
    
    h1, h2 {
        font-size: 1.25rem;
    }
    
    .table-responsive {
        font-size: 0.75rem;
    }
}

/* Animation for alerts */
.alert {
    animation: slideInDown 0.3s ease-in-out;
}

@keyframes slideInDown {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

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

/* Custom badge styles */
.badge {
    font-weight: 500;
}

/* Note styling */
.note-item {
    border-left: 3px solid var(--note-border-color);
    padding-left: 1rem;
    margin-bottom: 1rem;
}

/* Email autocomplete dropdown (owner / sales-contact assignment) */
.email-autocomplete-menu {
    position: absolute;
    z-index: 1080;
    background: var(--card-bg);
    border: 1px solid var(--bs-border-color);
    border-radius: 0.375rem;
    box-shadow: 0 0.5rem 1rem var(--card-shadow-hover);
    max-height: 16rem;
    overflow-y: auto;
    padding: 0.25rem 0;
}
.email-autocomplete-item {
    padding: 0.35rem 0.75rem;
    cursor: pointer;
    line-height: 1.25;
}
.email-autocomplete-item:hover,
.email-autocomplete-item.active {
    background: var(--table-hover-bg);
}
.email-autocomplete-item .eac-name {
    font-size: 0.9rem;
}
.email-autocomplete-item .eac-email {
    font-size: 0.8rem;
    color: var(--blockquote-color);
}

/* Changelog timeline page */
.changelog-page {
    max-width: 760px;
    margin: 0 auto;
}
.changelog-header {
    margin-bottom: 1.5rem;
}
.changelog-title {
    font-size: 1.9rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
}
.changelog-intro {
    color: var(--blockquote-color);
}
.changelog-intro p {
    margin-bottom: 0.25rem;
}
.changelog-updated {
    margin-top: 0.5rem;
}
.changelog-version {
    padding: 1.25rem 0;
    border-top: 1px solid var(--bs-border-color);
}
.changelog-version:first-child {
    border-top: none;
    padding-top: 0.5rem;
}
.changelog-version-head {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    margin-bottom: 0.75rem;
}
.changelog-pill {
    display: inline-block;
    background: #198754;
    color: #fff;
    font-size: 0.8rem;
    font-weight: 600;
    padding: 0.15rem 0.55rem;
    border-radius: 999px;
    letter-spacing: 0.02em;
}
.changelog-date {
    color: var(--blockquote-color);
    font-size: 0.85rem;
}
.changelog-section {
    margin-bottom: 0.75rem;
}
.changelog-section:last-child {
    margin-bottom: 0;
}
.changelog-section-label {
    font-size: 0.78rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--blockquote-color);
    margin-bottom: 0.3rem;
}
.changelog-items {
    margin: 0;
    padding-left: 1.25rem;
}
.changelog-items li {
    margin-bottom: 0.3rem;
    line-height: 1.5;
}
.changelog-extra {
    font-size: 0.9rem;
}
.changelog-page code {
    background: var(--code-bg);
    color: var(--code-color);
    padding: 0.1rem 0.25rem;
    border-radius: 0.2rem;
}

/* Konami party mode */
body.party-mode {
    filter: hue-rotate(35deg) saturate(1.15);
    transition: filter .3s ease;
}
.confetti {
    position: fixed;
    top: -12px;
    width: 8px;
    height: 12px;
    opacity: .95;
    animation: confetti-fall linear forwards;
    transform: rotate(15deg);
    z-index: 1056; /* above modal backdrop */
}
@keyframes confetti-fall {
    to { transform: translateY(105vh) rotate(360deg); opacity: 1; }
}

/* Spaceship Game Styles */
.spaceship-game-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    pointer-events: none;
    z-index: 9999;
}

.spaceship {
    position: absolute;
    font-size: 40px;
    pointer-events: none;
    user-select: none;
    filter: drop-shadow(0 0 10px rgba(255, 255, 100, 0.8));
    z-index: 10000;
    transform-origin: center center;
}

.bullet {
    position: absolute;
    font-size: 20px;
    pointer-events: none;
    user-select: none;
    filter: drop-shadow(0 0 5px rgba(255, 100, 0, 0.8));
    z-index: 9999;
    transform-origin: center center;
}

.game-score {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.8);
    color: #fff;
    padding: 15px 30px;
    border-radius: 30px;
    font-family: 'Courier New', monospace;
    font-size: 18px;
    font-weight: bold;
    z-index: 10001;
    pointer-events: none;
    user-select: none;
    box-shadow: 0 0 20px rgba(0, 255, 255, 0.5);
    border: 2px solid rgba(0, 255, 255, 0.3);
}

[data-bs-theme="dark"] .game-score {
    background: rgba(255, 255, 255, 0.15);
    color: #58a6ff;
    box-shadow: 0 0 20px rgba(88, 166, 255, 0.5);
    border: 2px solid rgba(88, 166, 255, 0.3);
}

.explosion-particle {
    position: fixed;
    width: 8px;
    height: 8px;
    background: radial-gradient(circle, #ff6b00 0%, #ff0000 50%, transparent 100%);
    border-radius: 50%;
    pointer-events: none;
    animation: particle-explode 0.5s ease-out forwards;
    z-index: 9998;
}

@keyframes particle-explode {
    0% {
        transform: translate(0, 0) scale(1);
        opacity: 1;
    }
    100% {
        transform: translate(var(--vx), var(--vy)) scale(0);
        opacity: 0;
    }
}

.note-item:last-child {
    margin-bottom: 0;
}

/* Markdown content styling within notes */
.note-item h1, .note-item h2, .note-item h3, 
.note-item h4, .note-item h5, .note-item h6 {
    margin-top: 0.5rem;
    margin-bottom: 0.25rem;
    font-weight: 600;
}

.note-item h1 { font-size: 1.25rem; }
.note-item h2 { font-size: 1.125rem; }
.note-item h3 { font-size: 1rem; }
.note-item h4, .note-item h5, .note-item h6 { font-size: 0.875rem; }

.note-item code {
    background-color: var(--code-bg);
    color: var(--code-color);
    padding: 0.125rem 0.25rem;
    border-radius: 0.25rem;
    font-size: 0.875em;
}

.note-item pre {
    background-color: var(--pre-bg);
    border: 1px solid var(--pre-border-color);
    border-radius: 0.25rem;
    padding: 0.5rem;
    overflow-x: auto;
    font-size: 0.875rem;
    margin: 0.5rem 0;
}

.note-item pre code {
    background-color: transparent;
    color: inherit;
    padding: 0;
}

.note-item blockquote {
    border-left: 3px solid var(--blockquote-border-color);
    padding-left: 1rem;
    margin: 0.5rem 0;
    color: var(--blockquote-color);
    font-style: italic;
}

.note-item ul, .note-item ol {
    margin: 0.5rem 0;
    padding-left: 1.5rem;
}

.note-item table {
    width: 100%;
    margin: 0.5rem 0;
    border-collapse: collapse;
}

.note-item th, .note-item td {
    border: 1px solid var(--table-border-color);
    padding: 0.25rem 0.5rem;
    text-align: left;
}

.note-item th {
    background-color: var(--table-header-bg);
    font-weight: 600;
}

.note-item a {
    color: var(--bs-primary);
    text-decoration: none;
}

.note-item a:hover {
    text-decoration: underline;
}

/* Shimmer sweep for the profile role badge */
.badge-shimmer {
    position: relative;
    overflow: hidden;
}

.badge-shimmer::after {
    content: "";
    position: absolute;
    top: 0;
    left: -150%;
    width: 150%;
    height: 100%;
    background: linear-gradient(
        100deg,
        rgba(255, 255, 255, 0) 30%,
        rgba(255, 255, 255, 0.55) 50%,
        rgba(255, 255, 255, 0) 70%
    );
    animation: badge-shimmer 2.8s ease-in-out infinite;
}

@keyframes badge-shimmer {
    0%   { left: -150%; }
    55%  { left: 150%; }
    100% { left: 150%; }
}

/* Respect users who prefer reduced motion */
@media (prefers-reduced-motion: reduce) {
    .badge-shimmer::after {
        animation: none;
    }
}

/* Compact product badges so several fit on one line, with a muted LR/HR suffix */
.product-badge {
    font-size: 0.7rem;
    font-weight: 600;
    padding: 0.2em 0.45em;
}
.product-badge .product-class {
    font-size: 0.6em;
    font-weight: 700;
    opacity: 0.65;
    margin-left: 0.15em;
    top: -0.4em;
}
