/* styles.css - External CSS for CSP compliance */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap');

:root {
    --bg-1: #071019;
    --bg-2: #0f2a34;
    --accent-a: #6ef0d6;
    --accent-b: #4fb6ff;
    --muted: #9fb8bb;
    --muted-2: #cfece7;
    --glass: rgba(255, 255, 255, 0.03);
    --glass-light: rgba(255, 255, 255, 0.05);
    --card-shadow-base: 0 12px 40px rgba(2, 6, 23, 0.6);
    --ease: cubic-bezier(.2, .9, .3, 1);
    --error-color: #ff8a8a;
    --success-color: var(--accent-a);
    --info-color: #8ab4f8;
    --github-color: #6e5494;
    --warning-color: #ffc107;
    --critical-color: #ff6b6b;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html, body {
    height: 100%;
    overflow: auto;
    -webkit-tap-highlight-color: transparent;
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    user-select: none;
}

/* Prevent scrolling when modal is open */
body.no-scroll {
    overflow: hidden;
}

body {
    font-family: 'Inter', system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial;
    min-height: 100vh;
    background-color: var(--bg-1);
    color: #e7f8f6;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    overflow-x: hidden;
    position: relative;
}

/* Mobile optimized class */
body.mobile-optimized {
    padding: 10px;
}

.image-bg {
    position: fixed;
    top: -5%; left: -5%;
    width: 110%; height: 110%;
    background-image: url('/android-chrome-512x512.png');
    background-size: cover;
    background-position: center;
    z-index: -2;
    filter: blur(10px) brightness(0.3);
}

body::before {
    content: '';
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background: linear-gradient(160deg, rgba(7, 16, 25, 0.8), rgba(15, 42, 52, 0.8), rgba(7, 16, 25, 0.8));
    background-size: 200% 200%;
    z-index: -1;
}

/* Mobile optimizations */
body.mobile-optimized .image-bg {
    filter: blur(5px) brightness(0.3);
}

/* Main wrapper - centers everything */
.main-wrapper {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
    margin: 0 auto;
}

/* WIDE LANDSCAPE CARD LAYOUT - UPDATED */
.container.card {
    width: min(96vw, 1120px);
    max-width: 1120px;
    min-height: 480px;
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.02), rgba(255, 255, 255, 0.01));
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: 16px;
    box-shadow: 0 0 25px rgba(79, 182, 255, 0.2), 
                0 0 40px rgba(110, 240, 214, 0.1), 
                var(--card-shadow-base);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    display: grid;
    grid-template-columns: 1fr 360px;
    gap: 22px;
    overflow: hidden;
    padding: 22px;
    align-items: start;
}

/* Mobile: stack vertically */
@media (max-width: 880px) {
    .container.card {
        grid-template-columns: 1fr;
        width: 94vw;
        padding: 18px;
        min-height: auto;
        max-width: 500px;
    }
}

/* Left column - UPDATED */
.card-left {
    display: flex;
    flex-direction: column;
    gap: 14px;
    padding-right: 6px;
    max-height: 100%;
    overflow-y: auto;
}

/* Right column - UPDATED */
.card-right {
    display: flex;
    flex-direction: column;
    gap: 18px;
    align-items: center;
    justify-content: space-between;
    padding-left: 6px;
    height: 100%;
}

/* Monkey header (Logo + headings) - UPDATED: Removed logo container */
.monkey-header {
    display: flex;
    align-items: center;
    flex-shrink: 0;
    justify-content: center;
    text-align: center;
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    10%, 30%, 50%, 70%, 90% { transform: translateX(-5px); }
    20%, 40%, 60%, 80% { transform: translateX(5px); }
}

.shake {
    animation: shake 0.5s ease-in-out;
}

/* Header */
.card-header {
    padding: 0;
    text-align: center;
    border-bottom: none;
    width: 100%;
}

.card-header h1 {
    font-size: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    font-weight: 700;
    color: #fff;
    margin: 0;
}

