/* Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

/* Container */
.container {
    width: 100%;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    align-items: stretch;
    padding: 20px 0;
    overflow-y: auto;
    overflow-x: hidden;
}

/* Content Container */
.content-container {
    width: 100%;
    min-height: calc(100vh - 40px);
    background: transparent;
    border-radius: 25px;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    align-items: stretch;
    padding: 0;
    position: relative;
    gap: 10px;
    flex: 1;
    box-sizing: border-box;
}

/* Top Section - User Greeting */
.top-section {
    display: flex;
    justify-content: flex-start;
    align-items: center;
    padding: 0 20px;
    margin-bottom: 20px;
    width: 100%;
}

/* Middle Section - Koala + Grid */
.middle-section {
    display: flex;
    flex-direction: row;
    justify-content: space-between;
    align-items: center;
    gap: 20px;
    flex: 1;
    width: 100%;
    margin: 10px 0;
    padding: 0 20px;
}

.koala-container {
    display: flex;
    justify-content: flex-start;
    align-items: center;
    flex: 1;
    position: relative;
    z-index: 50;
}

.grid-container {
    display: flex;
    justify-content: center;
    align-items: center;
    flex: 1;
    margin-left: 40px;
    position: relative;
    z-index: 100;
}

/* Bottom Section - Mic Button */
.bottom-section {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 0 20px;
    margin-top: auto;
    width: 100%;
}

/* Header - Hidden in new layout */
.header {
    display: none;
}

.title {
    display: none;
}

/* User Greeting Container - Top Left in Layout */
.user-greeting-container {
    position: relative;
    z-index: 10000;
}

/* User Greeting Button */
.user-greeting {
    font-family: var(--font-primary);
    font-size: 1.8rem;
    font-weight: var(--font-weight-semibold);
    color: white;
    text-shadow: 0 2px 4px rgba(0,0,0,0.3);
    padding: 12px 24px;
    background: rgba(255, 255, 255, 0.15);
    backdrop-filter: blur(10px);
    border-radius: 20px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.user-greeting:hover {
    background: rgba(255, 255, 255, 0.25);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.2);
}

.user-greeting:active {
    transform: translateY(0);
}

/* Categories Grid */
.categories-grid {
    display: grid !important;
    grid-template-columns: repeat(4, 1fr) !important;
    gap: 6px;
    padding: 15px;
    width: 100%;
    max-width: 1200px;
}

/* Category Card */
.category-card {
    background: transparent;
    border-radius: 20px;
    padding: 12px;
    cursor: pointer;
    transition: all 0.3s ease;
    backdrop-filter: none;
    border: none;
    box-shadow: none;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 120px;
}

.category-card:hover {
    transform: translateY(-8px);
    box-shadow: none;
    border-color: transparent;
}

.category-card:active {
    transform: translateY(-4px);
}

/* Category Icon */
.category-icon {
    width: 112px;
    height: 112px;
    border-radius: 25%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 8px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
}

.category-icon .icon {
    width: 60%;
    height: 60%;
    object-fit: contain;
}

/* Kai listening indicator - homescreen only */
.kai-assistant.listening::before {
    content: "";
    position: absolute;
    bottom: 15px;
    right: 15px;
    width: 12px;
    height: 12px;
    background: #4CAF50;
    border-radius: 50%;
    border: 2px solid white;
    box-shadow: 0 0 8px rgba(76, 175, 80, 0.6);
    animation: gentlePulse 2s ease-in-out infinite;
    z-index: 1001;
}

/* Stop koala animation when listening */
.kai-assistant.listening .kai-image {
    animation-play-state: paused;
}

/* Stop all koala animations when listening */
.kai-assistant.listening {
    animation-play-state: paused !important;
}

.kai-assistant.listening.bounce,
.kai-assistant.listening.wiggle {
    animation: none !important;
}

@keyframes gentlePulse {
    0%, 100% { opacity: 0.7; transform: scale(1); }
    50% { opacity: 1; transform: scale(1.1); }
}

/* Microphone Button */
.mic-button {
    position: relative;
    width: 80px;
    height: 80px;
    background: #F4A629;
    border: none;
    border-radius: 50%;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.25);
    cursor: pointer;
    z-index: 1001;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    padding: 0;
    -webkit-tap-highlight-color: transparent;
}

.mic-button:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.3);
}

