/* AAC Communication System Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Arial', sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    color: #333;
}

#app {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* Navigation */
.main-nav {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    padding: 1rem 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 2px 20px rgba(0, 0, 0, 0.1);
    position: sticky;
    top: 0;
    z-index: 100;
}

.nav-brand h1 {
    color: #667eea;
    font-size: 1.8rem;
    font-weight: bold;
}

.nav-brand i {
    margin-right: 0.5rem;
}

.nav-buttons {
    display: flex;
    gap: 1rem;
    align-items: center;
}

.user-name {
    color: #667eea;
    font-weight: 500;
    margin-right: 1rem;
    font-size: 1rem;
}

.nav-btn {
    background: #667eea;
    color: white;
    border: none;
    padding: 0.75rem 1.5rem;
    border-radius: 25px;
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.nav-btn:hover {
    background: #5a67d8;
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.4);
}

/* Main Content */
.main-content {
    flex: 1;
    padding: 2rem;
    max-width: 1400px;
    margin: 0 auto;
    width: 100%;
}

.page-header h2 {
    text-align: center;
    color: white;
    font-size: 2.5rem;
    margin-bottom: 2rem;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

/* Categories Grid */
.categories-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
    gap: 2rem;
    margin-bottom: 2rem;
}

.category-section {
    background: rgba(255, 255, 255, 0.95);
    border-radius: 20px;
    padding: 1.5rem;
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.1);
    backdrop-filter: blur(10px);
}

.category-title {
    font-size: 1.4rem;
    color: #667eea;
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    border-bottom: 2px solid #e2e8f0;
    padding-bottom: 0.5rem;
}

/* Buttons Grid */
.buttons-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 1rem;
}

.aac-button {
    background: white;
    border: 3px solid #e2e8f0;
    border-radius: 15px;
    padding: 1rem;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    min-height: 120px;
    position: relative;
    overflow: hidden;
    /* Accessibility improvements */
    outline: none;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.aac-button:focus {
    outline: 3px solid #667eea;
    outline-offset: 2px;
    box-shadow: 0 0 0 2px white, 0 0 0 5px #667eea;
}

.aac-button:hover {
    border-color: #667eea;
    transform: translateY(-3px);
    box-shadow: 0 8px 25px rgba(102, 126, 234, 0.2);
}

.aac-button.selected {
    background: #667eea;
    color: white;
    border-color: #5a67d8;
}

.button-image {
    width: 50px;
    height: 50px;
    border-radius: 8px;
    object-fit: cover;
    background: #f7fafc;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.8rem;
}

.button-text {
    font-weight: 600;
    font-size: 0.9rem;
    text-align: center;
    line-height: 1.2;
}

/* Sentence Builder Side Panel */
.sentence-builder-panel {
    position: fixed;
    top: 0;
    right: -400px;
    width: 400px;
    height: 100vh;
    background: rgba(255, 255, 255, 0.98);
    backdrop-filter: blur(15px);
    box-shadow: -5px 0 25px rgba(0, 0, 0, 0.1);
    transition: right 0.4s ease;
    z-index: 200;
    overflow-y: auto;
}

/* Hide the main sentence builder when panel is available */
.sentence-builder-bottom {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    padding: 1rem 2rem;
    box-shadow: 0 -5px 25px rgba(0, 0, 0, 0.1);
    z-index: 150;
    display: none; /* Hidden by default since we use the side panel */
}

.sentence-builder-panel.active {
    right: 0;
}

.sentence-panel-header {
    padding: 1.5rem;
    background: #667eea;
    color: white;
    display: flex;
    justify-content: between;
    align-items: center;
}

.sentence-panel-header h3 {
    font-size: 1.3rem;
}

.close-panel-btn {
    background: none;
    border: none;
    color: white;
    font-size: 1.5rem;
    cursor: pointer;
    margin-left: auto;
}

.sentence-display {
    padding: 1.5rem;
    border-bottom: 1px solid #e2e8f0;
}

.sentence-output {
    min-height: 80px;
    background: #f7fafc;
    border: 2px dashed #cbd5e0;
    border-radius: 10px;
    padding: 1rem;
    font-size: 1.1rem;
    line-height: 1.4;
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    color: #4a5568;
}

.sentence-controls {
    display: flex;
    gap: 0.5rem;
}

.control-btn {
    flex: 1;
    padding: 0.75rem;
    border: none;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
}

.speak-btn {
    background: #48bb78;
    color: white;
}

.speak-btn:hover {
    background: #38a169;
}

.clear-btn {
    background: #f56565;
    color: white;
}

.clear-btn:hover {
    background: #e53e3e;
}

/* Word Categories in Sentence Builder */
.word-categories {
    padding: 1.5rem;
}

.category-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.tab-btn {
    background: #e2e8f0;
    border: none;
    padding: 0.5rem 0.75rem;
    border-radius: 20px;
    font-size: 0.8rem;
    cursor: pointer;
    transition: all 0.3s ease;
}

.tab-btn.active {
    background: #667eea;
    color: white;
}

.words-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(80px, 1fr));
    gap: 0.5rem;
}

