/* ========================================
   RESET & BASE STYLES
   ======================================== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: linear-gradient(135deg, rgba(102, 126, 234, 0.9) 0%, rgba(118, 75, 162, 0.9) 100%),
                url('banner.png') center center / cover no-repeat fixed;
    color: #333;
    line-height: 1.6;
    min-height: 100vh;
}

/* ========================================
   HEADER
   ======================================== */
header {
    background: rgba(255, 255, 255, 0.95);
    padding: 1.5rem 2rem;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

.header-content {
    max-width: 1400px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 2rem;
    flex-wrap: wrap;
}

.logo-container {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.header-logo {
    width: 60px;
    height: 60px;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.header-text {
    flex: 1;
}

header h1 {
    font-size: 1.75rem;
    color: #667eea;
    margin-bottom: 0.25rem;
}

header p {
    color: #666;
    font-size: 0.875rem;
    margin: 0;
}

/* Language Switcher */
.language-switcher {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.lang-label {
    font-size: 0.875rem;
    font-weight: 600;
    color: #667eea;
    white-space: nowrap;
}

.lang-select {
    background: #f5f5f5;
    border: 2px solid #e0e0e0;
    padding: 0.5rem 0.75rem;
    border-radius: 8px;
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    min-width: 150px;
}

.lang-select:hover {
    background: #e8e8e8;
    border-color: #667eea;
}

.lang-select:focus {
    outline: none;
    border-color: #667eea;
    background: white;
}

/* ========================================
   PROMOTIONAL BANNER
   ======================================== */
.promo-banner {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    padding: 1rem 2rem;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 1.5rem;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
    position: sticky;
    top: 0;
    z-index: 100;
}

.promo-text {
    color: white;
    font-size: 1rem;
    font-weight: 500;
    margin: 0;
}

.promo-btn {
    background: white;
    color: #667eea;
    padding: 0.6rem 1.5rem;
    border-radius: 25px;
    text-decoration: none;
    font-weight: 600;
    font-size: 0.95rem;
    transition: all 0.3s ease;
    white-space: nowrap;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.promo-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    background: #f8f8f8;
}

/* ========================================
   MOBILE BOTTOM AD
   ======================================== */
.mobile-ad-bottom {
    display: none;
    background: #f5f5f5;
    padding: 1rem;
    text-align: center;
    border-top: 1px solid #ddd;
}

/* ========================================
   CONTAINER & LAYOUT
   ======================================== */
.container {
    display: flex;
    max-width: 1400px;
    margin: 2rem auto;
    padding: 0 1rem;
    gap: 1rem;
    align-items: flex-start;
}

/* ========================================
   SIDE ADS (DESKTOP)
   ======================================== */
.side-ad {
    flex-shrink: 0;
    width: 160px;
    position: sticky;
    top: 2rem;
}

.left-ad {
    order: 1;
}

.right-ad {
    order: 3;
}

/* ========================================
   MAIN CONTENT
   ======================================== */
.main-content {
    flex: 1;
    order: 2;
    min-width: 0;
}

/* ========================================
   FORM SECTION
   ======================================== */
.form-section {
    background: white;
    border-radius: 12px;
    padding: 2rem;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
    transition: all 0.3s ease;
}

.form-container h2 {
    color: #667eea;
    margin-bottom: 1.5rem;
    font-size: 1.5rem;
}

.form-group {
    margin-bottom: 1.5rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 600;
    color: #333;
}

.form-group input,
.form-group select {
    width: 100%;
    padding: 0.75rem;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    font-size: 1rem;
    transition: border-color 0.3s ease;
}

.form-group input:focus,
.form-group select:focus {
    outline: none;
    border-color: #667eea;
}

.form-group small {
    display: block;
    margin-top: 0.25rem;
    color: #666;
    font-size: 0.875rem;
}

/* Search Terms Input */
.search-terms-input {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.search-terms-input input {
    flex: 1;
}

/* Terms List */
.terms-list {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-top: 1rem;
    min-height: 50px;
    padding: 0.5rem;
    background: #f8f9fa;
    border-radius: 8px;
}

.term-tag {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    background: #667eea;
    color: white;
    padding: 0.5rem 0.75rem;
    border-radius: 20px;
    font-size: 0.875rem;
}

.term-tag button {
    background: none;
    border: none;
    color: white;
    cursor: pointer;
    font-size: 1.2rem;
    line-height: 1;
    padding: 0;
    margin: 0;
}

.term-tag button:hover {
    opacity: 0.8;
}

.terms-counter {
    margin-top: 0.5rem;
    font-size: 0.875rem;
    color: #666;
    text-align: right;
}

/* Buttons */
.btn-primary,
.btn-secondary {
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
}

.btn-primary {
    background: #667eea;
    color: white;
    width: 100%;
}

.btn-primary:hover:not(:disabled) {
    background: #5568d3;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

.btn-primary:disabled {
    background: #ccc;
    cursor: not-allowed;
}

.btn-secondary {
    background: #e0e0e0;
    color: #333;
}

.btn-secondary:hover {
    background: #d0d0d0;
}

/* Loading Indicator */
.loading-indicator {
    text-align: center;
    margin-top: 1.5rem;
}

.spinner {
    border: 4px solid #f3f3f3;
    border-top: 4px solid #667eea;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    animation: spin 1s linear infinite;
    margin: 0 auto 1rem;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.loading-indicator p {
    color: #666;
    font-size: 0.875rem;
}

/* Error Message */
.error-message {
    background: #fee;
    border: 1px solid #fcc;
    color: #c33;
    padding: 1rem;
    border-radius: 8px;
    margin-top: 1rem;
}

/* ========================================
   RESULTS SECTION
   ======================================== */
.results-section {
    background: white;
    border-radius: 12px;
    padding: 2rem;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
}

.mobile-form-toggle {
    display: block;
    width: 100%;
    padding: 1rem;
    background: #667eea;
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    margin-bottom: 2rem;
}

.mobile-form-toggle:hover {
    background: #5568d3;
}

/* App Info */
.app-info {
    display: flex;
    gap: 2rem;
    margin-bottom: 2rem;
    padding-bottom: 2rem;
    border-bottom: 2px solid #e0e0e0;
}

.app-photo-container {
    flex-shrink: 0;
}

.app-icon {
    width: 120px;
    height: 120px;
    border-radius: 20px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.app-details {
    flex: 1;
}

.app-details h2 {
    color: #667eea;
    margin-bottom: 0.75rem;
    font-size: 1.75rem;
}

.app-details p {
    color: #666;
    line-height: 1.6;
}

/* Rankings Container */
.rankings-container h3 {
    color: #333;
    margin-bottom: 1.5rem;
    font-size: 1.25rem;
}

.rankings-table {
    overflow-x: auto;
}

/* Desktop Table */
.rankings-table table {
    width: 100%;
    border-collapse: collapse;
    background: white;
}

.rankings-table th,
.rankings-table td {
    padding: 1rem;
    text-align: left;
    border-bottom: 1px solid #e0e0e0;
}

.rankings-table th {
    background: #f8f9fa;
    font-weight: 600;
    color: #333;
}

.rankings-table td.rank {
    font-weight: 600;
    font-size: 1.125rem;
}

/* Mobile Two-Column Layout */
.rankings-mobile {
    display: none;
}

.ranking-item {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 1rem;
    padding: 1rem;
    border-bottom: 1px solid #e0e0e0;
    align-items: center;
}

.ranking-item:last-child {
    border-bottom: none;
}

.ranking-term {
    font-weight: 500;
    color: #333;
}

.ranking-result {
    font-weight: 600;
    font-size: 1.125rem;
    padding: 0.5rem 1rem;
    border-radius: 8px;
    text-align: center;
    min-width: 60px;
}

/* Ranking Colors */
.rank-not-found {
    background-color: #ffebee;
    color: #c62828;
}

.rank-yellow {
    background-color: #fff9c4;
    color: #f57f17;
}

.rank-blue {
    background-color: #e3f2fd;
    color: #1565c0;
}

.rank-green {
    background-color: #e8f5e9;
    color: #2e7d32;
}

/* ========================================
   FOOTER AD
   ======================================== */
.footer-ad {
    background: #f5f5f5;
    padding: 2rem;
    text-align: center;
    margin-top: 2rem;
    border-top: 1px solid #ddd;
}

.footer-ad .ad-placeholder {
    max-width: 728px;
    margin: 0 auto;
    min-height: 90px;
}

/* ========================================
   MOBILE RESPONSIVE (< 768px)
   ======================================== */
@media (max-width: 768px) {
    /* Show mobile bottom ad */
    .mobile-ad-bottom {
        display: block;
    }

    /* Hide side ads */
    .side-ad {
        display: none;
    }

    /* Stack container */
    .container {
        flex-direction: column;
        margin: 1rem auto;
    }

    /* Header */
    header {
        padding: 1rem;
    }

    .header-content {
        flex-direction: column;
        align-items: flex-start;
        gap: 1rem;
    }

    .logo-container {
        width: 100%;
    }

    .header-logo {
        width: 50px;
        height: 50px;
    }

    header h1 {
        font-size: 1.25rem;
    }

    header p {
        font-size: 0.75rem;
    }

    .language-switcher {
        width: 100%;
        justify-content: space-between;
    }

    .lang-label {
        font-size: 0.75rem;
    }

    .lang-select {
        flex: 1;
        max-width: 180px;
        padding: 0.4rem 0.6rem;
        font-size: 0.75rem;
        min-width: 130px;
    }

    /* Promo Banner */
    .promo-banner {
        flex-direction: column;
        padding: 0.75rem 1rem;
        gap: 0.75rem;
    }

    .promo-text {
        font-size: 0.875rem;
        text-align: center;
    }

    .promo-btn {
        padding: 0.5rem 1.25rem;
        font-size: 0.875rem;
    }

    /* Form Section */
    .form-section {
        padding: 1.5rem;
    }

    /* App Info - Mobile Layout */
    .app-info {
        flex-direction: column;
        text-align: center;
        gap: 1rem;
    }

    .app-photo-container {
        display: flex;
        justify-content: center;
    }

    .app-icon {
        width: 100px;
        height: 100px;
    }

    .app-details h2 {
        font-size: 1.5rem;
    }

    .app-details p {
        font-size: 0.875rem;
    }

    /* Hide desktop table, show mobile layout */
    .rankings-table table {
        display: none;
    }

    .rankings-mobile {
        display: block;
    }

    /* Results Section */
    .results-section {
        padding: 1.5rem;
    }

    /* Footer Ad */
    .footer-ad {
        display: none;
    }

    /* Apps Showcase */
    .apps-showcase {
        padding: 2rem 1rem;
        margin: 1rem;
    }

    .apps-showcase-title {
        font-size: 1.5rem;
    }

    .apps-showcase-subtitle {
        font-size: 0.875rem;
        margin-bottom: 1.5rem;
    }

    .apps-grid {
        grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
        gap: 1rem;
    }

    .app-card {
        max-width: 130px;
        padding: 1rem;
    }

    .app-card-icon,
    .app-card-icon-placeholder {
        width: 70px;
        height: 70px;
    }

    .app-card-name {
        font-size: 0.8rem;
    }
}

/* ========================================
   APPS SHOWCASE SECTION
   ======================================== */
.apps-showcase {
    background: rgba(255, 255, 255, 0.95);
    padding: 3rem 2rem;
    margin: 2rem auto;
    max-width: 1400px;
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
}

.apps-showcase-container {
    max-width: 1200px;
    margin: 0 auto;
}

.apps-showcase-title {
    color: #667eea;
    font-size: 2rem;
    text-align: center;
    margin-bottom: 0.5rem;
}

.apps-showcase-subtitle {
    color: #666;
    font-size: 1rem;
    text-align: center;
    margin-bottom: 2.5rem;
}

.apps-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 1.5rem;
    justify-items: center;
}

.app-card {
    background: white;
    border-radius: 12px;
    padding: 1.25rem;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    width: 100%;
    max-width: 160px;
    text-decoration: none;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.75rem;
}

.app-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.15);
}

.app-card-icon {
    width: 80px;
    height: 80px;
    border-radius: 18px;
    object-fit: cover;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.app-card-name {
    font-size: 0.875rem;
    font-weight: 600;
    color: #333;
    line-height: 1.3;
    margin: 0;
    word-wrap: break-word;
}

.app-card-loading {
    opacity: 0.6;
}

.app-card-icon-placeholder {
    width: 80px;
    height: 80px;
    border-radius: 18px;
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: loading 1.5s infinite;
}

@keyframes loading {
    0% {
        background-position: 200% 0;
    }
    100% {
        background-position: -200% 0;
    }
}

/* ========================================
   TABLET (768px - 1024px)
   ======================================== */
@media (min-width: 768px) and (max-width: 1024px) {
    .side-ad {
        width: 120px;
    }

    .ad-placeholder {
        min-height: 400px;
        font-size: 0.75rem;
    }

    .container {
        gap: 0.5rem;
    }
}
