/**
 * MKB Core Styles
 * Toast notifications, PWA banner, Theme toggle, Cookie consent
 */

/* ============================================
   TOAST NOTIFICATIONS
   ============================================ */
.mkb-toast {
    position: fixed;
    bottom: 100px;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 24px;
    background: #1a1a2e;
    color: #fff;
    border-radius: 12px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
    z-index: 10000;
    opacity: 0;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    font-family: 'Public Sans', -apple-system, BlinkMacSystemFont, sans-serif;
    font-size: 14px;
    font-weight: 500;
    max-width: calc(100vw - 40px);
}

.mkb-toast.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

.mkb-toast-success {
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
}

.mkb-toast-error {
    background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
}

.mkb-toast-info {
    background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
}

.mkb-toast-warning {
    background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
}

.mkb-toast-icon {
    font-size: 18px;
    flex-shrink: 0;
}

.mkb-toast-message {
    flex: 1;
}

/* ============================================
   PWA INSTALL BANNER
   ============================================ */
.pwa-install-banner {
    display: none;
    position: fixed;
    bottom: 20px;
    left: 20px;
    right: 20px;
    z-index: 9999;
    background: var(--theme-color, #0da487);
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
    border-radius: 16px;
    padding: 16px 20px;
    box-shadow: 0 10px 40px rgba(16, 185, 129, 0.4);
    animation: slideUpBanner 0.5s ease-out;
}

.pwa-install-banner.show {
    display: flex;
    align-items: center;
    gap: 14px;
}

@keyframes slideUpBanner {
    from {
        opacity: 0;
        transform: translateY(100%);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.pwa-icon {
    width: 48px;
    height: 48px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    flex-shrink: 0;
}

.pwa-content {
    flex: 1;
    color: #fff;
}

.pwa-title {
    font-weight: 600;
    font-size: 15px;
    margin-bottom: 2px;
}

.pwa-desc {
    font-size: 13px;
    opacity: 0.9;
}

.pwa-install-btn {
    padding: 12px 24px;
    background: #fff;
    border: none;
    border-radius: 10px;
    font-family: inherit;
    font-size: 14px;
    font-weight: 600;
    color: #059669;
    cursor: pointer;
    white-space: nowrap;
    transition: transform 0.2s, box-shadow 0.2s;
}

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

.pwa-close {
    background: none;
    border: none;
    color: rgba(255, 255, 255, 0.7);
    font-size: 24px;
    cursor: pointer;
    padding: 8px;
    line-height: 1;
    transition: color 0.2s;
}

.pwa-close:hover {
    color: #fff;
}

/* ============================================
   THEME TOGGLE BUTTON
   ============================================ */
.theme-toggle-wrapper {
    position: relative;
}

.theme-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    background: var(--theme-color, #0da487);
    border: none;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.3s ease;
    color: #fff;
    font-size: 20px;
}

.theme-toggle:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 15px rgba(var(--theme-color-rgb, 13, 164, 135), 0.4);
}

.theme-toggle .sun-icon {
    display: none;
}

.theme-toggle .moon-icon {
    display: block;
}

body.dark .theme-toggle .sun-icon {
    display: block;
}

body.dark .theme-toggle .moon-icon {
    display: none;
}

/* Theme toggle in settings panel */
.theme-setting-2 .theme-setting-button {
    display: flex;
    gap: 8px;
}

.theme-setting-2 .btn-2 {
    padding: 8px 16px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 500;
    transition: all 0.2s ease;
}

.theme-setting-2 .btn-2.outline,
.theme-setting-2 .btn-2.active {
    background: var(--theme-color, #0da487);
    color: #fff;
}

.theme-setting-2 .btn-2.unline {
    background: transparent;
    border: 1px solid #ddd;
    color: #666;
}

body.dark .theme-setting-2 .btn-2.unline {
    border-color: #444;
    color: #999;
}

/* ============================================
   COOKIE CONSENT BAR
   ============================================ */
.cookie-bar-box {
    position: fixed;
    bottom: 20px;
    left: 20px;
    right: 20px;
    z-index: 9998;
    background: #fff;
    border-radius: 16px;
    padding: 20px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15);
    display: none;
    animation: slideUpBanner 0.5s ease-out;
}

.cookie-bar-box.show {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 16px;
}

body.dark .cookie-bar-box {
    background: #1a1a2e;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.4);
}

.cookie-box {
    display: flex;
    align-items: center;
    gap: 12px;
    flex: 1;
    min-width: 200px;
}

.cookie-image {
    display: flex;
    align-items: center;
    gap: 8px;
}

.cookie-image img {
    width: 40px;
    height: 40px;
}

.cookie-image h2 {
    font-size: 18px;
    font-weight: 700;
    margin: 0;
    color: var(--theme-color, #0da487);
}

.cookie-contain h5 {
    font-size: 14px;
    color: #666;
    margin: 0;
    line-height: 1.5;
}

body.dark .cookie-contain h5 {
    color: #999;
}

.cookie-bar-box .button-group {
    display: flex;
    gap: 10px;
    flex-shrink: 0;
}

.cookie-bar-box .privacy-button {
    padding: 10px 20px;
    background: transparent;
    border: 1px solid #ddd;
    border-radius: 8px;
    font-size: 14px;
    color: #666;
    cursor: pointer;
    transition: all 0.2s;
}

.cookie-bar-box .privacy-button:hover {
    border-color: var(--theme-color, #0da487);
    color: var(--theme-color, #0da487);
}

.cookie-bar-box .ok-button {
    padding: 10px 24px;
    background: var(--theme-color, #0da487);
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    color: #fff;
    cursor: pointer;
    transition: all 0.2s;
}

.cookie-bar-box .ok-button:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(var(--theme-color-rgb, 13, 164, 135), 0.4);
}

body.dark .cookie-bar-box .privacy-button {
    border-color: #444;
    color: #999;
}

/* ============================================
   LOGIN MODAL
   ============================================ */
#loginModal.mkb-login-modal {
    display: none !important;
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    width: 100% !important;
    height: 100% !important;
    z-index: 99999 !important;
    align-items: center !important;
    justify-content: center !important;
    padding: 20px !important;
    margin: 0 !important;
    background: transparent !important;
}

#loginModal.mkb-login-modal.show {
    display: flex !important;
}

#loginModal .mkb-modal-backdrop {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    width: 100% !important;
    height: 100% !important;
    background: rgba(0, 0, 0, 0.7) !important;
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    z-index: 99999 !important;
}

#loginModal .mkb-modal-content {
    position: relative !important;
    background: #fff !important;
    border-radius: 20px !important;
    max-width: 420px !important;
    width: 100% !important;
    max-height: 90vh !important;
    overflow-y: auto !important;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3) !important;
    animation: modalSlideUp 0.3s ease !important;
    z-index: 100000 !important;
    margin: auto !important;
}

