/* Global Application Styles */

/* ============================================
   HEADER STYLES - Dark Mode
   ============================================ */

.app-header {
    width: 100%;
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 50%, #0f3460 100%);
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
    position: sticky;
    top: 0;
    z-index: 1030;
}

.app-header .navbar {
    padding: 0.5rem 1rem;
    background: transparent !important;
    width: 100%;
    max-width: 100%;
    position: relative;
}

.app-header .container-fluid {
    max-width: 100%;
    padding-left: 1.5rem;
    padding-right: 1.5rem;
}

/* Logo Styles */
.header-logo {
    height: 40px;
    width: auto;
    transition: opacity 0.2s ease;
}

.header-logo:hover {
    opacity: 0.85;
}

/* Desktop logo - visible on larger screens */
.desktop-logo {
    display: block;
}

/* Mobile logo (icon) - hidden on larger screens */
.mobile-logo {
    display: none;
}

/* Responsive logo switching */
@media (max-width: 576px) {
    .desktop-logo {
        display: none;
    }
    
    .mobile-logo {
        display: block;
        height: 32px;
    }
}

/* Navbar brand adjustments */
.app-header .navbar-brand {
    padding: 0;
    margin-right: 1.5rem;
    display: flex;
    align-items: center;
}

/* Dark mode navigation links */
.app-header .navbar-nav .nav-link {
    color: rgba(255, 255, 255, 0.85);
    font-weight: 500;
    padding: 0.5rem 1rem;
    border-radius: 6px;
    transition: all 0.2s ease;
}

.app-header .navbar-nav .nav-link:hover {
    color: #ffffff;
    background-color: rgba(255, 255, 255, 0.1);
}

.app-header .navbar-nav .nav-link.active {
    color: #ffffff;
    background-color: rgba(255, 255, 255, 0.15);
}

/* Dark mode dropdown styling */
.app-header .dropdown-menu {
    background: #1a1a2e;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-top: 2px solid #4da8da;
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.4);
}

.app-header .dropdown-item {
    color: rgba(255, 255, 255, 0.85);
    padding: 0.5rem 1rem;
    transition: all 0.2s ease;
}

.app-header .dropdown-item:hover {
    background-color: rgba(255, 255, 255, 0.1);
    color: #ffffff;
}

.app-header .dropdown-item.active {
    background-color: #4da8da;
    color: #ffffff;
}

.app-header .dropdown-divider {
    border-color: rgba(255, 255, 255, 0.1);
}

/* Currency rates dark mode */
.app-header .currency-rate-item {
    color: rgba(255, 255, 255, 0.85);
}

.app-header .currency-rate-item strong {
    color: #4da8da;
}

.app-header .currency-rate-value {
    color: rgba(255, 255, 255, 0.7);
}

.app-header .currency-rate-value:hover {
    background-color: rgba(255, 255, 255, 0.1);
    color: #ffffff;
}

/* Dark mode form controls in header */
.app-header .form-control {
    background-color: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.2);
    color: #ffffff;
}

.app-header .form-control:focus {
    background-color: rgba(255, 255, 255, 0.15);
    border-color: #4da8da;
    color: #ffffff;
    box-shadow: 0 0 0 0.2rem rgba(77, 168, 218, 0.25);
}

.app-header .form-control::placeholder {
    color: rgba(255, 255, 255, 0.5);
}

/* Dark mode buttons in header */
.app-header .btn-outline-primary {
    color: #4da8da;
    border-color: #4da8da;
}

.app-header .btn-outline-primary:hover {
    background-color: #4da8da;
    border-color: #4da8da;
    color: #ffffff;
}

/* Settings dropdown button dark mode */
.app-header .btn-link.nav-link {
    color: rgba(255, 255, 255, 0.85) !important;
    text-decoration: none;
}

.app-header .btn-link.nav-link:hover {
    color: #ffffff !important;
}

/* Loading spinner in header */
.app-header .spinner-border-sm {
    color: #4da8da;
}

/* ============================================
   END HEADER STYLES
   ============================================ */

/* Settings dropdown styles */
.dropdown-menu {
    min-width: 200px;
}

