/**
 * Code Galaxy Page Two - Advanced Styles
 * Senior Developer Optimized Version
 */

/* =========================================
   FONTS
   ========================================= */
@font-face {
    font-family: 'mons';
    src: url('./PlayfairDisplay-VariableFont_wght.ttf') format('truetype');
    font-weight: normal;
    font-style: normal;
    font-display: swap;
}

/* =========================================
   CSS VARIABLES (Inherited + Extended)
   ========================================= */
:root {
    /* Base colors */
    --major: #001F3F;
    --secondary: #F5F5DC;
    --accent: #FFD700;
    --accent-dark: #C0A000;
    --accent-gradient: linear-gradient(to right, #FFD700, #C0A000);
    
    /* Background layers */
    --bg-primary: #0d133d;
    --bg-secondary: #1a2050;
    --card-bg: #24233b;
    
    /* Text colors */
    --text-primary: #ffffff;
    --text-secondary: #b0b0b0;
    --text-dark: #333333;
    
    /* Transitions */
    --transition-fast: 0.2s ease;
    --transition-normal: 0.3s ease;
    --transition-slow: 0.5s ease;
    
    /* Spacing */
    --space-xs: 0.25rem;
    --space-sm: 0.5rem;
    --space-md: 1rem;
    --space-lg: 1.5rem;
    --space-xl: 2rem;
    --space-2xl: 3rem;
    
    /* Border radius */
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 20px;
    --radius-2xl: 30px;
    
    /* Shadows */
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.1);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.15);
    --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.2);
    --shadow-glow: 0 0 20px rgba(255, 215, 0, 0.3);
}

/* =========================================
   BASE STYLES
   ========================================= */
* {
    box-sizing: border-box;
}

body {
    margin: 0;
    padding: 0;
    font-family: 'mons', 'Open Sans', Arial, sans-serif;
    color: var(--text-primary);
    background: var(--bg-primary);
    min-height: 100vh;
    overflow-x: hidden;
    line-height: 1.6;
}

p {
    font-size: 1rem;
    line-height: 1.6;
    margin: 0 0 var(--space-md) 0;
    color: var(--text-primary);
}

/* =========================================
   SIGN IN MODAL
   ========================================= */
#signin-box {
    display: none; /* Controlled by JS */
    position: fixed;
    top: 57%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 90%;
    max-width: 500px;
    min-height: 500px;
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    padding: var(--space-2xl);
    z-index: 1000;
    animation: modalSlideIn 0.3s ease;
}

@keyframes modalSlideIn {
    from {
        opacity: 0;
        transform: translate(-50%, -60%);
    }
    to {
        opacity: 1;
        transform: translate(-50%, -50%);
    }
}

#signin-box h2 {
    color: var(--accent);
    margin-bottom: var(--space-lg);
    text-align: center;
    font-size: clamp(1.5rem, 3vw, 2rem);
}

/* Close button for modal */
#close {
    position: absolute;
    top: var(--space-md);
    right: var(--space-md);
    background: transparent;
    border: none;
    cursor: pointer;
    padding: var(--space-xs);
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-sm);
    transition: all var(--transition-fast);
}

#close:hover {
    background: rgba(255, 255, 255, 0.1);
    transform: rotate(90deg);
}

#close svg {
    width: 24px;
    height: 24px;
}

/* =========================================
   FORM INPUTS
   ========================================= */
.inputs,
input[type="text"],
input[type="email"],
input[type="password"] {
    width: 100%;
    padding: var(--space-md);
    margin-bottom: var(--space-md);
    background-color: rgba(13, 19, 61, 0.6);
    color: var(--text-primary);
    border: 2px solid rgba(255, 215, 0, 0.2);
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-size: 1rem;
    transition: all var(--transition-normal);
}

.inputs::placeholder {
    color: var(--text-secondary);
    opacity: 0.7;
}

.inputs:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(255, 215, 0, 0.1);
    background-color: rgba(13, 19, 61, 0.8);
}

.inputs:hover {
    border-color: rgba(255, 215, 0, 0.4);
}

/* Input validation states */
.inputs[aria-invalid="true"] {
    border-color: #dc3545;
}