@keyframes modalSlideUp {
    from {
        opacity: 0;
        transform: translateY(30px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

#loginModal .mkb-modal-close {
    position: absolute !important;
    top: 12px !important;
    right: 12px !important;
    width: 32px !important;
    height: 32px !important;
    background: rgba(0, 0, 0, 0.05) !important;
    border: none !important;
    border-radius: 50% !important;
    font-size: 20px !important;
    color: #666 !important;
    cursor: pointer !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    transition: all 0.2s ease !important;
    z-index: 10 !important;
    padding: 0 !important;
    line-height: 1 !important;
}

#loginModal .mkb-modal-close:hover {
    background: rgba(239, 68, 68, 0.1) !important;
    color: #ef4444 !important;
    transform: rotate(90deg) !important;
}

#loginModal .login-step {
    padding: 32px 24px !important;
    text-align: center !important;
}

#loginModal .login-step-header {
    margin-bottom: 24px !important;
}

#loginModal .login-icon {
    font-size: 48px !important;
    margin-bottom: 16px !important;
    display: inline-block !important;
}

#loginModal .login-icon.success {
    width: 64px !important;
    height: 64px !important;
    background: linear-gradient(135deg, #10b981 0%, #059669 100%) !important;
    border-radius: 50% !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    color: white !important;
    font-size: 32px !important;
}

