/* 🔹 Global Reset */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Poppins', sans-serif;
}

/* 🔹 Fullscreen Landing Page */
.landing-container {
    width: 100%;
    height: 100vh;
    min-height: 100vh;
    background: radial-gradient(circle at top, #6a1b9a, #4a148c);
    color: white;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    position: relative;
    z-index: 1;
    overflow: hidden;
    padding: 1rem;
    gap: clamp(10px, 2vh, 20px);
}

/* 🔹 Floating Background Elements */
.floating-elements {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
}

/* 🔹 Shapes */
.circle {
    width: 120px;
    height: 120px;
    background: rgba(255, 255, 255, 0.15);
    border-radius: 50%;
    top: 8%;
    left: 5%;
    position: absolute;
    animation: float 6s infinite ease-in-out;
}

.triangle {
    width: 0;
    height: 0;
    border-left: 50px solid transparent;
    border-right: 50px solid transparent;
    border-bottom: 90px solid rgba(255, 255, 255, 0.15);
    bottom: 15%;
    right: 10%;
    position: absolute;
    animation: float 7s infinite ease-in-out;
}

.square {
    width: 60px;
    height: 60px;
    background: rgba(255, 255, 255, 0.15);
    bottom: 30%;
    left: 40%;
    position: absolute;
    animation: float 8s infinite ease-in-out;
}

/* 🔹 Code Elements */
.angle-brackets {
    top: 10%;
    left: 5%;
    font-size: 3rem;
    position: absolute;
    animation: float 9s infinite ease-in-out;
    color: rgba(255, 255, 255, 0.3);
}

.curly-braces {
    bottom: 20%;
    left: 15%;
    font-size: 3rem;
    position: absolute;
    animation: float 7s infinite ease-in-out;
    color: rgba(255, 255, 255, 0.3);
}

.binary-code {
    top: 40%;
    right: 10%;
    font-size: 2.5rem;
    position: absolute;
    animation: float 11s infinite ease-in-out;
    color: rgba(255, 255, 255, 0.3);
}

.slash {
    bottom: 15%;
    right: 30%;
    font-size: 3rem;
    position: absolute;
    animation: float 12s infinite ease-in-out;
    color: rgba(255, 255, 255, 0.3);
}

/* 🔹 Floating Animation */
@keyframes float {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-10px); }
}

/* 🔹 Title Styling */
.landing-container h1 {
    font-size: clamp(2rem, 5vw, 4rem);
    font-weight: 700;
    background: linear-gradient(to right, #f093fb, #f5576c);
    -webkit-background-clip: text;
    color: transparent;
    margin-bottom: clamp(5px, 1vh, 10px);
}

/* 🔹 Typing Effect */
#typing-text {
    font-size: clamp(1rem, 2.5vw, 1.8rem);
    font-weight: 500;
    color: white;
    opacity: 0.9;
    overflow: hidden;
    display: inline;
    min-height: clamp(1.5rem, 4vh, 2.5rem);
    margin-bottom: 0;
    white-space: nowrap;
    position: relative;
    vertical-align: bottom;
    padding-bottom: 2px;
}

/* Text wrapper for fixed width */
#typing-text-wrapper {
    display: inline-block;
    text-align: center;
    min-width: clamp(280px, 80vw, 500px);
    margin: 0 auto;
}

/* 🔹 Typing Container - Added for stability */
.typing-container {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: clamp(2rem, 6vh, 3rem);
    margin-bottom: clamp(15px, 2vh, 20px);
    width: 100%;
    text-align: center;
}

/* 🔹 Blinking Cursor - Separated from text */
.typing-cursor {
    display: inline-block;
    color: white;
    font-size: 1.2em;
    line-height: 1;
    margin-left: 2px;
    animation: blink-caret 0.8s infinite;
}

/* 🔹 Blinking Cursor */
@keyframes blink-caret {
    0%, 100% { opacity: 1; }
    50% { opacity: 0; }
}