/* Currency rates in header */
.currency-rates-wrapper {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.currency-rates-container {
    font-size: 0.875rem;
    padding: 0.25rem 0;
}

.currency-rates-inline {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.25rem;
}

.currency-rate-item {
    white-space: nowrap;
}

.currency-rate-item strong {
    font-weight: 600;
    margin-right: 0.25rem;
}

.currency-rate-item .text-muted {
    color: var(--bs-secondary) !important;
}

.currency-rate-value {
    color: var(--bs-secondary);
    cursor: pointer;
    padding: 2px 4px;
    border-radius: 3px;
    transition: background-color 0.2s;
    user-select: none;
}

.currency-rate-value:hover {
    background-color: var(--bs-light);
    color: var(--bs-primary);
}

.currency-rate-input {
    width: 80px;
    padding: 2px 4px;
    border: 1px solid var(--bs-primary) !important;
    border-radius: 3px;
    font-size: 0.875rem;
    outline: none;
}

.currency-rates-controls {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.currency-rates-controls .form-control-sm {
    height: calc(1.5em + 0.5rem + 2px);
    padding: 0.25rem 0.5rem;
    font-size: 0.875rem;
}

#refresh-currency-rates {
    padding: 0.25rem 0.5rem;
    line-height: 1.5;
}

/* Navigation menu styles */
.navbar-nav .dropdown-toggle::after {
    margin-left: 0.5rem;
}

.navbar-nav .nav-link.disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Nested dropdown (submenu) styles */
.dropdown-submenu {
    position: relative;
}

.dropdown-submenu > .dropdown-menu {
    position: absolute;
    left: 100%;
    top: -0.5rem;
    margin-left: 0;
    min-width: 180px;
    display: none;
    /* Inherits dark mode styles from .app-header .dropdown-menu */
}

/* Override Bootstrap's dropdown-toggle ::after for submenu (right arrow) */
.dropdown-menu .dropdown-submenu > a.dropdown-toggle::after {
    display: inline-block;
    margin-left: 0.5em;
    vertical-align: 0.1em;
    content: "";
    border-top: 0.3em solid transparent !important;
    border-right: 0 !important;
    border-bottom: 0.3em solid transparent !important;
    border-left: 0.3em solid !important;
}

/* Show submenu on hover */
.dropdown-submenu:hover > .dropdown-menu {
    display: block;
}

/* Highlight submenu trigger on hover */
.app-header .dropdown-submenu:hover > a {
    background-color: rgba(255, 255, 255, 0.1);
    color: #ffffff;
}

/* Mobile menu backdrop overlay and body scroll lock */
@media (max-width: 992px) {
    body.navbar-open {
        overflow: hidden;
    }
    
    body.navbar-open::before {
        content: '';
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: rgba(0, 0, 0, 0.5);
        z-index: 1019;
        animation: fadeIn 0.3s ease;
    }
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* Adjust submenu position if it goes off screen */
@media (max-width: 992px) {
    .dropdown-submenu > .dropdown-menu {
        position: static;
        left: auto;
        top: auto;
        margin-left: 1rem;
        margin-top: 0.25rem;
        border-left: 3px solid #4da8da;
        border-top: none;
        box-shadow: none;
    }
    
    /* Mobile header adjustments */
    .app-header .navbar-toggler {
        border-color: rgba(255, 255, 255, 0.3);
        padding: 0.25rem 0.5rem;
    }
    
    .app-header .navbar-toggler:focus {
        box-shadow: 0 0 0 0.2rem rgba(77, 168, 218, 0.25);
    }
    
    .app-header .navbar-toggler-icon {
        background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 30 30'%3e%3cpath stroke='rgba%28255, 255, 255, 0.85%29' stroke-linecap='round' stroke-miterlimit='10' stroke-width='2' d='M4 7h22M4 15h22M4 23h22'/%3e%3c/svg%3e");
    }
    
    .app-header .navbar-collapse {
        position: absolute;
        top: 100%;
        left: 0;
        right: 0;
        background: rgba(26, 26, 46, 0.98);
        padding: 1rem;
        margin-top: 0.5rem;
        margin-left: 1rem;
        margin-right: 1rem;
        border-radius: 8px;
        border: 1px solid rgba(255, 255, 255, 0.1);
        box-shadow: 0 8px 25px rgba(0, 0, 0, 0.4);
        z-index: 1020;
        max-height: calc(100vh - 100px);
        overflow-y: auto;
    }
    
    /* Stack right-side items vertically and align to left */
    .app-header .navbar-nav.ms-auto {
        margin-left: 0 !important;
        margin-top: 1rem;
        border-top: 1px solid rgba(255, 255, 255, 0.1);
        padding-top: 1rem;
        align-items: flex-start !important;
    }
    
    /* Improve touch targets on mobile */
    .app-header .navbar-nav .nav-link {
        padding: 0.75rem 1rem;
    }
    
    .app-header .dropdown .btn {
        padding: 0.75rem 1rem;
    }
    
    /* Keep user name visible on mobile - override Bootstrap d-none d-md-inline */
    .app-header .user-name {
        display: inline !important;
    }
    
    /* Currency rates on mobile - stack vertically and align left */
    .app-header .currency-rates-wrapper {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
        width: 100%;
    }
    
    .app-header .currency-rates-container {
        width: 100%;
        text-align: left;
    }
    
    .app-header .currency-rates-controls {
        width: 100%;
        justify-content: flex-start;
    }
}

/* Responsive: Optimize currency rates on small screens */
@media (max-width: 768px) {
    .app-header .currency-rates-container {
        font-size: 0.75rem;
    }
    
    .app-header .currency-rates-inline {
        flex-wrap: wrap;
        justify-content: flex-start;
    }
    
    .app-header .currency-rate-item {
        font-size: 0.75rem;
    }
}

/* Tablet optimizations (577px - 991px) */
@media (min-width: 577px) and (max-width: 991px) {
    .app-header .currency-rates-container {
        font-size: 0.75rem;
    }
    
    .app-header .currency-rates-wrapper {
        flex-direction: column;
        align-items: flex-start;
    }
    
    .app-header .navbar-nav .nav-link {
        padding: 0.5rem 0.75rem;
        font-size: 0.9rem;
    }
    
    .app-header .container-fluid {
        padding-left: 1rem;
        padding-right: 1rem;
    }
}

/* Mobile: Small devices (< 576px) */
@media (max-width: 576px) {
    .app-header .container-fluid {
        padding-left: 0.75rem;
        padding-right: 0.75rem;
    }
    
    .app-header .navbar-brand {
        margin-right: 0.5rem;
    }
    
    .app-header .navbar-nav {
        gap: 0.25rem;
    }
    
    /* Stack mobile menu items */
    .app-header .navbar-collapse .navbar-nav {
        padding: 0.5rem 0;
    }
    
    /* Currency rates - even smaller on very small screens */
    .app-header .currency-rates-container {
        font-size: 0.7rem;
    }
    
    .app-header .currency-rate-item {
        font-size: 0.7rem;
    }
    
    .app-header .currency-rates-controls .form-control-sm {
        font-size: 0.75rem;
        min-width: 120px;
    }
    
    /* Optimize dropdown spacing */
    .app-header .dropdown {
        margin-left: 0;
    }
    
    /* Full width dropdowns on mobile */
    .app-header .dropdown-menu {
        min-width: 100%;
    }
}

/* App container responsiveness */
@media (max-width: 768px) {
    .app-container {
        padding-left: 10px;
        padding-right: 10px;
    }
}

/* ============================================
   USER STATUS DROPDOWN STYLES
   ============================================ */

.user-status-dropdown {
    margin-left: 0.5rem;
}

.user-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid rgba(255, 255, 255, 0.3);
    transition: border-color 0.2s ease;
}

.user-status-dropdown:hover .user-avatar {
    border-color: rgba(255, 255, 255, 0.6);
}

.user-avatar-placeholder {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.15);
    border: 2px solid rgba(255, 255, 255, 0.3);
    display: flex;
    align-items: center;
    justify-content: center;
    color: rgba(255, 255, 255, 0.8);
    font-size: 0.875rem;
}

