/* Global Styles */
/* Loading indicator */
body.loading::after {
    content: "";
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.8);
    z-index: 9999;
    display: flex;
    justify-content: center;
    align-items: center;
}

body.loading::before {
    content: "Loading...";
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 10000;
    font-size: 24px;
    font-weight: bold;
    color: #333;
}

/* Letter navigation styling */
.letter-link.available {
    color: #333;
    cursor: pointer;
}

.letter-link.unavailable {
    color: #ccc;
    cursor: default;
}

.letter-link.active {
    font-weight: bold;
    color: #e74c3c;
}
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: "Gill Sans", "Segoe UI", sans-serif;
    background-color: #f4f4f4;
    color: #333;
    line-height: 1.6;
}

/* App Container */
.app-container {
    max-width: 1200px;
    margin: 20px auto;
    background-color: white;
    border-radius: 10px;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
    overflow: hidden;
}

/* Browser Controls */
.browser-controls {
    display: flex;
    align-items: center;
    padding: 10px 15px;
    background-color: #f0f0f0;
    border-bottom: 1px solid #ddd;
}

.window-controls {
    display: flex;
    gap: 8px;
    margin-right: 20px;
}

.control {
    width: 12px;
    height: 12px;
    border-radius: 50%;
}

.control.red {
    background-color: #ff5f57;
}

.control.yellow {
    background-color: #ffbd2e;
}

.control.green {
    background-color: #28c940;
}

.navigation-controls {
    display: flex;
    gap: 10px;
    margin-right: 15px;
}

.nav-button {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 16px;
    color: #666;
}

.search-bar {
    flex-grow: 1;
    display: flex;
    background-color: #e6e6e6;
    border-radius: 20px;
    padding: 5px 10px;
    margin: 0 15px;
}

.search-bar input {
    flex-grow: 1;
    border: none;
    background: none;
    outline: none;
    padding: 5px;
    font-size: 14px;
}

.search-button {
    background: none;
    border: none;
    cursor: pointer;
    color: #666;
}

.browser-actions {
    display: flex;
    gap: 15px;
}

.action-button {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 16px;
    color: #666;
}

/* Main Content */
.main-content {
    padding: 0;
}

/* Header with Logo */
header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 30px;
    border-bottom: 1px solid #eee;
}

.logo {
    display: flex;
    align-items: center;
    gap: 5px;
}

.logo-image {
    width: 60px;
    height: 60px;
}

.logo-text h1 {
    font-size: 28px;
    font-weight: bold;
    color: #1a3a4a;
    margin: 0;
    line-height: 1;
}

.logo-text h2 {
    font-size: 22px;
    color: #2980b9;
    margin: 0;
    line-height: 1.2;
}

.search-container {
    flex-grow: 0;
    display: flex;
    justify-content: flex-end;
    max-width: 500px;
    margin-left: 15px;
}

/* Language Selector */
.language-selector {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-left: 20px;
    flex-grow: 1;
    align-content: end;
    justify-content: end;
}

.language-flag {
    display: block;
    width: 40px;
    height: 40px;
    transition: transform 0.2s ease;
}

.language-flag img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    border: 1px solid #eee;
    border-radius: 100%;
}

.language-flag:hover {
    transform: scale(1.1);
}

.language-flag.active img {
    border: 2px solid #2980b9;
}

.search-box {
    display: flex;
    align-items: center;
    width: 100%;
    border: 1px solid #ddd;
    border-radius: 25px;
    padding: 8px 15px;
}

.search-box i {
    color: #2980b9;
    margin-right: 10px;
}

.search-box input {
    flex-grow: 1;
    border: none;
    outline: none;
    font-size: 16px;
}

/* Content Area */
.content-area {
    display: flex;
    min-height: 600px;
}

/* Alphabet Navigation */
#alphabet-nav {
    width: 80px;
    background-color: #f8f9fa;
    padding: 20px 0;
    border-right: 1px solid #eee;
    flex: 0 0
}

#alphabet-nav ul {
    list-style: none;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 15px;
}

#alphabet-nav ul li {
    width: 100%;
    text-align: center;
}

#alphabet-nav ul li a {
    display: block;
    text-decoration: none;
    color: #1a3a4a;
    font-size: 24px;
    font-weight: bold;
    padding: 10px 0; 
    width: 40px;
    height: 40px;
    line-height: 20px;
    margin: 0 auto;
}