.carl-logo { color: #25D366; font-size: 30px; }
.small { font-size: 14px; color: var(--muted); }

/* Content wrapper - UPDATED */
.content-flex-wrapper {
    display: flex;
    flex-direction: column;
    gap: 16px;
    flex: 1;
    min-height: 0;
}

.content-left {
    flex: 1 1 auto;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.content-right {
    width: 320px;
    min-width: 220px;
    max-width: 360px;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Inputs */
.input-group { 
    position: relative; 
    margin-bottom: 16px;
}

label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: var(--muted-2);
    font-size: 14px;
}

/* FIX: Include text type for password visibility toggle */
input[type="tel"], input[type="password"], input[type="text"] {
    width: 100%;
    padding: 12px 16px;
    border: 1px solid rgba(79, 182, 255, 0.2);
    background: var(--glass);
    border-radius: 8px;
    font-size: 16px;
    color: #e7f8f6;
    transition: border-color 0.2s, box-shadow 0.2s;
    box-shadow: 0 0 0 2px rgba(79, 182, 255, 0.1);
    -webkit-appearance: none;
}

body.mobile-optimized input[type="tel"], 
body.mobile-optimized input[type="password"],
body.mobile-optimized input[type="text"] {
    padding: 14px 16px;
    font-size: 16px;
}

/* FIX: Include text type for hover states */
input[type="tel"]:hover, input[type="password"]:hover, input[type="text"]:hover {
    box-shadow: 0 0 0 3px rgba(79, 182, 255, 0.25);
    border-color: rgba(79, 182, 255, 0.5);
}
input#number::placeholder { color: var(--muted); opacity: 0.7; }

/* FIX: Include text type for focus states */
input[type="tel"]:focus, input[type="password"]:focus, input[type="text"]:focus {
    outline: none;
    border-color: var(--accent-b);
    box-shadow: 0 0 0 4px rgba(79, 182, 255, 0.4);
}

.password-group {
    position: relative;
}

.password-group label {
    position: absolute;
    top: 50%;
    left: 16px;
    transform: translateY(-50%);
    color: var(--muted);
    pointer-events: none;
    transition: all 0.2s ease-out;
    background-color: transparent;
}

.password-group input:focus + label,
.password-group input:not(:placeholder-shown) + label {
    top: 0;
    transform: translateY(-50%);
    font-size: 12px;
    color: var(--accent-b);
    background-color: var(--bg-2);
    padding: 0 6px;
    left: 12px;
}

/* FIX: Ensure password field maintains same padding when type changes */
#password, #password[type="text"] { 
    padding: 16px 50px 8px 16px; 
}

.icon-toggle {
    position: absolute;
    right: 10px; top: 50%;
    transform: translateY(-50%);
    width: 38px; height: 38px;
    border-radius: 8px;
    background: transparent;
    border: 0;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--muted);
    transition: color 0.2s;
    z-index: 3;
}
.icon-toggle:hover { color: var(--accent-a); }

/* Combined comprehensive note style with colored sections - UPDATED */
.info-box.comprehensive-note {
    margin: 16px 0; 
    padding: 16px; 
    border-radius: 8px; 
    font-size: 14px;
    background: rgba(138, 180, 248, 0.05);
    border-left: 5px solid rgba(138, 180, 248, 0.2);
    color: var(--info-color);
    max-height: 280px;
    overflow-y: auto;
    flex-shrink: 0;
}

.info-box.comprehensive-note h4 {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 12px;
    color: var(--info-color);
    font-size: 15px;
}

.info-box.comprehensive-note ul {
    margin-left: 20px;
}

.info-box.comprehensive-note li {
    margin-bottom: 10px;
    line-height: 1.5;
    padding: 8px 12px;
    border-radius: 6px;
    transition: background-color 0.2s ease;
}

.info-box.comprehensive-note li:hover {
    background: rgba(255, 255, 255, 0.03);
}

