/* ==========================================
   CRT Placement Lab Style Sheet
   Apple Premium Glassmorphism Theme
   ========================================== */

@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;500;600;700;800&family=Fira+Code:wght@400;500;600&display=swap');

:root {
    --bg-darker: #08080f;
    --bg-dark: #0e0e16;
    --bg-panel: rgba(22, 22, 32, 0.42);
    --bg-panel-hover: rgba(32, 32, 48, 0.62);
    --border-color: rgba(255, 255, 255, 0.08);
    --border-color-glow: rgba(0, 113, 227, 0.4);
    
    --primary: #0071e3; /* Apple Premium Blue */
    --primary-glow: rgba(0, 113, 227, 0.35);
    --secondary: rgba(255, 255, 255, 0.08);
    
    --accent-success: #30d158; /* Apple System Green */
    --accent-success-glow: rgba(48, 209, 88, 0.3);
    --accent-error: #ff453a; /* Apple System Red */
    --accent-warning: #ff9f0a; /* Apple System Orange */
    --accent-info: #64d2ff; /* Apple System Cyan */
    
    --text-main: #f5f5f7; /* Apple Primary Text */
    --text-muted: #86868b; /* Apple Secondary Text */
    --text-dark: #1d1d1f;
    
    --font-sans: -apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro Text", "Segoe UI", Roboto, "Outfit", sans-serif;
    --font-mono: "SF Mono", "Fira Code", Monaco, Consolas, monospace;
    
    --card-shadow: 0 16px 40px rgba(0, 0, 0, 0.3);
    --transition-speed: 0.25s;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    -webkit-font-smoothing: antialiased;
}

body {
    background-color: var(--bg-darker);
    color: var(--text-main);
    font-family: var(--font-sans);
    min-height: 100vh;
    overflow-x: hidden;
    position: relative;
}

/* ------------------------------------------
   Background Ambient Blobs (Apple Aurora style)
   ------------------------------------------ */
.glow-bg {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: -1;
    overflow: hidden;
    pointer-events: none;
}

.color-blob {
    position: absolute;
    border-radius: 50%;
    filter: blur(140px);
    opacity: 0.25;
    animation: floatBlob 24s infinite alternate ease-in-out;
}

.blob-1 {
    width: 600px;
    height: 600px;
    background: radial-gradient(circle, rgba(0, 113, 227, 0.75) 0%, rgba(139, 92, 246, 0.3) 100%);
    top: -200px;
    left: -100px;
}

.blob-2 {
    width: 700px;
    height: 700px;
    background: radial-gradient(circle, rgba(236, 72, 153, 0.55) 0%, rgba(59, 130, 246, 0.25) 100%);
    bottom: -200px;
    right: -100px;
    animation-delay: -6s;
}

.blob-3 {
    width: 500px;
    height: 500px;
    background: radial-gradient(circle, rgba(48, 209, 88, 0.45) 0%, rgba(0, 113, 227, 0.15) 100%);
    top: 30%;
    left: 45%;
    animation-delay: -12s;
}

@keyframes floatBlob {
    0% { transform: translate(0, 0) scale(1); }
    50% { transform: translate(60px, 40px) scale(1.05); }
    100% { transform: translate(-40px, -60px) scale(0.95); }
}

/* ------------------------------------------
   App Structure Layout
   ------------------------------------------ */
.app-container {
    display: flex;
    flex-direction: column;
    height: 100vh;
    padding: 1.5rem;
    max-width: 1600px;
    margin: 0 auto;
    gap: 1.25rem;
}

/* Header */
.app-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.85rem 1.75rem;
    background: var(--bg-panel);
    border: 1px solid var(--border-color);
    border-radius: 20px;
    backdrop-filter: blur(25px) saturate(180%);
    -webkit-backdrop-filter: blur(25px) saturate(180%);
    box-shadow: var(--card-shadow);
}