#alphabet-nav ul li a:hover,
#alphabet-nav ul li a.active {
    color: #2980b9;
    background-color: #e6f2ff;
}

/* Main Content */
main {
    flex-grow: 1;
    padding: 30px;
}

/* Topics Section */
#topics-section {
    width: 100%;
}

.letter-heading {
    font-size: 48px;
    color: #1a3a4a;
    margin-bottom: 30px;
    font-weight: bold;
}

.current-letter, .search-term {
    color: #2980b9;
}

#topics-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(500px, 1fr));
    gap: 30px;
}

.topic-card {
    background-color: white;
    border-radius: 10px;
    box-shadow: 0 3px 10px rgba(0, 0, 0, 0.1);
    overflow: hidden;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    cursor: pointer;
    /* A5 proportions (148mm x 210mm = 1:1.414) */
    aspect-ratio: 1/1.414;
    display: flex;
    flex-direction: column;
    /* Random border colors */
    border: 5px solid;
    border-radius: 10px;
}


/* Generate random border colors using CSS classes that will be applied via JavaScript */
.border-red {
    border-color: #ff5f57;
}

.border-blue {
    border-color: #2980b9;
}

.border-green {
    border-color: #27ae60;
}

.border-purple {
    border-color: #8e44ad;
}

.border-orange {
    border-color: #f39c12;
}

.border-teal {
    border-color: #16a085;
}

.topic-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
}

.topic-card-content {
    padding: 0;
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    height: 100%;
}

.topic-card-image {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.topic-card-placeholder {
    grid-column: 1 / -1;
    text-align: center;
    padding: 50px;
    background-color: #f8f9fa;
    border-radius: 10px;
    color: #666;
    font-size: 18px;
}

/* Topic Display Section */
#topic-display-section {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(255, 255, 255, 0.95);
    z-index: 1000;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    padding: 30px;
}

#close-topic-btn {
    position: absolute;
    top: 20px;
    right: 20px;
    background-color: #ff5f57;
    color: white;
    border: none;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    font-size: 20px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.3s ease;
}

#close-topic-btn:hover {
    background-color: #e04942;
}

/* Topic Navigation */
.topic-navigation {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 20px;
    margin-top: 20px;
    margin-bottom: 20px;
    width: 100%;
}

.topic-navigation .nav-button {
    background-color: #2980b9;
    color: white;
    border: none;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    font-size: 18px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.3s ease;
}

.topic-navigation .nav-button:hover {
    background-color: #1a6ca4;
}

.topic-navigation .nav-button:disabled {
    background-color: #cccccc;
    cursor: not-allowed;
}

#topic-title-display {
    font-size: 36px;
    color: #1a3a4a;
    text-align: center;
    flex-grow: 1;
}

#image-container {
    max-width: 80%;
    max-height: 70vh;
    display: flex;
    justify-content: center;
    align-items: center;
    margin-top: 60px;
}

#topic-image {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    border-radius: 10px;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
}

.topic-description {
    max-width: 80%;
    margin: 20px auto;
    font-size: 18px;
    line-height: 1.6;
    text-align: center;
    color: #333;
}

/* Footer */
footer {
    padding: 20px 30px;
    background-color: white;
    border-top: 1px solid #eee;
    text-align: right;
}

.footer-links {
    display: flex;
    justify-content: flex-end;
    gap: 20px;
}

.footer-links a {
    text-decoration: none;
    color: #1a3a4a;
    font-size: 16px;
    transition: color 0.3s ease;
}

.footer-links a:hover {
    color: #2980b9;
}

/* Signup Popup Styles */
.popup-container {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.7);
    z-index: 2000;
    justify-content: center;
    align-items: center;
}

.popup-content {
    background-color: white;
    padding: 30px;
    border-radius: 10px;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.3);
    max-width: 800px;
    width: 95%;
    position: relative;
    animation: popupFadeIn 0.3s ease;
}

@media (max-width: 768px) {
    .popup-content {
        padding: 20px;
        max-height: 90vh;
        overflow-y: auto;
    }
}