#loginModal .login-step-header h3 {
    font-size: 22px !important;
    font-weight: 700 !important;
    color: #1a1a2e !important;
    margin: 0 0 8px 0 !important;
}

#loginModal .login-step-header p {
    font-size: 14px !important;
    color: #666 !important;
    margin: 0 !important;
}

#loginModal .login-form {
    margin-top: 20px !important;
}

#loginModal .form-group {
    margin-bottom: 16px !important;
}

#loginModal .mobile-input-wrapper {
    display: flex !important;
    align-items: center !important;
    gap: 8px !important;
    border: 2px solid #e5e7eb !important;
    border-radius: 12px !important;
    padding: 4px !important;
    transition: all 0.2s ease !important;
    background: #fff !important;
}

#loginModal .mobile-input-wrapper:focus-within {
    border-color: #10b981 !important;
    box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.1) !important;
}

#loginModal .country-code {
    display: flex !important;
    align-items: center !important;
    gap: 6px !important;
    padding: 10px 12px !important;
    background: #f3f4f6 !important;
    border-radius: 8px !important;
    font-size: 14px !important;
    font-weight: 600 !important;
    color: #333 !important;
    white-space: nowrap !important;
}

#loginModal .country-code .flag {
    font-size: 18px !important;
}

#loginModal .mobile-input-wrapper .form-control {
    border: none !important;
    padding: 10px 12px !important;
    flex: 1 !important;
    font-size: 16px !important;
    background: transparent !important;
    box-shadow: none !important;
}

#loginModal .mobile-input-wrapper .form-control:focus {
    box-shadow: none !important;
    outline: none !important;
}

#loginModal .otp-input-group {
    display: flex !important;
    gap: 12px !important;
    justify-content: center !important;
}

#loginModal .otp-input {
    width: 56px !important;
    height: 56px !important;
    text-align: center !important;
    font-size: 24px !important;
    font-weight: 700 !important;
    border: 2px solid #e5e7eb !important;
    border-radius: 12px !important;
    transition: all 0.2s ease !important;
    background: #fff !important;
}

#loginModal .otp-input:focus {
    outline: none !important;
    border-color: #10b981 !important;
    box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.1) !important;
}

#loginModal .btn {
    padding: 14px 24px !important;
    border: none !important;
    border-radius: 12px !important;
    font-size: 15px !important;
    font-weight: 600 !important;
    cursor: pointer !important;
    transition: all 0.2s ease !important;
    font-family: inherit !important;
}

#loginModal .btn-block {
    width: 100% !important;
    display: block !important;
}

#loginModal .btn-primary {
    background: linear-gradient(135deg, #10b981 0%, #059669 100%) !important;
    color: white !important;
}

#loginModal .btn-primary:hover {
    transform: translateY(-1px) !important;
    box-shadow: 0 6px 16px rgba(16, 185, 129, 0.3) !important;
}

#loginModal .btn-primary:disabled {
    opacity: 0.6 !important;
    cursor: not-allowed !important;
    transform: none !important;
}

#loginModal .btn-link {
    background: transparent !important;
    color: #999 !important;
    font-size: 13px !important;
    padding: 12px !important;
    width: 100% !important;
    border: none !important;
}

#loginModal .btn-link:hover {
    color: #666 !important;
}

/* Button loading state - controlled via inline styles from JS */
#loginModal .btn-loading {
    align-items: center;
    justify-content: center;
    gap: 8px;
}

#loginModal .spinner {
    width: 16px !important;
    height: 16px !important;
    border: 2px solid rgba(255,255,255,0.3) !important;
    border-top-color: white !important;
    border-radius: 50% !important;
    animation: spin 0.8s linear infinite !important;
    display: inline-block !important;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