.mic-button:active {
    transform: scale(0.98);
}

.mic-icon {
    width: 32px;
    height: 32px;
    color: white;
    pointer-events: none;
}

/* ============================================
   MIC BUTTON STATES - Three distinct states
   ============================================ */

/* IDLE State - Yellow (default) - "Tap to talk to Kai" */
.mic-button.idle {
    background: #FFC107;
    animation: idlePulse 3s ease-in-out infinite;
}

@keyframes idlePulse {
    0%, 100% { 
        transform: scale(1); 
        box-shadow: 0 2px 5px rgba(0, 0, 0, 0.25);
    }
    50% { 
        transform: scale(1.02); 
        box-shadow: 0 4px 8px rgba(0, 0, 0, 0.3);
    }
}

/* SPEAKING State - Orange - "Wait, Kai is talking" */
.mic-button.speaking {
    background: #FF5722;
    animation: speakingPulse 1s ease-in-out infinite;
}

@keyframes speakingPulse {
    0%, 100% { 
        transform: scale(1); 
        box-shadow: 0 2px 5px rgba(0, 0, 0, 0.25), 0 0 0 0 rgba(255, 87, 34, 0.4);
    }
    50% { 
        transform: scale(1.05); 
        box-shadow: 0 4px 8px rgba(0, 0, 0, 0.3), 0 0 20px 8px rgba(255, 87, 34, 0.25);
    }
}

/* LISTENING State - Green - "Speak now!" */
.mic-button.listening,
.mic-button.active {
    background: #4CAF50;
    animation: listeningGlow 1.5s ease-out infinite;
}

@keyframes listeningGlow {
    0% { 
        box-shadow: 0 2px 5px rgba(0, 0, 0, 0.25), 0 0 0 0 rgba(76, 175, 80, 0.6);
    }
    70% { 
        box-shadow: 0 2px 5px rgba(0, 0, 0, 0.25), 0 0 0 15px rgba(76, 175, 80, 0);
    }
    100% { 
        box-shadow: 0 2px 5px rgba(0, 0, 0, 0.25), 0 0 0 0 rgba(76, 175, 80, 0);
    }
}

/* Override for 1200x800 screens - homescreen gets 250x250 */
@media (max-width: 1200px) and (max-height: 800px) {
    .container {
        padding: 15px;
    }
    
    .content-container {
        padding: 15px;
    }
    
    .header {
        margin-top: calc(5vh - 20px);
    }
    
    .title {
        font-size: 4em;
    }
    
    .user-greeting {
        font-size: 1.5rem;
        padding: 10px 20px;
        top: 15px;
        right: 15px;
    }
    
    .categories-grid {
        grid-template-columns: repeat(4, 1fr) !important;
        gap: 4px;
        padding: 10px;
    }
    
    .category-card {
        padding: 6px;
        min-height: 110px;
    }
    
    .category-icon {
        width: 100px;
        height: 100px;
    }
    
    .category-title {
        font-size: 1.1rem;
    }
}


/* 1920x1200 screen optimization */
@media (min-width: 1920px) and (max-width: 1920px) and (min-height: 1200px) and (max-height: 1200px) {
    .categories-grid {
        grid-template-columns: repeat(4, 1fr) !important;
        gap: 10px;
        padding: 20px;
    }
    
    .category-card {
        padding: 12px;
        min-height: 130px;
    }
    
    .category-icon {
        width: 120px;
        height: 120px;
    }
    
    .category-title {
        font-size: 1.3rem;
    }
}

/* For screens wider than 1200px: no left padding/margin */
@media (min-width: 1201px) {
    .container {
        padding-left: 0 !important;
    }
    .content-container {
        padding-left: 0 !important;
    }
}

/* Category-specific colors */
.literacy-icon {
    background: #039DA7;
}

.maths-icon {
    background: #032037;
}

.science-icon {
    background: #F5A546;
}

.arts-icon {
    background: #E77867;
}

.smartscan-icon {
    background: #AF1B0D;
}

.daily-facts-icon {
    background: #D6381A;
}

.languages-icon {
    background: #F9C88F;
}

.yoga-icon {
    background: #A7E2D7;
}

/* Category Title */
.category-title {
    font-family: var(--font-primary);
    font-size: 1.5rem;
    font-weight: var(--font-weight-semibold);
    color: white;
    text-shadow: 0 2px 4px rgba(0,0,0,0.3);
    margin: 0;
}