/* 🔹 Feature Cards */
.card {
    background: rgba(255, 255, 255, 0.2);
    backdrop-filter: blur(10px);
    padding: clamp(15px, 3vw, 25px);
    width: clamp(150px, 20vw, 200px);
    border-radius: 12px;
    text-align: center;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

/* 🔹 Feature Cards - Ensure Proper Alignment */
.cards-container {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: clamp(10px, 2vw, 25px);
    margin: clamp(10px, 2vh, 20px) 0;
    width: 90%;
    max-width: 1000px;
}

/* 🔹 Feature Card Logos */
.card-logo {
    width: clamp(40px, 7vw, 60px);
    height: auto;
    margin-bottom: 10px;
    display: block;
}

/* ✅ Hover Effects */
.card:hover, .card.touch-active {
    transform: scale(1.1);
    box-shadow: 0 10px 30px rgba(255, 255, 255, 0.3);
}

/* Touch feedback for better mobile experience */
.card:active {
    transform: scale(0.98);
    box-shadow: 0 5px 15px rgba(255, 255, 255, 0.2);
}

/* 🔹 Buttons Container */
.buttons-container {
    display: flex;
    gap: clamp(10px, 2vw, 20px);
    flex-wrap: wrap;
    justify-content: center;
    width: 90%;
    max-width: 600px;
    margin-top: clamp(10px, 2vh, 20px);
}

/* 🔹 Common Button Styles */
#start-button, #language-button {
    padding: clamp(10px, 2vw, 14px) clamp(20px, 3vw, 35px);
    font-size: clamp(1rem, 1.5vw, 1.3rem);
    font-weight: bold;
    color: white;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.3s ease-in-out;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    width: clamp(180px, 40vw, 250px);
    text-align: center;
}

/* 🔹 Start Button */
#start-button {
    background: linear-gradient(45deg, #ff5722, #ff784e);
}

/* 🔹 Language Button */
#language-button {
    background: linear-gradient(45deg, #4CAF50, #8BC34A);
}

/* 🔹 Language Card Styling */
.language-card {
    background: rgba(255, 255, 255, 0.2);
}

/* ✅ Hover Effects */
#start-button:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.3);
}

#language-button:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.3);
}

/* 🔹 Transition Overlay - Improved */
.transition-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: radial-gradient(circle at center, #6a1b9a, #4a148c);
    transform: translateY(100%);
    opacity: 0;
    z-index: 9999;
    pointer-events: none;
    transition: transform 0.8s cubic-bezier(0.19, 1, 0.22, 1), 
                opacity 0.6s cubic-bezier(0.19, 1, 0.22, 1);
}

.transition-overlay::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="100" height="100" viewBox="0 0 100 100"><text x="50%" y="50%" dominant-baseline="middle" text-anchor="middle" font-family="monospace" font-size="20" fill="rgba(255,255,255,0.1)">&lt;/&gt;</text></svg>');
    background-size: 100px;
    opacity: 0.2;
}

.transition-overlay::after {
    content: 'Loading Playground...';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: white;
    font-size: 1.8rem;
    font-weight: 500;
    opacity: 0;
    animation: fadeInText 0.5s ease forwards 0.3s;
}

@keyframes fadeInText {
    from { opacity: 0; transform: translate(-50%, -40%); }
    to { opacity: 1; transform: translate(-50%, -50%); }
}

.fade-out {
    opacity: 1;
    transform: translateY(0%);
    pointer-events: all;
}

/* Transition Symbols Animation */
.transition-symbol {
    position: absolute;
    pointer-events: none;
    opacity: 0;
    animation: fadeFloat 4s ease-in-out infinite;
}

@keyframes fadeFloat {
    0% { opacity: 0; transform: translateY(20px) rotate(0deg); }
    30% { opacity: 0.7; }
    70% { opacity: 0.7; }
    100% { opacity: 0; transform: translateY(-20px) rotate(10deg); }
}

/* Responsive Styles */

/* Large tablets and small desktops */
@media (max-width: 1200px) {
    .cards-container {
        width: 95%;
    }
}

/* Medium tablets */
@media (max-width: 992px) {
    .card {
        width: clamp(140px, 23vw, 180px);
    }
}

/* Small tablets and large phones */
@media (max-width: 768px) {
    .landing-container {
        justify-content: space-evenly;
    }
    
    .cards-container {
        display: grid;
        grid-template-columns: repeat(2, 1fr);
        gap: 15px;
        width: 90%;
        max-width: 500px;
    }
    
    .card {
        width: 100%;
        margin: 0 auto;
    }
    
    .card h2 {
        font-size: clamp(1.1rem, 4vw, 1.5rem);
    }
    
    .card p {
        font-size: clamp(0.8rem, 3vw, 1rem);
    }
    
    /* Header adjustments */
    .header {
        padding: 0.5rem;
    }
    
    .header-title {
        font-size: 1.2rem;
    }
    
    .header-logo {
        height: 28px;
    }
    
    .header-actions {
        gap: 0.5rem;
    }
    
    .user-info {
        max-width: 120px;
    }
    
    .user-name {
        max-width: 80px;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }
    
    /* Editor adjustments */
    .editor-container {
        height: calc(100vh - 110px);
    }
    
    /* Footer adjustments */
    .footer {
        padding: 0.5rem;
        flex-wrap: wrap;
        justify-content: center;
        gap: 0.5rem;
    }
    
    .footer .toolbar-button {
        padding: 0.3rem 0.5rem;
    }
    
    /* Full-screen mode adjustments */
    .fullscreen .editor-container {
        height: calc(100vh - 60px);
    }
    
    /* Ensure dialogs are properly sized */
    .dialog-content {
        width: 90vw;
        max-width: 90vw;
    }
}