/* Critical items (red) */
.info-box.comprehensive-note li.critical {
    color: var(--critical-color);
    background: rgba(255, 107, 107, 0.08);
    border-left: 3px solid var(--critical-color);
    margin-left: -8px;
    padding-left: 16px;
}

.info-box.comprehensive-note li.critical strong {
    color: #ff8a8a;
}

/* Warning items (yellow) */
.info-box.comprehensive-note li.warning {
    color: var(--warning-color);
    background: rgba(255, 193, 7, 0.08);
    border-left: 3px solid var(--warning-color);
    margin-left: -8px;
    padding-left: 16px;
}

.info-box.comprehensive-note li.warning strong {
    color: #ffd54f;
}

/* Controls & buttons - Grouped by purpose - UPDATED */
.controls {
    display: flex;
    flex-direction: column;
    gap: 16px;
    width: 100%;
    flex: 1;
    justify-content: flex-start;
}

.button-group {
    display: flex;
    flex-direction: column;
    gap: 10px;
    width: 100%;
}

.button-group:first-child {
    margin-top: 0;
}

.button-group-title {
    font-size: 12px;
    color: var(--muted);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 6px;
    padding: 0 8px;
}

button.hero-btn, a.hero-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 12px 16px;
    min-height: 44px;
    border-radius: 12px;
    cursor: pointer;
    transition: transform .18s var(--ease), box-shadow .18s var(--ease), background .18s var(--ease);
    font-weight: 700;
    text-decoration: none;
    border: 1px solid var(--glass-light);
    touch-action: manipulation;
    font-size: 14px;
    width: 100%;
}

body.mobile-optimized button.hero-btn,
body.mobile-optimized a.hero-btn {
    padding: 12px 16px;
    min-height: 48px;
}

button.hero-btn:hover, a.hero-btn:hover { 
    transform: translateY(-2px); 
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
}

body.mobile-optimized button.hero-btn:hover,
body.mobile-optimized a.hero-btn:hover {
    transform: translateY(-1px);
}