.user-avatar-large {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    object-fit: cover;
}

.user-avatar-placeholder-large {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: var(--bs-gray-200);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--bs-gray-600);
    font-size: 1.25rem;
}

.user-name {
    color: rgba(255, 255, 255, 0.9);
    font-weight: 500;
    max-width: 120px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.user-status-dropdown .dropdown-header {
    padding: 0.75rem 1rem;
}

.user-status-dropdown .dropdown-menu {
    min-width: 250px;
}

/* User dropdown dark mode adjustments */
.app-header .user-status-dropdown .dropdown-header {
    color: rgba(255, 255, 255, 0.9);
}

.app-header .user-status-dropdown .dropdown-header .text-muted {
    color: rgba(255, 255, 255, 0.6) !important;
}

/* Responsive adjustments */
@media (max-width: 576px) {
    .user-avatar {
        width: 28px;
        height: 28px;
    }
    
    .user-avatar-placeholder {
        width: 28px;
        height: 28px;
        font-size: 0.75rem;
    }
}

/* Currency Rate Readonly Styles */
.currency-rate-readonly {
    cursor: default !important;
    pointer-events: none;
}

/* ============================================
   ENCODE/DECODE GENERATOR MODAL STYLES
   ============================================ */

#encode-decode-form .btn-group {
    display: flex;
}

#encode-decode-form .btn-check:checked + .btn-outline-primary {
    background-color: var(--bs-primary);
    border-color: var(--bs-primary);
    color: #fff;
}

#encode-decode-output {
    background-color: var(--bs-gray-100);
    font-family: var(--bs-font-monospace);
    font-size: 0.9rem;
    resize: vertical;
}

#encode-decode-input {
    resize: vertical;
    font-family: var(--bs-font-monospace);
    font-size: 0.9rem;
}

/* ============================================
   NESTED MODAL STYLES
   ============================================ */

/* Modals with shadow (second+ modal) - no backdrop, shadow instead */
.modal.modal-shadow .modal-dialog {
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3),
                0 4px 16px rgba(0, 0, 0, 0.2),
                0 0 0 1px rgba(255, 255, 255, 0.1);
    border-radius: var(--bs-border-radius);
}

/* Ensure nested modals appear above the first modal */
.modal.modal-shadow {
    z-index: 1056;
}

.modal.show.modal-shadow {
    z-index: 1056;
}

.modal.show:not(.modal-shadow) {
    z-index: 1055;
}