/* Small phones */
@media (max-width: 480px) {
    .landing-container {
        padding: 1rem;
        height: 100vh;
        justify-content: flex-start;
        padding-top: clamp(40px, 10vh, 60px);
    }
    
    .landing-container h1 {
        margin-bottom: 5px;
    }
    
    #typing-text {
        margin-bottom: 10px;
        min-height: 1.5rem;
    }
    
    .cards-container {
        margin: 15px 0;
    }
    
    .buttons-container {
        flex-direction: column;
        width: 90%;
        align-items: center;
        margin-top: 15px;
    }
    
    #start-button, #language-button {
        width: 90%;
        max-width: 280px;
        margin-bottom: 10px;
    }
    
    /* Adjust floating elements for better appearance on smaller screens */
    .floating-elements {
        opacity: 0.7;
    }
    
    .header-actions .btn:not(.user-info-container, .btn-icon) {
        display: none;
    }
    
    .btn-icon {
        width: 36px;
        height: 36px;
    }
    
    .language-selector {
        max-width: 100px;
    }
    
    .footer {
        padding: 0.3rem;
    }
    
    /* Make terminal/output area larger on small screens */
    .output-container {
        min-height: 120px;
    }
    
    .auth-section {
        display: flex;
        justify-content: center;
        width: 90%;
        max-width: 300px;
    }
    
    .user-info {
        padding: 5px 10px;
        display: flex;
        flex-wrap: nowrap;
        align-items: center;
        max-width: 100%;
        width: 100%;
        justify-content: space-between;
    }
    
    .user-avatar {
        width: 28px;
        height: 28px;
        min-width: 28px; /* Prevent shrinking */
    }
    
    #user-name {
        max-width: 80px;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        font-size: 0.9rem;
    }
    
    #logout-button {
        padding: 3px 8px !important;
        font-size: 0.75rem !important;
        margin-left: 5px !important;
    }
    
    #admin-panel-btn {
        padding: 3px 8px !important;
        font-size: 0.75rem !important;
        margin: 0 3px !important;
    }
    
    #admin-panel-btn i {
        margin-right: 3px;
    }
    
    /* Mobile and small screen media query refinements */
    @media (max-width: 360px) {
        #user-name {
            display: none; /* Hide username on very small screens */
        }
        
        .user-info {
            gap: 5px;
            padding: 3px 8px;
        }
        
        #logout-button, #admin-panel-btn {
            padding: 3px 6px !important;
        }
        
        #admin-panel-btn span {
            display: none; /* Hide text, keep only icon */
        }
        
        #admin-panel-btn i {
            margin-right: 0;
        }
    }
}

/* Handle very small screens and landscape mode */
@media (max-height: 600px) {
    .landing-container {
        height: auto;
        min-height: 100vh;
        padding: 1rem;
    }
    
    .cards-container {
        margin: 10px 0;
    }
    
    .card {
        padding: 10px;
    }
    
    .card-logo {
        width: clamp(30px, 5vw, 40px);
        margin-bottom: 5px;
    }
    
    .card h2 {
        margin: 5px 0;
        font-size: clamp(1rem, 3vw, 1.2rem);
    }
    
    .card p {
        font-size: clamp(0.7rem, 2vw, 0.9rem);
        margin-bottom: 0;
    }
    
    #start-button, #language-button {
        padding: 8px 15px;
    }
}

/* Handle landscape orientation on mobile */
@media (max-height: 500px) and (orientation: landscape) {
    .landing-container {
        padding: 0.5rem;
        justify-content: center;
        gap: 10px;
    }
    
    .landing-container h1 {
        margin-top: 5px;
        margin-bottom: 0;
        font-size: clamp(1.5rem, 4vw, 2.5rem);
    }
    
    #typing-text {
        margin-bottom: 5px;
        min-height: auto;
        font-size: clamp(0.8rem, 2vw, 1.2rem);
    }
    
    .cards-container {
        display: flex;
        flex-direction: row;
        flex-wrap: wrap;
        gap: 10px;
        margin: 5px 0;
    }
    
    .card {
        width: clamp(120px, 20vw, 160px);
        padding: 8px;
        margin: 0;
    }
    
    .card-logo {
        width: clamp(25px, 5vw, 40px);
        margin-bottom: 5px;
    }
    
    .card h2 {
        font-size: clamp(0.9rem, 2vw, 1.1rem);
        margin: 3px 0;
    }
    
    .card p {
        font-size: clamp(0.7rem, 1.5vw, 0.9rem);
        margin: 0;
    }
    
    .buttons-container {
        flex-direction: row;
        margin-top: 5px;
    }
    
    #start-button, #language-button {
        padding: 6px 12px;
        font-size: clamp(0.8rem, 1.8vw, 1rem);
        width: clamp(160px, 30vw, 200px);
    }
}

