/* Mobile-First Optimizations for TriTownBBS */

/* Base Mobile Styles */
@media screen and (max-width: 768px) {
    
    /* Touch-friendly button sizes */
    button {
        min-height: 44px;
        min-width: 44px;
        padding: 0.75rem 1rem;
        font-size: 16px; /* Prevents zoom on iOS */
    }
    
    /* Larger text for readability */
    body {
        font-size: 16px;
        line-height: 1.6;
    }
    
    /* Container adjustments */
    .container {
        padding: 0.5rem;
    }
    
    .board-container {
        padding: 0.25rem;
        height: 100vh;
    }
    
    /* Header optimizations */
    .app-header {
        margin-bottom: 1rem;
        padding-bottom: 0.5rem;
    }
    
    .ascii-art {
        font-size: 14px;
        margin-bottom: 0.5rem;
    }
    
    .user-info {
        font-size: 14px;
        margin-top: 0.5rem;
    }
    
    /* Board header mobile */
    .board-navigation {
        flex-direction: column;
        gap: 0.5rem;
        align-items: stretch;
    }
    
    .board-title {
        text-align: center;
        font-size: 18px;
        order: -1;
    }
    
    .nav-btn {
        padding: 0.5rem;
        font-size: 14px;
    }
    
    /* Control panel mobile */
    .control-panel {
        flex-direction: column;
        padding: 0.75rem;
        gap: 0.75rem;
    }
    
    .control-panel button,
    .control-panel .admin-link {
        width: 100%;
        text-align: center;
        padding: 0.75rem;
        margin: 0;
    }
    
    /* Board list mobile */
    .board-item {
        padding: 0.75rem;
        cursor: pointer;
        -webkit-tap-highlight-color: rgba(0, 255, 0, 0.1);
    }
    
    .board-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.25rem;
    }
    
    .board-meta {
        align-self: flex-end;
    }
    
    /* Messages mobile optimizations */
    .messages-main {
        margin-bottom: 0.5rem;
    }
    
    .message-list {
        padding: 0.75rem;
    }
    
    .message-item {
        margin-bottom: 1.5rem;
        padding-bottom: 0.75rem;
    }
    
    .message-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.25rem;
        margin-bottom: 0.75rem;
    }
    
    .message-text {
        font-size: 16px;
        line-height: 1.7;
    }
    
    /* Compose section mobile */
    .compose-section {
        padding: 0.75rem;
        position: relative;
    }
    
    .compose-header {
        margin-bottom: 0.75rem;
    }
    
    #message-input {
        min-height: 80px;
        max-height: 200px;
        font-size: 16px; /* Prevents zoom */
        line-height: 1.5;
        resize: none; /* Disable manual resize on mobile */
    }
    
    .compose-actions {
        flex-direction: column;
        gap: 0.5rem;
        margin-top: 0.75rem;
    }
    
    .compose-tips {
        order: -1;
        font-size: 12px;
        text-align: center;
    }
    
    #submit-message {
        width: 100%;
        font-size: 18px;
        padding: 1rem;
        background: #002200;
        font-weight: bold;
    }
    
    #voice-input-btn {
        position: absolute;
        top: 0.5rem;
        right: 0.5rem;
        padding: 0.5rem;
        font-size: 12px;
        z-index: 10;
    }
    
    /* Keyboard helper */
    .keyboard-helper {
        background: #001100;
        border-top: 2px solid #0f0;
        padding: 0.75rem;
        box-shadow: 0 -2px 10px rgba(0, 255, 0, 0.2);
    }
    
    .helper-btn {
        width: 100%;
        padding: 0.75rem 2rem;
        font-size: 18px;
        background: #0f0;
        color: #000;
        font-weight: bold;
    }
    
    /* Modal mobile optimizations */
    .modal-content {
        margin: 2% auto;
        width: 95%;
        max-width: none;
        padding: 1rem;
        max-height: 90vh;
        overflow-y: auto;
    }
    
    .modal-header {
        margin-bottom: 0.75rem;
        padding-bottom: 0.75rem;
    }
    
    .close-modal {
        font-size: 28px;
        padding: 0.25rem;
        min-width: 44px;
        min-height: 44px;
        display: flex;
        align-items: center;
        justify-content: center;
    }
    
    /* Create board form mobile */
    .form-group {
        margin-bottom: 1.25rem;
    }
    
    .form-group input,
    .form-group textarea {
        font-size: 16px; /* Prevents zoom */
        padding: 0.75rem;
    }
    
    .radio-group {
        gap: 0.75rem;
    }
    
    .radio-label {
        padding: 0.75rem;
        border: 1px solid #333;
        background: #111;
        border-radius: 4px;
        cursor: pointer;
        -webkit-tap-highlight-color: rgba(0, 255, 0, 0.1);
    }
    
    .radio-label:has(input:checked) {
        border-color: #0f0;
        background: #002200;
    }
    
    .form-actions {
        flex-direction: column;
        gap: 0.75rem;
        margin-top: 1.5rem;
    }
    
    .form-actions button {
        width: 100%;
        padding: 1rem;
        font-size: 18px;
    }
    
    /* Tip jar mobile */
    .tip-amounts {
        grid-template-columns: 1fr 1fr;
        gap: 0.75rem;
        margin: 1.5rem 0;
    }
    
    .tip-amount-btn {
        padding: 1rem;
        font-size: 16px;
        min-height: 80px;
        display: flex;
        flex-direction: column;
        justify-content: center;
        align-items: center;
    }
    
    .custom-input-group {
        flex-direction: column;
        gap: 0.75rem;
    }
    
    #custom-tip-amount {
        font-size: 16px;
        padding: 0.75rem;
        text-align: center;
    }
    
    .custom-tip-btn {
        width: 100%;
        padding: 0.75rem;
        font-size: 16px;
    }
    
    /* Admin panel mobile */
    .admin-nav {
        flex-direction: column;
        gap: 0.5rem;
        text-align: center;
    }
    
    .stats-grid {
        grid-template-columns: 1fr;
        gap: 0.75rem;
    }
    
    .invite-generators {
        flex-direction: column;
    }
    
    .invite-bulk {
        flex-direction: column;
        gap: 0.75rem;
        align-items: stretch;
    }
    
    .invite-item {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.75rem;
    }
    
    .invite-actions {
        width: 100%;
        justify-content: space-between;
    }
    
    .board-admin-item,
    .user-item {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.75rem;
    }
    
    .board-admin-actions,
    .user-actions {
        width: 100%;
        justify-content: space-between;
    }
    
    .settings-grid {
        grid-template-columns: 1fr;
    }
    
    .danger-actions {
        flex-direction: column;
    }
    
    /* QR Code mobile */
    .qr-display {
        padding: 0.5rem;
    }
    
    #qr-code-container {
        margin: 1rem auto;
        padding: 0.5rem;
        max-width: 280px;
    }
    
    .qr-actions {
        flex-direction: column;
        gap: 0.75rem;
    }
    
    .qr-actions button {
        width: 100%;
    }
    
    /* Auth required mobile */
    .auth-required {
        padding: 1.5rem 1rem;
        margin: 1rem 0;
    }
    
    .auth-required .primary-btn {
        width: 100%;
        padding: 1rem;
        font-size: 18px;
        margin-top: 1rem;
    }
    
    /* Footer mobile */
    .app-footer {
        margin-top: 1rem;
        padding-top: 0.75rem;
        font-size: 10px;
    }
    
    /* Admin message mobile */
    .admin-message {
        position: fixed;
        top: 10px;
        left: 10px;
        right: 10px;
        max-width: none;
        padding: 0.75rem;
        font-size: 14px;
    }
    
    /* Bulk invites mobile */
    .bulk-invite-list {
        max-height: 250px;
        font-size: 11px;
    }
    
    .bulk-invite-item {
        padding: 0.75rem;
        word-break: break-all;
    }
}