.logo {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.logo-icon {
    font-size: 1.8rem;
    color: var(--text-main);
    filter: drop-shadow(0 2px 10px rgba(255, 255, 255, 0.15));
}

.logo-text h1 {
    font-size: 1.25rem;
    font-weight: 600;
    letter-spacing: -0.3px;
    color: var(--text-main);
}

.logo-text span {
    font-size: 0.72rem;
    color: var(--text-muted);
    font-weight: 500;
    letter-spacing: 0.2px;
}

.header-status {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background: rgba(255, 255, 255, 0.05);
    padding: 0.4rem 0.9rem;
    border-radius: 40px;
    font-size: 0.75rem;
    font-weight: 500;
    border: 1px solid rgba(255, 255, 255, 0.05);
}

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

.status-indicator.online {
    background-color: var(--accent-success);
    box-shadow: 0 0 8px var(--accent-success);
}

.status-indicator.offline {
    background-color: var(--accent-error);
    box-shadow: 0 0 8px var(--accent-error);
}

.status-indicator.loading {
    background-color: var(--accent-warning);
    box-shadow: 0 0 8px var(--accent-warning);
    animation: pulse 1.5s infinite;
}

@keyframes pulse {
    0% { opacity: 0.4; }
    50% { opacity: 1; }
    100% { opacity: 0.4; }
}

/* Workspace */
.workspace {
    display: flex;
    flex: 1;
    gap: 1.25rem;
    min-height: 0;
}

/* Sidebar */
.sidebar {
    width: 320px;
    background: var(--bg-panel);
    border: 1px solid var(--border-color);
    border-radius: 20px;
    backdrop-filter: blur(25px) saturate(180%);
    -webkit-backdrop-filter: blur(25px) saturate(180%);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-shadow: var(--card-shadow);
}

.sidebar-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--border-color);
}

.sidebar-header h2 {
    font-size: 0.92rem;
    font-weight: 600;
    color: var(--text-main);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.sidebar-header h2 i {
    color: var(--text-muted);
}

.refresh-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 0.95rem;
    transition: color var(--transition-speed), transform var(--transition-speed);
}

.refresh-btn:hover {
    color: var(--primary);
    transform: rotate(180deg);
}

.problem-list {
    flex: 1;
    overflow-y: auto;
    padding: 0.75rem;
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

/* Problem Items - Apple Style Selection */
.problem-item {
    background: transparent;
    border: 1px solid transparent;
    padding: 0.85rem 1rem;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.2s ease-in-out;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: relative;
}

.problem-item:hover {
    background: rgba(255, 255, 255, 0.04);
}

.problem-item.active {
    background: var(--primary);
    box-shadow: 0 4px 15px var(--primary-glow);
}

.problem-info {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
    flex: 1;
}

.problem-name {
    font-weight: 500;
    font-size: 0.9rem;
    color: var(--text-main);
    transition: color 0.2s;
}

.problem-desc-preview {
    font-size: 0.75rem;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 190px;
    transition: color 0.2s;
}

.problem-item.active .problem-name {
    color: #ffffff;
}

.problem-item.active .problem-desc-preview {
    color: rgba(255, 255, 255, 0.7);
}

.problem-status-badge {
    background: rgba(255, 255, 255, 0.08);
    color: var(--text-main);
    font-size: 0.7rem;
    font-weight: 600;
    padding: 0.15rem 0.45rem;
    border-radius: 6px;
    border: 1px solid rgba(255, 255, 255, 0.05);
    transition: all 0.2s;
}

.problem-item.active .problem-status-badge {
    background: rgba(255, 255, 255, 0.2);
    border-color: rgba(255, 255, 255, 0.1);
    color: #ffffff;
}

/* Skeleton Loaders */
.skeleton {
    height: 52px;
    background: linear-gradient(90deg, rgba(255, 255, 255, 0.02) 25%, rgba(255, 255, 255, 0.05) 50%, rgba(255, 255, 255, 0.02) 75%);
    background-size: 200% 100%;
    animation: loadingSkeleton 1.5s infinite;
    border-radius: 12px;
}

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

/* Main Content Panel */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
    min-height: 0;
}

/* Panels */
.description-card, .editor-panel, .terminal-panel {
    background: var(--bg-panel);
    border: 1px solid var(--border-color);
    border-radius: 20px;
    backdrop-filter: blur(25px) saturate(180%);
    -webkit-backdrop-filter: blur(25px) saturate(180%);
    box-shadow: var(--card-shadow);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* Description Card */
.description-card {
    padding: 1.25rem 1.5rem;
    gap: 0.5rem;
}

.card-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.problem-badge {
    background: rgba(255, 255, 255, 0.08);
    color: var(--text-main);
    font-family: var(--font-mono);
    font-weight: 600;
    padding: 0.25rem 0.6rem;
    border-radius: 6px;
    font-size: 0.75rem;
    border: 1px solid rgba(255, 255, 255, 0.05);
}

#desc-title {
    font-size: 1.15rem;
    font-weight: 600;
    letter-spacing: -0.2px;
}

#desc-text {
    font-size: 0.9rem;
    color: var(--text-muted);
    line-height: 1.55;
}

/* Editor Panel */
.editor-panel {
    flex: 2;
    min-height: 250px;
}

.panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.85rem 1.5rem;
    border-bottom: 1px solid var(--border-color);
    background: rgba(0, 0, 0, 0.1);
}

.panel-title {
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-main);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.panel-title i {
    color: var(--text-muted);
}

.editor-container {
    flex: 1;
    width: 100%;
    position: relative;
    background: rgba(18, 18, 24, 0.15);
}

#code-editor {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
}

/* Monaco Glassmorphism Overrides */
.monaco-editor, 
.monaco-editor .margin, 
.monaco-editor-background {
    background-color: transparent !important;
}

/* Action Bar */
.action-bar {
    display: flex;
    gap: 0.75rem;
    align-items: center;
}

/* Buttons - Apple Style Pill buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    padding: 0.55rem 1.25rem;
    font-family: var(--font-sans);
    font-size: 0.85rem;
    font-weight: 500;
    border-radius: 30px;
    border: none;
    cursor: pointer;
    transition: all 0.2s ease-in-out;
}

.btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.btn-primary {
    background: var(--primary);
    color: #fff;
    box-shadow: 0 4px 12px rgba(0, 113, 227, 0.2);
}

.btn-primary:not(:disabled):hover {
    background: #0077ed;
    box-shadow: 0 4px 16px rgba(0, 113, 227, 0.35);
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.06);
    color: var(--text-main);
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.12);
}

/* Terminal Panel */
.terminal-panel {
    flex: 1.2;
    min-height: 180px;
    background: rgba(12, 12, 18, 0.45);
}

.terminal-meta {
    font-family: var(--font-mono);
    font-size: 0.75rem;
    color: var(--text-muted);
}

.terminal-body {
    flex: 1;
    overflow-y: auto;
    padding: 1.25rem;
    font-family: var(--font-mono);
    font-size: 0.82rem;
    line-height: 1.5;
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    background: rgba(8, 8, 12, 0.25);
}

.terminal-line {
    white-space: pre-wrap;
    word-break: break-all;
}

.terminal-line.output {
    color: #f5f5f7;
}

.terminal-line.error {
    color: var(--accent-error);
    background: rgba(255, 69, 58, 0.06);
    padding: 0.25rem 0.5rem;
    border-radius: 6px;
    border-left: 3px solid var(--accent-error);
}

.terminal-line.input {
    color: var(--accent-info);
    font-weight: 500;
}

.terminal-line.system-msg {
    color: var(--text-muted);
    font-style: italic;
}

.terminal-line.system-success {
    color: var(--accent-success);
    font-weight: 500;
}

/* Custom Scrollbars */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 10px;
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.2);
}

/* Footer Styles */
.app-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.85rem 1.75rem;
    background: var(--bg-panel);
    border: 1px solid var(--border-color);
    border-radius: 20px;
    backdrop-filter: blur(25px) saturate(180%);
    -webkit-backdrop-filter: blur(25px) saturate(180%);
    box-shadow: var(--card-shadow);
    margin-top: auto;
    font-size: 0.82rem;
    flex-shrink: 0;
}

.footer-left {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--text-muted);
}

.footer-heart {
    color: var(--accent-error);
    animation: heartBeat 1.5s infinite;
}

@keyframes heartBeat {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.15); }
}

.footer-right {
    display: flex;
    gap: 1.5rem;
}

.footer-link {
    color: var(--text-muted);
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 0.4rem;
    font-weight: 500;
    transition: color var(--transition-speed), transform var(--transition-speed);
}

.footer-link:hover {
    color: var(--primary);
    transform: translateY(-1px);
}

.footer-link i {
    font-size: 0.9rem;
}