#loginModal .otp-actions {
    margin-top: 20px !important;
    font-size: 13px !important;
    color: #999 !important;
}

#loginModal .otp-actions a {
    color: #10b981 !important;
    text-decoration: none !important;
}

#loginModal .otp-actions a:hover {
    text-decoration: underline !important;
}

#loginModal .otp-actions a.disabled {
    color: #ccc !important;
    pointer-events: none !important;
}

#loginModal .otp-actions .divider {
    margin: 0 8px !important;
}

/* Mobile Responsive for Login Modal */
@media (max-width: 640px) {
    #loginModal .mkb-modal-content {
        max-width: 100% !important;
        border-radius: 20px 20px 0 0 !important;
        max-height: 95vh !important;
        position: fixed !important;
        bottom: 0 !important;
        left: 0 !important;
        right: 0 !important;
        margin: 0 !important;
        animation: modalSlideUpMobile 0.3s ease !important;
    }
    
    #loginModal .login-step {
        padding: 24px 20px !important;
    }
    
    #loginModal .login-step-header h3 {
        font-size: 20px !important;
    }
    
    #loginModal .otp-input {
        width: 50px !important;
        height: 50px !important;
        font-size: 20px !important;
    }
}

@keyframes modalSlideUpMobile {
    from {
        opacity: 0;
        transform: translateY(100%);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ============================================
   AUTH STATE VISIBILITY
   Default: Show login buttons, hide logged-in content
   JS will update these based on actual auth state
   ============================================ */
.show-when-logged-in {
    display: none !important;
}

.hide-when-logged-in {
    display: block !important;
}

/* When body has logged-in class (set by JS) */
body.logged-in .show-when-logged-in {
    display: block !important;
}

body.logged-in .hide-when-logged-in {
    display: none !important;
}

/* For list items specifically */
ul.hide-when-logged-in,
ul.show-when-logged-in {
    display: block !important;
}

body.logged-in ul.show-when-logged-in {
    display: block !important;
}

body.logged-in ul.hide-when-logged-in {
    display: none !important;
}

ul.show-when-logged-in {
    display: none !important;
}

/* ============================================
   MOBILE OPTIMIZATIONS
   ============================================ */
@media (max-width: 576px) {
    .mkb-toast {
        bottom: 80px;
        left: 16px;
        right: 16px;
        transform: translateX(0) translateY(100px);
        max-width: none;
    }
    
    .mkb-toast.show {
        transform: translateX(0) translateY(0);
    }
    
    .pwa-install-banner {
        left: 12px;
        right: 12px;
        bottom: 80px;
        padding: 14px 16px;
    }
    
    .pwa-install-banner.show {
        flex-wrap: wrap;
    }
    
    .pwa-icon {
        width: 40px;
        height: 40px;
        font-size: 20px;
    }
    
    .pwa-install-btn {
        width: 100%;
        margin-top: 8px;
    }
    
    .cookie-bar-box {
        left: 12px;
        right: 12px;
        bottom: 80px;
        padding: 16px;
    }
    
    .cookie-bar-box.show {
        flex-direction: column;
        align-items: stretch;
    }
    
    .cookie-bar-box .button-group {
        width: 100%;
        justify-content: stretch;
    }
    
    .cookie-bar-box .button-group button {
        flex: 1;
    }
}

/* ============================================
   SAFE AREA SUPPORT
   ============================================ */
@supports (padding: max(0px)) {
    .pwa-install-banner,
    .cookie-bar-box,
    .mkb-toast {
        bottom: max(20px, calc(env(safe-area-inset-bottom) + 20px));
    }
    
    @media (max-width: 576px) {
        .pwa-install-banner,
        .cookie-bar-box,
        .mkb-toast {
            bottom: max(80px, calc(env(safe-area-inset-bottom) + 80px));
        }
    }
}