/* Very small screens (iPhone SE, etc.) */
@media screen and (max-width: 375px) {
    .container {
        padding: 0.25rem;
    }
    
    .ascii-art {
        font-size: 12px;
    }
    
    .board-title {
        font-size: 16px;
    }
    
    .message-text {
        font-size: 15px;
    }
    
    .tip-amounts {
        grid-template-columns: 1fr;
    }
    
    .tip-amount-btn {
        min-height: 60px;
        font-size: 14px;
    }
}

/* Landscape orientation */
@media screen and (max-width: 768px) and (orientation: landscape) {
    .board-container {
        height: 100vh;
    }
    
    .ascii-art {
        font-size: 12px;
        margin-bottom: 0.25rem;
    }
    
    .app-header {
        margin-bottom: 0.5rem;
        padding-bottom: 0.25rem;
    }
    
    .control-panel {
        padding: 0.5rem;
        margin-bottom: 1rem;
    }
    
    .compose-section {
        padding: 0.5rem;
    }
    
    #message-input {
        min-height: 60px;
        max-height: 120px;
    }
    
    .keyboard-helper {
        padding: 0.5rem;
    }
}

/* Touch improvements */
@media (hover: none) and (pointer: coarse) {
    /* This targets touch devices */
    
    button:hover {
        /* Disable hover effects on touch devices */
        background: inherit;
        text-shadow: inherit;
        transform: none;
    }
    
    button:active {
        background: #0f0;
        color: #000;
        transform: scale(0.95);
    }
    
    .board-item:hover {
        background-color: inherit;
    }
    
    .board-item:active {
        background-color: #002200;
    }
    
    .tip-amount-btn:hover {
        background: inherit;
        text-shadow: inherit;
        transform: none;
    }
    
    .tip-amount-btn:active {
        background: #000055;
        transform: scale(0.95);
    }
    
    /* Add visual feedback for touch */
    button:active,
    .board-item:active,
    .radio-label:active {
        box-shadow: 0 0 10px rgba(0, 255, 0, 0.3);
    }
}

/* Focus styles for accessibility */
@media screen and (max-width: 768px) {
    button:focus,
    input:focus,
    textarea:focus,
    select:focus {
        outline: 2px solid #0ff;
        outline-offset: 2px;
    }
    
    .board-item:focus {
        outline: 2px solid #0f0;
        outline-offset: 2px;
    }
}

/* Dark mode aware */
@media (prefers-color-scheme: dark) {
    /* Already dark by default, but ensure consistency */
    body {
        background-color: #000;
        color: #0f0;
    }
}

/* Reduce motion for accessibility */
@media (prefers-reduced-motion: reduce) {
    * {
        transition: none !important;
        animation: none !important;
    }
    
    button:active {
        transform: none;
    }
    
    .tip-amount-btn:active {
        transform: none;
    }
}