.inputs[aria-invalid="false"] {
    border-color: #28a745;
}

.field-error {
    color: #dc3545;
    font-size: 0.875rem;
    margin-top: -0.5rem;
    margin-bottom: var(--space-md);
    display: block;
}

/* =========================================
   BUTTONS
   ========================================= */
.button,
.card-button,
.card-button1 {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: var(--space-md) var(--space-xl);
    background: var(--accent-gradient);
    color: var(--major);
    font-family: 'Open Sans', Arial, sans-serif;
    font-weight: 700;
    font-size: 1rem;
    text-decoration: none;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all var(--transition-normal);
    box-shadow: var(--shadow-sm);
}

.button:hover,
.button:focus,
.card-button:hover,
.card-button1:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.button:active,
.card-button:active,
.card-button1:active {
    transform: translateY(0);
}

.button:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

/* =========================================
   TYPOGRAPHY
   ========================================= */
.Title,
.htm,
.cs,
.J,
.fra {
    font-family: 'Playfair Display', serif;
    font-weight: 700;
    color: var(--accent);
    letter-spacing: 0.02em;
}

.Title {
    font-size: clamp(2rem, 5vw, 3rem);
    margin: 0 0 var(--space-md) 0;
}

.Subtitle,
.subtitle {
    font-size: clamp(1.2rem, 3vw, 1.8rem);
    line-height: 1.3;
    letter-spacing: 1px;
    margin: 0 0 var(--space-md) 0;
    font-weight: 400;
}

.titl {
    width: 100%;
    min-height: 30vh;
    margin-top: 80px;
    padding: var(--space-xl);
}

/* =========================================
   SECTIONS
   ========================================= */
section.html,
section.css,
section.JS {
    background: transparent;
    width: 100%;
    min-height: 60vh;
    display: flex;
    align-items: center;
    justify-content: space-around;
    padding: var(--space-2xl) var(--space-xl);
    gap: var(--space-2xl);
    flex-wrap: wrap;
}

.section-left {
    flex: 1;
    min-width: 280px;
    max-width: 400px;
    display: flex;
    flex-direction: column;
    gap: var(--space-md);
}

.section-right {
    flex: 1;
    min-width: 280px;
    max-width: 500px;
}

.section-title {
    font-size: clamp(2rem, 4vw, 3rem);
    color: var(--accent);
    margin-bottom: var(--space-sm);
}

.section-desc {
    font-size: 1.125rem;
    color: var(--text-secondary);
    margin-bottom: var(--space-lg);
}

.section-card {
    display: flex;
    flex-direction: column;
    gap: var(--space-md);
}

/* =========================================
   CODE EDITOR CARDS
   ========================================= */
.code-card {
    width: 100%;
    background-color: var(--card-bg);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    padding: var(--space-lg);
    overflow: hidden;
}

.code-header {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    margin-bottom: var(--space-md);
    user-select: none;
}

.circle {
    width: 12px;
    height: 12px;
    border-radius: 50%;
}