.btn-legend {
    background: linear-gradient(145deg, rgba(110, 240, 214, 0.2), rgba(79, 182, 255, 0.3));
    color: #e7f8f6;
    border-color: rgba(110, 240, 214, 0.2);
}
.btn-stop { background: linear-gradient(145deg, var(--glass), rgba(249, 115, 22, 0.3)); color: #fff; border-color: rgba(249, 115, 22, 0.3); }
.btn-delete { background: linear-gradient(145deg, var(--glass), rgba(220, 38, 38, 0.3)); color: #fff; border-color: rgba(220, 38, 38, 0.3); }
.btn-home { background: linear-gradient(145deg, var(--glass), rgba(34, 197, 94, 0.3)); color: #fff; border-color: rgba(34, 197, 94, 0.3); }
.btn-telegram { background: linear-gradient(145deg, var(--glass), rgba(34, 158, 217, 0.4)); color: #fff; border-color: rgba(34, 158, 217, 0.4); }
.btn-github { background: linear-gradient(145deg, var(--glass), rgba(110, 84, 148, 0.4)); color: #fff; border-color: rgba(110, 84, 148, 0.4); }

/* Make home button full width on PC */
@media (min-width: 881px) {
    .btn-home {
        grid-column: 1 / -1;
    }
}

/* Footer - UPDATED */
.footer { 
    padding: 16px; 
    text-align: center; 
    border-top: 1px solid rgba(255, 255, 255, 0.05); 
    width: 100%;
    margin-top: auto;
    flex-shrink: 0;
}

/* Pairing area */
.pairing { 
    margin-top: 16px; 
    padding: 16px; 
    background: var(--glass); 
    border-radius: 8px; 
    text-align: center; 
    display: none; 
    border: 1px solid rgba(110, 240, 214, 0.2); 
    box-shadow: 0 0 15px rgba(110, 240, 214, 0.1); 
    transition: all 0.3s ease; 
    width: 100%;
}

/* QR Modal Overlay (z-index 1000) */
.qr-modal-overlay { 
    position: fixed; top: 0; left: 0; width: 100%; height: 100%; 
    background: rgba(0, 0, 0, 0.5); 
    backdrop-filter: blur(5px); 
    display: flex; align-items: center; justify-content: center; 
    z-index: 1000; 
    opacity: 0; visibility: hidden; 
    transition: opacity 0.3s, visibility 0.3s; 
}
.qr-modal-overlay.show { opacity: 1; visibility: visible; }
.qr-modal-content { 
    background: linear-gradient(160deg, var(--bg-1), var(--bg-2)); 
    border: 1px solid rgba(255,255,255,0.1); 
    padding: 24px; border-radius: 16px; text-align: center; 
    transform: scale(0.9); transition: transform 0.3s; 
    max-width: 90vw; 
    width: 320px;
}
.qr-modal-overlay.show .qr-modal-content { transform: scale(1); }
#qr-img { width: 280px; height: 280px; border-radius: 8px; background: #fff; object-fit: contain; margin: 12px 0; padding: 10px; max-width: 100%; }

/* NEW: Modal action buttons layout */
.modal-actions {
    display: flex;
    gap: 12px;
    margin-top: 20px;
    width: 100%;
}

.modal-actions .hero-btn {
    flex: 1;
    margin: 0;
}

#numberSuggestions { position: absolute; top: 100%; left: 0; width: 100%; background: var(--bg-2); border: 1px solid rgba(255,255,255,0.1); border-radius: 8px; box-shadow: 0 4px 12px rgba(0,0,0,0.2); max-height: 150px; overflow-y: auto; z-index: 100; display: none; }
.suggestion-item { padding: 12px 16px; cursor: pointer; display: flex; justify-content: space-between; align-items: center; }
.suggestion-item:hover { background: var(--glass-light); }
.suggestion-item .remove-suggestion { color: var(--muted); font-size: 14px; }
.suggestion-item .remove-suggestion:hover { color: var(--error-color); }

/* Alert Modal Styles (z-index 2000) */
.alert-modal-overlay { 
    position: fixed; top: 0; left: 0; width: 100%; height: 100%; 
    background: rgba(0, 0, 0, 0.5); 
    backdrop-filter: blur(5px); 
    display: flex; align-items: center; justify-content: center; 
    z-index: 2000;
    opacity: 0; visibility: hidden; 
    transition: opacity 0.3s, visibility 0.3s; 
}
.alert-modal-overlay.show { opacity: 1; visibility: visible; }

.alert-modal-content { 
    background: linear-gradient(160deg, var(--bg-1), var(--bg-2)); 
    border: 1px solid rgba(255,255,255,0.1); 
    padding: 24px; 
    border-radius: 16px; 
    text-align: center; 
    transform: scale(0.9); 
    transition: transform 0.3s; 
    max-width: 90vw;
    max-width: 500px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.3);
}
.alert-modal-overlay.show .alert-modal-content { transform: scale(1); }

#alertModalIcon {
    font-size: 48px;
    margin-bottom: 16px;
}
#alertModalIcon.icon-error { color: var(--error-color); }
#alertModalIcon.icon-success { color: var(--success-color); }
#alertModalIcon.icon-info { color: var(--accent-b); }

#alertModalMessage {
    font-size: 16px;
    color: #fff;
    line-height: 1.5;
    word-wrap: break-word;
    margin-bottom: 20px;
}

.alert-modal-buttons {
    display: flex;
    gap: 12px;
    justify-content: center;
    margin-top: 20px;
}

.alert-modal-buttons .copy-btn {
    margin: 0;
}

/* Session ID display in modal */
.session-id-display {
    background: rgba(0,0,0,0.2);
    padding: 12px 16px;
    border-radius: 8px;
    margin: 16px 0;
    font-family: monospace;
    word-break: break-all;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.session-id-text {
    flex: 1;
    text-align: left;
}

.session-id-hidden {
    -webkit-text-security: disc;
    text-security: disc;
    font-family: monospace;
}

.session-id-visible {
    -webkit-text-security: none;
    text-security: none;
    font-family: monospace;
}

/* Copy buttons */
.copy-btn { 
    background: var(--accent-b); 
    color: #042026; 
    border: none; 
    padding: 8px 12px; 
    border-radius: 6px; 
    cursor: pointer; 
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

/* Deletion count badge */
.deletion-badge {
    background: rgba(255, 193, 7, 0.1);
    border: 1px solid rgba(255, 193, 7, 0.3);
    padding: 6px 10px;
    border-radius: 12px;
    font-size: 12px;
    margin-top: 12px;
    color: #ffc107;
    display: none;
    align-items: center;
    gap: 6px;
    width: fit-content;
}

.deletion-badge i {
    color: #ffc107;
}

/* Persistent Toast Notification Styles */
.toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 3000;
    display: flex;
    flex-direction: column;
    gap: 10px;
    max-width: 350px;
}

.toast {
    background: linear-gradient(145deg, var(--bg-1), var(--bg-2));
    border: 1px solid rgba(255,255,255,0.1);
    border-left: 5px solid var(--accent-b);
    padding: 16px;
    border-radius: 8px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.3);
    display: flex;
    align-items: center;
    gap: 12px;
    animation: slideInRight 0.3s ease-out;
    backdrop-filter: blur(10px);
    cursor: pointer;
}

.toast.error {
    border-left-color: var(--error-color);
}

.toast.success {
    border-left-color: var(--success-color);
}

.toast.warning {
    border-left-color: #ffc107;
}

.toast.info {
    border-left-color: var(--info-color);
}

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

.toast-content {
    flex: 1;
    color: #fff;
    font-size: 14px;
    line-height: 1.4;
}

.toast-close {
    background: none;
    border: none;
    color: var(--muted);
    cursor: pointer;
    font-size: 16px;
    padding: 4px;
    border-radius: 4px;
    transition: color 0.2s;
}

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

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

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

.toast.hiding {
    animation: slideOutRight 0.3s ease-in forwards;
}

/* Scroll down indicator - REMOVED */
.scroll-indicator {
    display: none !important;
}

/* Mobile-specific optimizations */
@media (max-width: 768px) {
    body {
        padding: 10px;
        align-items: flex-start;
        min-height: 100vh;
        height: auto;
    }
    
    .main-wrapper {
        padding: 10px 0;
    }
    
    .card-header h1 {
        font-size: 20px;
    }
    
    .content-flex-wrapper {
        flex-direction: column;
    }
    
    .content-right {
        width: 100%;
        max-width: none;
    }
    
    .controls {
        grid-template-columns: 1fr;
        gap: 12px;
    }
    
    button.hero-btn, a.hero-btn {
        padding: 12px 16px;
        min-height: 48px;
    }
    
    #qr-img {
        width: 250px;
        height: 250px;
    }
    
    .alert-modal-content {
        margin: 20px;
        padding: 20px;
    }
    
    .toast-container {
        top: 10px;
        right: 10px;
        left: 10px;
        max-width: none;
    }
    
    .info-box.comprehensive-note {
        padding: 14px;
        max-height: 200px;
    }
    
    .info-box.comprehensive-note ul {
        margin-left: 16px;
    }
    
    .info-box.comprehensive-note li {
        padding: 6px 10px;
        margin-left: -6px;
        padding-left: 12px;
    }
    
    .card-right {
        height: auto;
        justify-content: flex-start;
    }

    .modal-actions {
        flex-direction: column;
    }
    
    .qr-modal-content {
        width: 280px;
    }
}

/* Very small screens */
@media (max-width: 360px) {
    .container.card {
        border-radius: 12px;
    }
    
    .card-header h1 {
        font-size: 18px;
    }
    
    .carl-logo {
        font-size: 24px;
    }
    
    #qr-img {
        width: 220px;
        height: 220px;
    }
    
    .qr-modal-content {
        width: 260px;
        padding: 20px;
    }
}
