/* Mobile-First Responsive Design for Android Phones */

/* Base Mobile Styles */
* {
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    user-select: none;
}

html {
    font-size: 16px;
    -webkit-text-size-adjust: 100%;
    -ms-text-size-adjust: 100%;
    scroll-behavior: smooth;
}

body {
    margin: 0;
    padding: 0;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    line-height: 1.4;
    overflow-x: hidden;
    background: #1a1a2e;
    color: #ffffff;
    min-height: 100vh;
    touch-action: manipulation;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* Container Styles */
.container, .game-container, .main-container {
    width: 100%;
    max-width: 100vw;
    padding: 0 15px;
    margin: 0 auto;
    overflow-x: hidden;
}

/* Header & Navigation */
.header, .nav-header, .navbar {
    position: sticky;
    top: 0;
    z-index: 1000;
    background: rgba(26, 26, 46, 0.95);
    backdrop-filter: blur(10px);
    padding: 10px 15px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.nav-menu, .navbar-menu {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
}

.nav-item, .nav-link, .navbar-link {
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 14px;
    text-decoration: none;
    color: #ffffff;
    transition: all 0.2s ease;
    min-height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.nav-item:active, .nav-link:active, .navbar-link:active {
    background: rgba(233, 69, 96, 0.2);
    transform: scale(0.95);
}

/* Mobile Menu Toggle */
.mobile-menu-btn {
    display: none;
    background: none;
    border: none;
    color: #ffffff;
    font-size: 1.5rem;
    cursor: pointer;
    padding: 8px;
    border-radius: 4px;
    min-height: 44px;
    min-width: 44px;
}

.mobile-menu-btn:active {
    background: rgba(255, 255, 255, 0.1);
}

/* Button Styles */
.btn, button, .button {
    min-height: 44px;
    padding: 12px 20px;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    background: linear-gradient(135deg, #e94560, #ff6b6b);
    color: white;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    touch-action: manipulation;
}

.btn:active, button:active, .button:active {
    transform: scale(0.95);
    background: linear-gradient(135deg, #d63851, #e94560);
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.btn-secondary:active {
    background: rgba(255, 255, 255, 0.2);
}

/* Form Elements */
input, textarea, select {
    width: 100%;
    min-height: 44px;
    padding: 12px 16px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.05);
    color: #ffffff;
    font-size: 16px; /* Prevents zoom on iOS */
    transition: all 0.2s ease;
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
}

input:focus, textarea:focus, select:focus {
    outline: none;
    border-color: #e94560;
    background: rgba(255, 255, 255, 0.1);
    box-shadow: 0 0 0 2px rgba(233, 69, 96, 0.2);
}

/* Special input types for mobile */
input[type="email"] {
    -webkit-text-size-adjust: 100%;
    text-transform: none;
}

input[type="tel"] {
    -webkit-text-size-adjust: 100%;
}

input[type="password"] {
    -webkit-text-security: disc;
}

/* Password boxes for special login */
.password-box {
    width: 60px !important;
    height: 60px !important;
    text-align: center;
    font-size: 1.5rem;
    font-weight: bold;
    margin: 0 5px;
}

.password-boxes {
    display: flex;
    gap: 10px;
    justify-content: center;
    flex-wrap: wrap;
}

/* Game Page Specific */
.game-board {
    height: 45vh;
    min-height: 280px;
    max-height: 400px;
    position: relative;
    background: linear-gradient(to bottom, #0f3460, #1a1a2e);
    border-radius: 0 0 20px 20px;
    overflow: hidden;
}

.photo-selection-section {
    padding: 15px;
    background: linear-gradient(to bottom, #16213e, #0f3460);
    border-radius: 20px 20px 0 0;
    margin-top: -20px;
    position: relative;
    z-index: 10;
}

.photo-container {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    padding: 10px 0;
    scroll-snap-type: x mandatory;
    -webkit-overflow-scrolling: touch;
}

.photo-container::-webkit-scrollbar {
    display: none;
}

.photo-option {
    flex: 0 0 85px;
    height: 120px;
    border-radius: 12px;
    overflow: hidden;
    scroll-snap-align: start;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    transition: all 0.2s ease;
}

.photo-option:active {
    transform: scale(0.95);
    background: rgba(233, 69, 96, 0.1);
}

.photo-image {
    width: 100%;
    height: 80px;
    object-fit: cover;
}

.photo-info {
    padding: 6px;
    text-align: center;
    font-size: 11px;
}

/* Analytics Page */
.analytics-container {
    padding: 15px;
    max-width: 100%;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 15px;
    margin: 20px 0;
}

.stat-card {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    padding: 15px;
    text-align: center;
}

.chart-container {
    width: 100%;
    height: 250px;
    margin: 20px 0;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 12px;
    padding: 15px;
}

/* Certificate Page */
.certificate-container {
    padding: 20px 15px;
    text-align: center;
}

.certificate {
    background: linear-gradient(135deg, #16213e, #0f3460);
    border: 2px solid #e94560;
    border-radius: 15px;
    padding: 30px 20px;
    margin: 20px 0;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
}

.certificate-title {
    font-size: 24px;
    color: #e94560;
    margin-bottom: 20px;
    font-weight: bold;
}

.certificate-content {
    font-size: 16px;
    line-height: 1.6;
    margin-bottom: 20px;
}

/* Messenger Page */
.messenger-container {
    display: flex;
    flex-direction: column;
    height: 100vh;
    max-height: 100vh;
}

.chat-header {
    background: rgba(26, 26, 46, 0.95);
    padding: 15px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    position: sticky;
    top: 0;
    z-index: 100;
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 15px;
    -webkit-overflow-scrolling: touch;
}

.message {
    margin-bottom: 15px;
    max-width: 85%;
    word-wrap: break-word;
}

.message.sent {
    margin-left: auto;
    background: #e94560;
    color: white;
    border-radius: 18px 18px 4px 18px;
    padding: 12px 16px;
}

.message.received {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 18px 18px 18px 4px;
    padding: 12px 16px;
}

.chat-input-container {
    padding: 15px;
    background: rgba(26, 26, 46, 0.95);
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    display: flex;
    gap: 10px;
    align-items: flex-end;
}

.chat-input {
    flex: 1;
    min-height: 44px;
    max-height: 120px;
    resize: none;
    border-radius: 22px;
    padding: 12px 16px;
}

.send-btn {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Profile Page */
.profile-container {
    padding: 15px;
    max-width: 100%;
}

.profile-header {
    text-align: center;
    padding: 30px 0;
    background: linear-gradient(135deg, #16213e, #0f3460);
    border-radius: 20px;
    margin-bottom: 20px;
}

.profile-avatar {
    width: 100px;
    height: 100px;
    border-radius: 50%;
    border: 3px solid #e94560;
    margin: 0 auto 15px;
    display: block;
    object-fit: cover;
}

.profile-name {
    font-size: 24px;
    font-weight: bold;
    margin-bottom: 5px;
    color: #e94560;
}

.profile-bio {
    font-size: 14px;
    color: #aaa;
    max-width: 300px;
    margin: 0 auto;
}

.profile-stats {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 15px;
    margin: 20px 0;
}

.profile-stat {
    text-align: center;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 12px;
    padding: 15px 10px;
}

.stat-number {
    font-size: 20px;
    font-weight: bold;
    color: #e94560;
    display: block;
}

.stat-label {
    font-size: 12px;
    color: #aaa;
    margin-top: 5px;
}

.profile-sections {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.profile-section {
    background: rgba(255, 255, 255, 0.05);
    border-radius: 12px;
    padding: 20px;
}

.section-title {
    font-size: 18px;
    font-weight: bold;
    margin-bottom: 15px;
    color: #e94560;
}

/* Loading States */
.loading {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 40px;
    font-size: 16px;
    color: #e94560;
}

.spinner {
    width: 20px;
    height: 20px;
    border: 2px solid rgba(233, 69, 96, 0.3);
    border-top: 2px solid #e94560;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-right: 10px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Modal & Popup */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    padding: 20px;
}

.modal-content {
    background: linear-gradient(135deg, #16213e, #0f3460);
    border-radius: 15px;
    padding: 25px;
    max-width: 90%;
    max-height: 80%;
    overflow-y: auto;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

/* Utility Classes */
.text-center { text-align: center; }
.text-left { text-align: left; }
.text-right { text-align: right; }

.mb-10 { margin-bottom: 10px; }
.mb-15 { margin-bottom: 15px; }
.mb-20 { margin-bottom: 20px; }

.mt-10 { margin-top: 10px; }
.mt-15 { margin-top: 15px; }
.mt-20 { margin-top: 20px; }

.p-10 { padding: 10px; }
.p-15 { padding: 15px; }
.p-20 { padding: 20px; }

.hidden { display: none !important; }
.visible { display: block !important; }

.flex { display: flex; }
.flex-column { flex-direction: column; }
.flex-center { align-items: center; justify-content: center; }
.flex-between { justify-content: space-between; }
.flex-wrap { flex-wrap: wrap; }

.w-full { width: 100%; }
.h-full { height: 100%; }

/* Responsive Breakpoints - Industry Standard */
/* Large Desktop: 1200px+ (default) */
/* Desktop: 1024px - 1199px */
@media (max-width: 1199px) {
    .container, .game-container, .main-container {
        max-width: 1024px;
        padding: 0 20px;
    }
    
    .main-layout {
        gap: 1rem;
    }
    
    .sidebar {
        min-width: 200px;
        max-width: 250px;
    }
}

/* Tablet: 768px - 1023px */
@media (max-width: 1023px) {
    .container, .game-container, .main-container {
        max-width: 768px;
        padding: 0 15px;
    }
    
    .main-layout {
        gap: 0.8rem;
    }
    
    .sidebar {
        min-width: 180px;
        max-width: 220px;
    }
    
    .photo-option {
        flex: 0 0 80px;
        height: 115px;
    }
    
    .photo-image {
        height: 75px;
    }
}

/* Mobile: 480px - 767px */
@media (max-width: 767px) {
    .container, .game-container, .main-container {
        padding: 0 10px;
    }
    
    .mobile-menu-btn {
        display: block;
    }
    
    .nav-menu, .navbar-menu {
        position: fixed;
        top: 60px;
        left: 0;
        right: 0;
        background: rgba(26, 26, 46, 0.98);
        flex-direction: column;
        padding: 20px;
        transform: translateY(-100%);
        transition: transform 0.3s ease;
        z-index: 999;
        backdrop-filter: blur(15px);
    }
    
    .nav-menu.active, .navbar-menu.active {
        transform: translateY(0);
    }
    
    .main-layout {
        display: flex;
        flex-direction: row;
        gap: 0.8rem;
    }
    
    .content {
        flex: 7;
        min-width: 0;
    }
    
    .sidebar {
        flex: 3;
        position: sticky;
        top: 80px;
        height: fit-content;
        min-width: 120px;
    }
    
    .photo-option {
        flex: 0 0 75px;
        height: 110px;
    }
    
    .photo-image {
        height: 70px;
    }
    
    .btn, button, .button {
        padding: 10px 16px;
        font-size: 14px;
    }
    
    .profile-avatar {
        width: 80px;
        height: 80px;
    }
    
    .profile-name {
        font-size: 20px;
    }
    
    .certificate-title {
        font-size: 20px;
    }
    
    .modal-content {
        padding: 20px;
        max-width: 95%;
    }
    
    /* Article cards mobile optimization */
    .article-card {
        margin-bottom: 1rem;
    }
    
    .article-content {
        padding: 1rem;
    }
    
    .article-title {
        font-size: 1.2rem;
        line-height: 1.3;
    }
    
    /* Login form mobile optimization */
    .login-form-container {
        padding: 20px;
        margin: 10px;
    }
    
    .login-header h1 {
        font-size: 1.5rem;
    }
    
    /* Profile page mobile optimization */
    .profile-container {
        padding: 0 10px;
    }
    
    .profile-header {
        padding: 1.5rem 1rem;
    }
    
    .profile-stats {
        gap: 1rem;
    }
    
    /* Debate page mobile optimization */
    .debate-arena {
        padding: 10px;
    }
    
    .question-container {
        padding: 15px;
    }
    
    .answer-options {
        gap: 10px;
    }
    
    .answer-option {
        padding: 12px;
        font-size: 14px;
    }
}

/* Small Mobile: up to 479px */
@media (max-width: 479px) {
    html {
        font-size: 14px;
    }
    
    .container, .game-container, .main-container {
        padding: 0 8px;
    }
    
    .main-layout {
        gap: 0.5rem;
    }
    
    .sidebar {
        min-width: 160px;
        max-width: 180px;
    }
    
    .ideology-test-container {
        padding: 1rem 0.8rem;
    }
    
    .ideology-test-title {
        font-size: 1.2rem;
    }
    
    .ideology-test-button {
        padding: 0.8rem 1.2rem;
        font-size: 0.9rem;
    }
    
    .photo-option {
        flex: 0 0 70px;
        height: 100px;
    }
    
    .photo-image {
        height: 65px;
    }
    
    .profile-stats {
        grid-template-columns: repeat(2, 1fr);
        gap: 0.5rem;
    }
    
    .stats-grid {
        grid-template-columns: 1fr;
    }
    
    .btn, button, .button {
        padding: 8px 12px;
        font-size: 13px;
    }
    
    .login-form-container {
        padding: 15px;
        margin: 5px;
    }
    
    .password-box {
        width: 50px !important;
        height: 50px !important;
        font-size: 1.2rem;
    }
    
    .article-title {
        font-size: 1.1rem;
    }
    
    .nav-item, .nav-link, .navbar-link {
        font-size: 13px;
        padding: 6px 10px;
    }
}

/* Extra Small Mobile: up to 359px */
@media (max-width: 359px) {
    html {
        font-size: 13px;
    }
    
    .container, .game-container, .main-container {
        padding: 0 5px;
    }
    
    .main-layout {
        gap: 0.3rem;
    }
    
    .sidebar {
        min-width: 140px;
        max-width: 160px;
    }
    
    .ideology-test-container {
        padding: 0.8rem 0.5rem;
    }
    
    .ideology-test-title {
        font-size: 1rem;
    }
    
    .ideology-test-button {
        padding: 0.6rem 1rem;
        font-size: 0.8rem;
    }
    
    .photo-option {
        flex: 0 0 65px;
        height: 90px;
    }
    
    .photo-image {
        height: 60px;
    }
    
    .profile-stats {
        grid-template-columns: 1fr;
        gap: 0.5rem;
    }
    
    .stats-grid {
        grid-template-columns: 1fr;
    }
    
    .password-box {
        width: 45px !important;
        height: 45px !important;
        font-size: 1rem;
    }
    
    .btn, button, .button {
        padding: 6px 10px;
        font-size: 12px;
    }
    
    .login-form-container {
        padding: 10px;
        margin: 2px;
    }
    
    .modal-content {
        padding: 15px;
        max-width: 98%;
    }
}

/* Dark Mode Enhancements */
@media (prefers-color-scheme: dark) {
    body {
        background: #0a0a0a;
    }
    
    .modal {
        background: rgba(0, 0, 0, 0.9);
    }
}

/* High DPI Displays */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
    .photo-image, .profile-avatar {
        image-rendering: -webkit-optimize-contrast;
        image-rendering: crisp-edges;
    }
}

/* Landscape Orientation */
@media (orientation: landscape) and (max-height: 500px) {
    .game-board {
        height: 35vh;
        min-height: 200px;
    }
    
    .messenger-container {
        height: 100vh;
    }
    
    .profile-header {
        padding: 20px 0;
    }
    
    .profile-avatar {
        width: 70px;
        height: 70px;
    }
}

/* Accessibility */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* Focus Styles for Keyboard Navigation */
button:focus, .btn:focus, input:focus, textarea:focus, select:focus {
    outline: 2px solid #e94560;
    outline-offset: 2px;
}

/* Safe Area for Notched Phones */
@supports (padding: max(0px)) {
    .header, .nav-header {
        padding-top: max(10px, env(safe-area-inset-top));
    }
    
    .chat-input-container {
        padding-bottom: max(15px, env(safe-area-inset-bottom));
    }
    
    body {
        padding-left: env(safe-area-inset-left);
        padding-right: env(safe-area-inset-right);
    }
}