/* Responsiveness */
@media (max-width: 900px) {
    .app-container {
        height: auto;
        min-height: 100vh;
        padding: 0.75rem;
        gap: 0.75rem;
    }
    
    .app-header {
        padding: 0.85rem 1.25rem;
        flex-direction: column;
        gap: 0.75rem;
        align-items: center;
        text-align: center;
    }
    
    .logo {
        flex-direction: column;
        gap: 0.25rem;
    }
    
    .header-status {
        width: 100%;
        justify-content: center;
    }
    
    .workspace {
        flex-direction: column;
        gap: 0.75rem;
        flex: none;
        height: auto;
    }
    
    .sidebar {
        width: 100%;
        height: auto;
        max-height: none;
        flex: none;
    }
    
    .sidebar-header {
        padding: 0.75rem 1.25rem;
        border-bottom: 1px solid var(--border-color);
        justify-content: center;
    }
    
    .problem-list {
        flex-direction: row;
        overflow-x: auto;
        overflow-y: hidden;
        padding: 0.6rem;
        gap: 0.4rem;
        -webkit-overflow-scrolling: touch;
    }
    
    .problem-item {
        flex: 0 0 auto;
        padding: 0.55rem 0.85rem;
        min-width: 130px;
        max-width: 180px;
        height: auto;
        flex-direction: column;
        align-items: center;
        text-align: center;
        gap: 0.15rem;
    }
    
    .problem-item::before {
        display: none;
    }
    
    .problem-info {
        align-items: center;
        gap: 0;
    }
    
    .problem-desc-preview {
        display: none;
    }
    
    .main-content {
        flex: none;
        gap: 0.75rem;
        height: auto;
    }
    
    .description-card {
        padding: 1.25rem;
    }
    
    .card-header {
        flex-wrap: wrap;
        gap: 0.5rem;
    }
    
    #share-btn {
        width: 100%;
        margin-left: 0 !important;
        margin-top: 0.5rem;
        justify-content: center;
    }
    
    .editor-panel {
        height: 320px;
        min-height: 320px;
        flex: none;
    }
    
    .terminal-panel {
        height: 250px;
        min-height: 250px;
        flex: none;
    }
    
    .action-bar {
        width: 100%;
        justify-content: space-between;
    }
    
    .btn {
        flex: 1;
        padding: 0.6rem 1rem;
        font-size: 0.85rem;
    }
    
    .app-footer {
        flex-direction: column;
        gap: 0.75rem;
        align-items: center;
        text-align: center;
        padding: 1.25rem;
    }
    
    .footer-right {
        flex-direction: column;
        gap: 0.5rem;
        align-items: center;
    }
}

/* Share Modal Overlay */
.modal-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.45);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    z-index: 1000;
    justify-content: center;
    align-items: center;
    opacity: 0;
    transition: opacity 0.25s ease-out;
}

.modal-overlay.show {
    display: flex;
    opacity: 1;
}

/* Modal Card */
.modal-card {
    background: rgba(28, 28, 30, 0.65);
    border: 1px solid var(--border-color);
    border-radius: 22px;
    width: 90%;
    max-width: 440px;
    padding: 1.75rem;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(30px) saturate(190%);
    -webkit-backdrop-filter: blur(30px) saturate(190%);
    transform: scale(0.9);
    transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

.modal-overlay.show .modal-card {
    transform: scale(1);
}

/* Modal Header */
.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.25rem;
}

.modal-header h3 {
    font-size: 1.2rem;
    font-weight: 600;
    letter-spacing: -0.3px;
    color: var(--text-main);
}

.modal-close-btn {
    background: rgba(255, 255, 255, 0.08);
    border: none;
    color: var(--text-muted);
    font-size: 1.25rem;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.modal-close-btn:hover {
    background: rgba(255, 255, 255, 0.15);
    color: var(--text-main);
}

/* Share Link Box */
.share-link-box {
    display: flex;
    gap: 0.6rem;
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--border-color);
    border-radius: 30px;
    padding: 0.25rem 0.25rem 0.25rem 1rem;
    align-items: center;
    margin-bottom: 1.5rem;
}

#share-link-input {
    flex: 1;
    background: transparent;
    border: none;
    color: var(--text-main);
    font-family: var(--font-mono);
    font-size: 0.8rem;
    outline: none;
    text-overflow: ellipsis;
}

#modal-copy-btn {
    padding: 0.45rem 1.25rem;
    font-size: 0.8rem;
    border-radius: 30px;
}

.modal-subtitle {
    font-size: 0.78rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    margin-bottom: 0.75rem;
    text-align: center;
}

/* Share Grid */
.share-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 0.75rem;
}

.share-grid-item {
    background: transparent;
    border: none;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    color: var(--text-muted);
    font-family: var(--font-sans);
    font-size: 0.72rem;
    font-weight: 500;
    transition: all 0.2s;
}

.share-grid-item:hover {
    color: var(--text-main);
}

.share-icon-wrap {
    width: 46px;
    height: 46px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    color: white;
    transition: transform 0.2s;
}

.share-grid-item:hover .share-icon-wrap {
    transform: scale(1.08);
}

/* Platform Colors */
.share-icon-wrap.whatsapp {
    background: #25d366;
}

.share-icon-wrap.x-twitter {
    background: #000000;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.share-icon-wrap.linkedin {
    background: #0077b5;
}

.share-icon-wrap.reddit {
    background: #ff4500;
}