/* Fix for white line at bottom of page */
html, body {
    margin: 0;
    padding: 0;
    background-color: #4a148c;
    height: 100%;
    overflow: hidden;
}

/* Tour Popup Styles */
.tour-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.7);
    z-index: 9998;
}

.tour-popup {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background-color: #2d2054;
    border-radius: 10px;
    box-shadow: 0 5px 20px rgba(0, 0, 0, 0.5);
    z-index: 9999;
    width: 90%;
    max-width: 400px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    border: 1px solid #6a1b9a;
}

.tour-header {
    padding: 15px 20px;
    border-bottom: 1px solid #6a1b9a;
    background-color: #4a148c;
    background: linear-gradient(45deg, #4a148c, #6a1b9a);
}

.tour-header h3 {
    margin: 0;
    color: #ffffff;
    font-size: 18px;
}

.tour-content {
    padding: 20px;
    flex: 1;
    color: #e5e5e5;
}

.tour-buttons {
    display: flex;
    justify-content: flex-end;
    padding: 15px 20px;
    border-top: 1px solid #3e3e42;
    background-color: #1e1e1e;
}

.tour-button {
    padding: 8px 16px;
    border-radius: 6px;
    border: none;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    margin-left: 10px;
    transition: all 0.3s ease;
}

.tour-button.primary {
    background: linear-gradient(45deg, #ff5722, #ff784e);
    color: white;
}

.tour-button.primary:hover {
    background: linear-gradient(45deg, #ff784e, #ff5722);
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(255, 87, 34, 0.3);
}

.tour-button.secondary {
    background-color: #2d2054;
    color: white;
    border: 1px solid #6a1b9a;
}

.tour-button.secondary:hover {
    background-color: #3a296b;
    transform: translateY(-2px);
}

/* Tour Guide Styles */
.tour-highlight {
    position: absolute;
    box-shadow: 0 0 0 5000px rgba(0, 0, 0, 0.7);
    border-radius: 4px;
    z-index: 9997;
    pointer-events: none;
    box-sizing: border-box;
    border: 2px solid #ff5722;
    animation: pulse 1.5s infinite;
    display: none;
}

@keyframes pulse {
    0% {
        box-shadow: 0 0 0 5000px rgba(0, 0, 0, 0.7), 0 0 0 0 rgba(255, 87, 34, 0.7);
    }
    70% {
        box-shadow: 0 0 0 5000px rgba(0, 0, 0, 0.7), 0 0 0 10px rgba(255, 87, 34, 0);
    }
    100% {
        box-shadow: 0 0 0 5000px rgba(0, 0, 0, 0.7), 0 0 0 0 rgba(255, 87, 34, 0);
    }
}

.tour-tooltip {
    position: absolute;
    background-color: #2d2054;
    width: 300px;
    border-radius: 10px;
    box-shadow: 0 3px 10px rgba(0, 0, 0, 0.3);
    z-index: 9999;
    overflow: hidden;
    display: none;
    border: 1px solid #6a1b9a;
}

.tooltip-header {
    padding: 10px 15px;
    border-bottom: 1px solid #6a1b9a;
    background: linear-gradient(45deg, #4a148c, #6a1b9a);
}

.tooltip-header h4 {
    margin: 0;
    color: #ffffff;
    font-size: 16px;
}

.tooltip-content {
    padding: 15px;
    color: #e5e5e5;
}

.tooltip-buttons {
    display: flex;
    justify-content: flex-end;
    padding: 10px 15px;
    border-top: 1px solid #3e3e42;
    background-color: #1e1e1e;
}

/* Responsive adjustments for tour */
@media (max-width: 768px) {
    .tour-popup {
        max-width: 90%;
    }
    
    .tour-tooltip {
        width: 250px;
    }
}

@media (max-width: 480px) {
    .tour-tooltip {
        width: 200px;
    }
    
    .tooltip-buttons {
        flex-wrap: wrap;
        gap: 5px;
    }
    
    .tour-button {
        padding: 6px 12px;
        font-size: 12px;
    }
}