/* Mobile - Mic Button Adjustments */
@media (max-width: 480px) {
    .mic-button {
        width: 56px;
        height: 56px;
    }

    .mic-icon {
        width: 22px;
        height: 22px;
    }
    
    .middle-section {
        flex-direction: column;
        gap: 20px;
    }
}

@media (min-width: 481px) and (max-width: 767px) {
    .mic-button {
        width: 64px;
        height: 64px;
    }

    .mic-icon {
        width: 26px;
        height: 26px;
    }
    
    .middle-section {
        flex-direction: column;
        gap: 30px;
    }
}

/* Tablet-specific optimizations */
@media (min-width: 768px) and (max-width: 1024px) {
    .content-container {
        padding: 20px;
        max-width: 1000px;
    }
    
    .header {
        margin-top: calc(8vh - 20px);
    }
    
    .title {
        font-size: 5em;
    }
    
    .categories-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 8px;
        padding: 10px;
    }
    
    .category-card {
        padding: 10px;
        min-height: 100px;
    }
    
    .category-icon {
        width: 98px;
        height: 98px;
    }
    
    .category-icon .icon {
        width: 60%;
        height: 60%;
        object-fit: contain;
    }
    
    .category-title {
        font-size: 1.5rem;
    }
}

/* Large tablet/desktop */
@media (min-width: 1025px) {
    .content-container {
        padding: 30px;
        max-width: 1200px;
    }
    
    .header {
        margin-top: calc(10vh - 20px);
    }
    
    .title {
        font-size: 6em;
    }
    
    .categories-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 8px;
        padding: 15px;
    }
    
    .category-card {
        padding: 12px;
        min-height: 120px;
    }
    
    .category-icon {
        width: 160px;
        height: 160px;
    }
    
    .category-icon .icon {
        width: 60%;
        height: 60%;
        object-fit: contain;
    }
    
    .category-title {
        font-size: 1.5rem;
    }
}

/* Mobile phones */
@media (max-width: 767px) {
    .content-container {
        padding: 15px;
    }
    
    .header {
        margin-top: calc(5vh - 20px);
    }
    
    .title {
        font-size: 4em;
    }
    
    .user-greeting {
        font-size: 1.3rem;
        padding: 8px 16px;
        top: 10px;
        right: 10px;
    }
    
    .categories-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 8px;
        padding: 10px;
    }
    
    .category-card {
        padding: 10px;
        min-height: 100px;
    }
    
    .category-icon {
        width: 84px;
        height: 84px;
    }
    
    .category-icon .icon {
        width: 60%;
        height: 60%;
        object-fit: contain;
    }
    
    .category-title {
        font-size: 1.5rem;
    }
}

/* Landscape orientation for tablets */
@media (orientation: landscape) and (max-height: 600px) {
    .content-container {
        padding: 10px;
    }
    
    .header {
        top: 20vh;
    }
    
    .title {
        font-size: 3em;
    }
    
    .categories-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 10px;
        padding: 5px;
    }
    
    .category-card {
        padding: 10px;
        min-height: 100px;
    }
    
    .category-icon {
        width: 120px;
        height: 120px;
    }
    
    .category-icon .icon {
        width: 60%;
        height: 60%;
        object-fit: contain;
    }
    
    .category-title {
        font-size: 1.5rem;
    }
}

/* Lenovo Tablet 1463x915 (Pilot Group) */
@media (min-width: 1400px) and (max-width: 1500px) and (min-height: 880px) and (max-height: 950px) {
    .container {
        padding: 25px;
    }
    
    .header {
        margin-top: 15vh;
    }
    
    .title {
        font-size: 5.5em;
    }
    
    .categories-grid {
        grid-template-columns: repeat(4, 1fr);
        gap: 20px;
        max-width: 1300px;
        padding: 20px;
    }
    
    .category-icon {
        width: 140px;
        height: 140px;
    }
    
    .category-name {
        font-size: 1.6rem;
        margin-top: 12px;
    }
    
    .user-greeting {
        font-size: 2rem;
        padding: 15px 30px;
    }
}

/* NOTE: Homescreen koala size (450px) is now defined in koala_assistant.css
   as a single source of truth for all screen resolutions */