.circle.red { background-color: #ff605c; }
.circle.yellow { background-color: #ffbd44; }
.circle.green { background-color: #00ca4e; }

.code-title {
    color: var(--text-primary);
    font-size: 1rem;
    font-weight: 600;
    margin-left: var(--space-sm);
}

.code-area,
textarea.code-area {
    width: 100%;
    min-height: 250px;
    padding: var(--space-md);
    background-color: rgba(73, 70, 92, 0.8);
    border: none;
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-family: 'Fira Code', 'Consolas', 'Monaco', monospace;
    font-size: 0.9rem;
    line-height: 1.5;
    resize: vertical;
    overflow: auto;
}

.code-area:focus {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

.copy-code-btn {
    margin-top: var(--space-md);
    padding: var(--space-sm) var(--space-lg);
    background-color: rgba(255, 255, 255, 0.1);
    color: var(--text-primary);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 0.875rem;
    font-weight: 600;
    transition: all var(--transition-fast);
}

.copy-code-btn:hover {
    background-color: rgba(255, 255, 255, 0.2);
    transform: translateY(-1px);
}

.copy-code-btn:active {
    transform: translateY(0);
}

/* =========================================
   3D FRAMEWORK CARDS
   ========================================= */
.frame {
    width: 100%;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: var(--space-lg);
    padding: var(--space-xl);
}

.fram {
    position: relative;
    padding: var(--space-xl);
    border-radius: var(--radius-2xl);
    background: var(--secondary);
    color: var(--text-dark);
    box-shadow: var(--shadow-md);
    transform-style: preserve-3d;
    transform: perspective(1000px);
    transition: transform var(--transition-slow), box-shadow var(--transition-normal);
    will-change: transform;
    overflow: hidden;
}

/* Glow effect on hover */
.fram::before {
    content: '';
    position: absolute;
    inset: 0;
    background: radial-gradient(
        circle at 50% 50%,
        rgba(255, 215, 0, 0.15),
        transparent
    );
    border-radius: var(--radius-2xl);
    opacity: 0;
    transition: opacity var(--transition-normal);
    pointer-events: none;
}

.fram:hover::before {
    opacity: 1;
}

.fram:hover {
    box-shadow: var(--shadow-lg);
}

/* Framework specific colors */
.tain { background: linear-gradient(135deg, #1D249A 0%, #2836ba 100%); color: white; }
.react { background: linear-gradient(135deg, #3A48A9 0%, #4a5bc9 100%); color: white; }
.bootstrap { background: linear-gradient(135deg, #566CB8 0%, #6a7fd8 100%); color: white; }
.typescript { background: linear-gradient(135deg, #3572A5 0%, #4585c0 100%); color: white; }
.next { background: linear-gradient(135deg, #61dafb 0%, #7ce5ff 100%); color: #222; }
.node { background: linear-gradient(135deg, #3A48A9 0%, #4a5bc9 100%); color: white; }

.fra {
    font-size: clamp(1.5rem, 3vw, 2.5rem);
    margin-bottom: var(--space-md);
    text-align: center;
    font-weight: 700;
}

.tech-desc {
    font-size: 1rem;
    line-height: 1.6;
    margin-bottom: var(--space-lg);
    text-align: center;
    opacity: 0.9;
}

.cards1 {
    display: flex;
    justify-content: center;
    align-items: center;
}

/* Scroll reveal animation */
.fram {
    opacity: 0;
    transform: translateY(30px);
    transition: opacity 0.6s ease, transform 0.6s ease;
}

.fram.visible {
    opacity: 1;
    transform: translateY(0);
}

/* =========================================
   AI CHAT WIDGET
   ========================================= */
.ai-widget-container {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 9999;
}

.ai-button {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: var(--accent-gradient);
    border: none;
    cursor: pointer;
    color: var(--major);
    font-weight: bold;
    font-size: 1.5rem;
    box-shadow: var(--shadow-lg);
    transition: all var(--transition-normal);
    display: flex;
    align-items: center;
    justify-content: center;
}

.ai-button:hover {
    transform: scale(1.1);
    box-shadow: var(--shadow-glow);
}

.ai-chat-box {
    position: absolute;
    bottom: 80px;
    right: 0;
    width: 350px;
    height: 500px;
    background: var(--bg-primary);
    border: 2px solid var(--accent);
    border-radius: var(--radius-lg);
    display: none;
    flex-direction: column;
    overflow: hidden;
    box-shadow: var(--shadow-lg);
    animation: chatSlideIn 0.3s ease;
}

@keyframes chatSlideIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.ai-header {
    background: var(--bg-secondary);
    padding: var(--space-md);
    color: var(--accent);
    font-weight: bold;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid rgba(255, 215, 0, 0.2);
}

.ai-close {
    background: none;
    border: none;
    color: var(--text-primary);
    font-size: 1.5rem;
    cursor: pointer;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-sm);
    transition: all var(--transition-fast);
}

.ai-close:hover {
    background: rgba(255, 255, 255, 0.1);
}

.ai-messages {
    flex: 1;
    padding: var(--space-md);
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: var(--space-sm);
}

/* Scrollbar styling */
.ai-messages::-webkit-scrollbar {
    width: 6px;
}

.ai-messages::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.2);
}

.ai-messages::-webkit-scrollbar-thumb {
    background: rgba(255, 215, 0, 0.3);
    border-radius: 3px;
}

.ai-messages::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 215, 0, 0.5);
}

.message {
    padding: var(--space-sm) var(--space-md);
    border-radius: var(--radius-md);
    max-width: 85%;
    font-size: 0.9rem;
    line-height: 1.4;
    animation: messageSlideIn 0.2s ease;
}

@keyframes messageSlideIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.user-msg {
    align-self: flex-end;
    background: var(--accent);
    color: var(--major);
    font-weight: 600;
}

.ai-msg {
    align-self: flex-start;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: var(--text-primary);
}

.ai-input-area {
    padding: var(--space-md);
    display: flex;
    gap: var(--space-sm);
    background: var(--bg-secondary);
    border-top: 1px solid rgba(255, 215, 0, 0.2);
}

#ai-input {
    flex: 1;
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(255, 215, 0, 0.3);
    color: var(--text-primary);
    padding: var(--space-sm);
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-size: 0.9rem;
}

#ai-input:focus {
    outline: none;
    border-color: var(--accent);
}

#ai-send-btn {
    background: var(--accent);
    border: none;
    padding: 0 var(--space-md);
    cursor: pointer;
    border-radius: var(--radius-sm);
    color: var(--major);
    font-weight: bold;
    transition: all var(--transition-fast);
}

#ai-send-btn:hover {
    transform: scale(1.05);
}

/* =========================================
   STATUS MESSAGES
   ========================================= */
.status-message {
    padding: var(--space-md);
    border-radius: var(--radius-md);
    margin-top: var(--space-md);
    text-align: center;
    font-weight: 600;
    display: none;
    animation: slideDown 0.3s ease;
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.status-message.show {
    display: block;
}

.status-message.success {
    background: #d4edda;
    color: #155724;
    border: 2px solid #c3e6cb;
}

.status-message.error {
    background: #f8d7da;
    color: #721c24;
    border: 2px solid #f5c6cb;
}

.status-message.warning {
    background: #fff3cd;
    color: #856404;
    border: 2px solid #ffeaa7;
}

/* =========================================
   TOAST NOTIFICATIONS
   ========================================= */
.cg-toast {
    position: fixed;
    bottom: var(--space-xl);
    right: var(--space-xl);
    padding: var(--space-md) var(--space-xl);
    border-radius: var(--radius-md);
    color: white;
    font-weight: 600;
    box-shadow: var(--shadow-lg);
    z-index: 10000;
    max-width: 400px;
    word-wrap: break-word;
}

.cg-toast-success { background: #28a745; }
.cg-toast-error { background: #dc3545; }
.cg-toast-warning { background: #ffc107; color: #333; }
.cg-toast-info { background: #17a2b8; }

/* =========================================
   RESPONSIVE DESIGN
   ========================================= */
@media (max-width: 900px) {
    .titl {
        padding: var(--space-md);
        margin-top: 60px;
    }
    
    .Title {
        font-size: 1.5rem;
    }
    
    .Subtitle,
    .subtitle {
        font-size: 1rem;
    }
    
    section.html,
    section.css,
    section.JS {
        flex-direction: column;
        padding: var(--space-xl) var(--space-md);
        gap: var(--space-xl);
    }
    
    .section-left,
    .section-right {
        max-width: 100%;
        min-width: 0;
    }
    
    .frame {
        grid-template-columns: 1fr;
        padding: var(--space-md);
    }
    
    .fram {
        transform: none !important;
    }
    
    #signin-box {
        width: 95%;
        padding: var(--space-xl);
    }
    
    .ai-chat-box {
        width: 300px;
        height: 450px;
    }
}

/* =========================================
   ACCESSIBILITY
   ========================================= */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
    
    .fram {
        transform: none !important;
    }
}

/* =========================================
   UTILITY CLASSES
   ========================================= */
.accent {
    color: var(--accent);
}

.text-center {
    text-align: center;
}

.mt-lg {
    margin-top: var(--space-lg);
}

.mb-lg {
    margin-bottom: var(--space-lg);
}