.word-btn {
    background: white;
    border: 2px solid #e2e8f0;
    border-radius: 8px;
    padding: 0.5rem;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 0.85rem;
    text-align: center;
    min-height: 50px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.word-btn:hover {
    border-color: #667eea;
    background: #f7fafc;
}

/* Page Content (for full-screen pages) */
.page-content {
    flex: 1;
    padding: 2rem;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    margin: 2rem;
    border-radius: 20px;
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.1);
}

.page-content.hidden {
    display: none !important;
}

/* Ensure sentence builder page elements are completely hidden when not in use */
#sentence-builder-page {
    display: none !important;
}

/* Hide any bottom sentence builder elements that might be confusing */
body > div:last-child .word-categories,
body > div:last-child .sentence-display:not(.speech-display),
#app > div:last-child:not(.speech-display) {
    display: none !important;
}

/* Aggressively hide bottom sentence builder elements */
#app > div:nth-last-child(2),
#app > div:last-child:not(.speech-display),
.sentence-display:not(.speech-display),
.word-categories,
.category-tabs,
.words-grid,
.sentence-controls:not(.speech-display .sentence-controls) {
    display: none !important;
}

.back-btn {
    background: #667eea;
    color: white;
    border: none;
    padding: 0.75rem 1.5rem;
    border-radius: 25px;
    cursor: pointer;
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    transition: all 0.3s ease;
}

.back-btn:hover {
    background: #5a67d8;
    transform: translateY(-2px);
}

/* Settings */
.settings-content {
    max-width: 600px;
}

.setting-group {
    background: white;
    border-radius: 10px;
    padding: 1.5rem;
    margin-bottom: 1.5rem;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
}

.setting-group h3 {
    color: #667eea;
    margin-bottom: 1rem;
    font-size: 1.2rem;
}

.setting-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1rem;
    padding: 0.5rem 0;
}

.setting-item:last-child {
    margin-bottom: 0;
}

.setting-item label {
    font-weight: 600;
    color: #4a5568;
}

.setting-item select,
.setting-item input {
    padding: 0.5rem;
    border: 2px solid #e2e8f0;
    border-radius: 5px;
    background: white;
}

.setting-item input[type="range"] {
    width: 150px;
}

/* Speech Display */
.speech-display {
    position: fixed;
    bottom: 2rem;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.9);
    color: white;
    padding: 1rem 2rem;
    border-radius: 25px;
    backdrop-filter: blur(10px);
    z-index: 300;
    display: none;
    max-width: 80%;
    animation: slideUp 0.3s ease;
}

.speech-display.show {
    display: block;
}

.speech-content {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.spoken-text {
    font-size: 1.2rem;
    font-weight: 600;
}

.close-speech {
    background: none;
    border: none;
    color: white;
    font-size: 1.2rem;
    cursor: pointer;
    opacity: 0.7;
}

.close-speech:hover {
    opacity: 1;
}

/* Animations */
@keyframes slideUp {
    from {
        transform: translateX(-50%) translateY(100%);
        opacity: 0;
    }
    to {
        transform: translateX(-50%) translateY(0);
        opacity: 1;
    }
}

/* Responsive Design */
@media (max-width: 768px) {
    .main-nav {
        flex-direction: column;
        gap: 1rem;
        text-align: center;
    }

    .nav-buttons {
        flex-wrap: wrap;
        justify-content: center;
    }

    .categories-grid {
        grid-template-columns: 1fr;
        gap: 1rem;
    }

    .sentence-builder-panel {
        width: 100vw;
        right: -100vw;
    }

    .page-header h2 {
        font-size: 2rem;
    }

    .main-content {
        padding: 1rem;
    }

    /* Hide all sentence builder bottom elements on mobile */
    #app > div:not(.speech-display):not(.main-nav):not(.main-content):not([id^="settings"]) {
        display: none !important;
    }
}

@media (max-width: 480px) {
    .buttons-grid {
        grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
        gap: 1rem;
    }

    .aac-button {
        min-height: 120px;
        padding: 1rem;
        /* Better touch targets for mobile */
        min-width: 44px;
        transition: transform 0.1s ease;
    }

    .aac-button:active {
        transform: scale(0.95);
        background: #667eea;
        color: white;
    }

    .button-image {
        width: 48px;
        height: 48px;
        font-size: 1.8rem;
    }

    .button-text {
        font-size: 0.9rem;
        font-weight: 600;
    }

    /* Larger nav buttons on mobile */
    .nav-btn {
        padding: 1rem 1.5rem;
        font-size: 1.1rem;
        min-height: 44px;
    }
}

/* High Contrast Mode */
body.high-contrast {
    background: #000;
    color: #fff;
}

body.high-contrast .category-section,
body.high-contrast .aac-button {
    background: #000;
    border-color: #fff;
    color: #fff;
}

body.high-contrast .aac-button:hover {
    background: #333;
}

/* Font Size Variants */
body.font-large {
    font-size: 1.2em;
}

body.font-x-large {
    font-size: 1.5em;
}

body.font-small {
    font-size: 0.9em;
}

/* Button Size Variants */
body.buttons-large .aac-button {
    min-height: 150px;
    padding: 1.5rem;
}

body.buttons-large .button-image {
    width: 60px;
    height: 60px;
    font-size: 2rem;
}

body.buttons-small .aac-button {
    min-height: 80px;
    padding: 0.5rem;
}

body.buttons-small .button-image {
    width: 35px;
    height: 35px;
    font-size: 1.3rem;
}