@keyframes popupFadeIn {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.close-popup {
    position: absolute;
    top: 10px;
    right: 15px;
    font-size: 24px;
    color: #666;
    cursor: pointer;
    transition: color 0.3s ease;
}

.close-popup:hover {
    color: #ff5f57;
}

.popup-content h2 {
    color: #1a3a4a;
    margin-bottom: 15px;
    font-size: 24px;
}

.popup-content p {
    color: #666;
    margin-bottom: 20px;
    line-height: 1.5;
}

.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
    color: #1a3a4a;
}

.form-group input,
.form-group select {
    width: 100%;
    padding: 12px 15px;
    border: 1px solid #ddd;
    border-radius: 5px;
    font-size: 16px;
    transition: border-color 0.3s ease;
    background-color: #fff;
}

.form-group input:focus,
.form-group select:focus {
    border-color: #2980b9;
    outline: none;
    box-shadow: 0 0 0 2px rgba(41, 128, 185, 0.2);
}

.form-select {
    appearance: none;
    background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%231a3a4a' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right 15px center;
    background-size: 16px;
    padding-right: 40px;
}

.signup-btn {
    background-color: #2980b9;
    color: white;
    border: none;
    border-radius: 5px;
    padding: 14px 20px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    width: 100%;
    margin-top: 10px;
    display: flex;
    justify-content: center;
    align-items: center;
}

.signup-btn:hover {
    background-color: #1a6ca4;
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}

.signup-btn:active {
    transform: translateY(0);
}

#signup-message {
    margin-top: 15px;
    padding: 10px;
    border-radius: 5px;
    text-align: center;
    display: none;
}

#signup-message.success {
    background-color: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
    display: block;
}

#signup-message.error {
    background-color: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
    display: block;
}

/* Responsive Styles */
@media (max-width: 992px) {
    .search-container {
        max-width: 100%;
        margin-top: 15px;
        order: 2;
    }
    
    header {
        flex-wrap: wrap;
    }
    
    .content-area {
        flex-direction: column;
    }
    
    #alphabet-nav {
        width: 100%;
        border-right: none;
        border-bottom: 1px solid #eee;
        padding: 10px 0;
    }
    
    #alphabet-nav ul {
        flex-direction: row;
        flex-wrap: wrap;
        justify-content: center;
    }
    
    #alphabet-nav ul li {
        width: auto;
    }
    
    #alphabet-nav ul li a {
        padding: 0;
        font-size: 20px;
        width: 36px;
        height: 36px;
        line-height: 30px;
    }
    #alphabet-nav ul li a:hover, 
    #alphabet-nav ul li a.active {
        border-radius: 50%;
    }
    
    #topics-grid {
        grid-template-columns: repeat(auto-fill, minmax(500px, 1fr));
    }
}

@media (max-width: 768px) {
    body {
        background-color: white;
    }
    
    .app-container {
        max-width: 100%;
        margin: 0;
        border-radius: 0;
        box-shadow: none;
    }
    
    .browser-controls {
        flex-wrap: wrap;
    }
    
    .search-bar {
        order: 3;
        width: 100%;
        margin: 10px 0 0;
    }
    
    #topic-display-section {
        padding: 0;
    }
    
    .browser-actions {
        margin-left: auto;
    }
    
    .logo {
        flex-direction: column;
        align-items: center;
        text-align: center;
        width: 100%;
        justify-content: center;
        margin-bottom: 10px;
    }
    
    header {
        flex-direction: column;
        padding: 15px;
    }
    
    .search-container {
        width: 100%;
        max-width: 100%;
        margin-top: 10px;
        justify-content: center;
        display: flex;
    }
    
    .language-selector {
        width: 100%;
        justify-content: center;
        margin: 15px 0 0 0;
    }
    
    .search-box {
        max-width: 90%;
        margin: 0 auto;
    }
    
    #topics-grid {
        grid-template-columns: 1fr;
        gap: 15px;
    }
    
    .topic-card {
        max-width: 100%;
        width: 100%;
        height: auto;
        margin: 0;
        border-radius: 0;
    }
    
    #image-container {
        max-width: 100%;
        width: 100%;
        padding: 0;
        margin-top: 70px;
    }
    
    #topic-image {
        width: 100%;
        border-radius: 0;
        box-shadow: none;
        max-height: none;
    }
    
    .topic-navigation {
        padding: 10px;
        margin-top: 0;
        margin-bottom: 10px;
        position: absolute;
        top: 10px;
        left: 0;
        right: 0;
    }
    
    #close-topic-btn {
        z-index: 1001;
    }
}