/* Live Room Updates - Mobile Responsive Styles */

/* ==================== TAB BUTTONS ==================== */
.tab-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.625rem 1rem;
    font-size: 0.875rem;
    font-weight: 500;
    border-radius: 0.5rem;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: rgba(255, 255, 255, 0.6);
    transition: all 0.2s ease;
    white-space: nowrap;
}

.tab-btn:hover {
    background: rgba(255, 255, 255, 0.06);
    color: rgba(255, 255, 255, 0.8);
}

.tab-btn.active {
    background: rgba(100, 108, 255, 0.15);
    border-color: rgba(100, 108, 255, 0.3);
    color: #646cff;
}

/* Mobile tabs - scrollable */
@media (max-width: 640px) {
    .tab-btn {
        padding: 0.5rem 0.75rem;
        font-size: 0.75rem;
    }
    
    .tab-btn i {
        display: none;
    }
}

/* ==================== VIEW TOGGLE GROUP ==================== */
.view-toggle-group {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 0.5rem;
    padding: 0.25rem;
}

.view-toggle-group button {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    padding: 0.375rem 0.75rem;
    font-size: 0.75rem;
    font-weight: 500;
    border-radius: 0.375rem;
    background: transparent;
    color: rgba(255, 255, 255, 0.5);
    transition: all 0.2s ease;
    white-space: nowrap;
}

.view-toggle-group button:hover {
    color: rgba(255, 255, 255, 0.8);
}

.view-toggle-group button.active {
    background: rgba(100, 108, 255, 0.2);
    color: #646cff;
}

.view-toggle-divider {
    width: 1px;
    height: 20px;
    background: rgba(255, 255, 255, 0.1);
    margin: 0 0.25rem;
}

@media (max-width: 640px) {
    .view-toggle-group button span {
        display: none;
    }
    
    .view-toggle-group button {
        padding: 0.375rem 0.5rem;
    }
}

/* ==================== CARD HEADER MOBILE ==================== */
@media (max-width: 768px) {
    .card-header {
        padding: 0.875rem 1rem;
    }
    
    .card-header.flex {
        flex-direction: column;
        align-items: flex-start !important;
        gap: 0.75rem;
    }
    
    .card-header .flex.items-center.gap-3 {
        width: 100%;
    }
    
    .card-header > .flex.items-center.gap-3:last-child,
    .card-header > .btn,
    .card-header > a.btn-outline {
        width: 100%;
        justify-content: center;
    }
    
    /* Stats row in card header */
    .card-header span.text-sm.text-textMuted {
        font-size: 0.75rem;
    }
}

/* ==================== ACTIVITY TAB HEADER - MOBILE ==================== */
@media (max-width: 768px) {
    #activity-tab .card-header .flex.items-center.gap-3.flex-wrap {
        flex-direction: column;
        align-items: stretch;
        gap: 0.5rem;
        width: 100%;
    }
    
    #activity-tab .card-header .w-px.h-6 {
        display: none;
    }
    
    /* View toggle and filters row */
    #activity-tab .view-toggle-group {
        width: 100%;
        justify-content: center;
    }
    
    #activity-tab .card-header select {
        flex: 1;
        min-width: 0;
    }
    
    /* Controls row */
    #activity-tab .card-header > .flex.items-center {
        flex-wrap: wrap;
        gap: 0.5rem;
    }
}

/* Activity controls row on mobile */
@media (max-width: 640px) {
    #activity-tab .card-header .flex.items-center.gap-3.flex-wrap {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 0.5rem;
    }
    
    #activity-tab .view-toggle-group {
        grid-column: 1 / -1;
    }
    
    #activity-tab label.flex.items-center {
        grid-column: 1 / -1;
        justify-content: center;
    }
}

/* ==================== STATS BAR MOBILE ==================== */
@media (max-width: 640px) {
    #activity-tab .grid.grid-cols-2.md\:grid-cols-4 {
        grid-template-columns: repeat(2, 1fr);
        gap: 0.5rem;
    }
    
    #activity-tab .grid.grid-cols-2.md\:grid-cols-4 > div {
        padding: 0.5rem;
    }
    
    #activity-tab .grid.grid-cols-2.md\:grid-cols-4 .text-2xl {
        font-size: 1.25rem;
    }
}

/* ==================== USER FILTER TABS ==================== */
#userFilterTabs {
    scrollbar-width: thin;
    scrollbar-color: rgba(100, 108, 255, 0.3) transparent;
}

#userFilterTabs::-webkit-scrollbar {
    height: 4px;
}

#userFilterTabs::-webkit-scrollbar-track {
    background: transparent;
}

#userFilterTabs::-webkit-scrollbar-thumb {
    background: rgba(100, 108, 255, 0.3);
    border-radius: 2px;
}

/* User filter tab buttons */
#userFilterTabs button {
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    padding: 0.375rem 0.75rem;
    font-size: 0.75rem;
    font-weight: 500;
    border-radius: 9999px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: rgba(255, 255, 255, 0.7);
    transition: all 0.2s ease;
    white-space: nowrap;
}

#userFilterTabs button:hover {
    background: rgba(255, 255, 255, 0.1);
    color: white;
}

#userFilterTabs button.active {
    background: rgba(100, 108, 255, 0.2);
    border-color: rgba(100, 108, 255, 0.4);
    color: #a78bfa;
}

/* ==================== ACTIVITY GRID VIEW MOBILE ==================== */
@media (max-width: 768px) {
    #activityGridContainer {
        grid-template-columns: 1fr !important;
    }
}

/* ==================== HISTORY TAB MOBILE ==================== */
@media (max-width: 640px) {
    #history-tab .card-header .flex.items-center.gap-3 {
        flex-direction: column;
        width: 100%;
    }
    
    #history-tab .card-header select {
        width: 100%;
    }
    
    #history-tab .card-header .btn-outline {
        width: 100%;
    }
    
    /* Pagination */
    #historyPagination {
        flex-direction: column;
        gap: 0.75rem;
        text-align: center;
    }
    
    #historyPagination .flex.gap-2 {
        width: 100%;
        justify-content: space-between;
    }
    
    #historyPagination .flex.gap-2 button {
        flex: 1;
    }
}

/* ==================== WEBHOOKS TAB MOBILE ==================== */
@media (max-width: 640px) {
    #webhooks-tab .card-header {
        flex-direction: column;
        gap: 0.75rem;
    }
    
    #webhooks-tab .card-header .btn {
        width: 100%;
    }
}

/* ==================== SUBSCRIPTION CARDS MOBILE ==================== */
@media (max-width: 640px) {
    /* Public room tracking header */
    #subscriptions-tab .card-header .flex.items-center.gap-3:last-child {
        flex-direction: column;
        gap: 0.5rem;
    }
    
    #subscriptions-tab .card-header .btn {
        width: 100%;
    }
}

/* ==================== QUICK STATS MOBILE ==================== */
@media (max-width: 640px) {
    #premiumContent > .max-w-6xl.mb-8 .grid {
        gap: 0.5rem;
    }
    
    #premiumContent > .max-w-6xl.mb-8 .card-body {
        padding: 0.75rem;
    }
    
    #premiumContent > .max-w-6xl.mb-8 .w-12.h-12 {
        width: 2.5rem;
        height: 2.5rem;
    }
    
    #premiumContent > .max-w-6xl.mb-8 .text-2xl {
        font-size: 1.25rem;
    }
    
    #premiumContent > .max-w-6xl.mb-8 .text-sm {
        font-size: 0.75rem;
    }
}

/* ==================== MODALS - OVERRIDE GLOBAL STYLES ==================== */
/* The global tailwind.css forces .modal-overlay .grid to specific columns.
   We need scoped overrides so the modal form grids render correctly. */
.modal-overlay .modal-container .modal-body .grid {
    grid-template-columns: unset;
    gap: unset;
}

.modal-overlay .modal-container .modal-body .grid.grid-cols-2 {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    gap: 0.75rem !important;
}

.modal-overlay .modal-container .modal-body .grid.grid-cols-3 {
    grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
    gap: 0.75rem !important;
}

/* ==================== MODALS MOBILE ==================== */
@media (max-width: 768px) {
    .modal-overlay .modal-container .modal-body .grid.grid-cols-3 {
        grid-template-columns: 1fr !important;
    }
}

@media (max-width: 640px) {
    .modal-overlay {
        padding: 0.5rem !important;
    }

    .modal-container {
        max-height: calc(100vh - 1rem) !important;
        border-radius: 12px !important;
    }

    .modal-header {
        padding: 14px 16px !important;
    }

    .modal-header h3 {
        font-size: 1rem !important;
    }

    .modal-body {
        padding: 16px !important;
    }

    .modal-overlay .modal-container .modal-body .grid.grid-cols-2 {
        grid-template-columns: 1fr !important;
    }

    .modal-body .mb-6 {
        margin-bottom: 1rem;
    }
}

/* ==================== ACTIVITY EVENT CARDS MOBILE ==================== */
@media (max-width: 640px) {
    .activity-event {
        padding: 0.75rem !important;
    }
    
    .activity-event .w-10.h-10 {
        width: 2rem;
        height: 2rem;
    }
    
    .activity-event .text-sm {
        font-size: 0.75rem;
    }
    
    /* Furniture info box mobile */
    .activity-event .mt-2.p-2 {
        padding: 0.5rem;
        font-size: 0.7rem;
    }
}

/* ==================== BOTTOM STATUS BAR ==================== */
@media (max-width: 640px) {
    #activity-tab .mt-4.pt-4.flex {
        flex-direction: column;
        gap: 0.25rem;
        text-align: center;
    }
}

/* ==================== ALERT BOXES MOBILE ==================== */
@media (max-width: 640px) {
    .alert {
        padding: 0.75rem;
        font-size: 0.875rem;
    }
    
    .alert i {
        font-size: 1rem;
    }
}

/* ==================== FORM INPUTS MOBILE ==================== */
@media (max-width: 640px) {
    .form-input,
    select.form-input {
        font-size: 16px; /* Prevents zoom on iOS */
    }
}

/* ==================== CONNECTION STATUS BADGE ==================== */
#connectionStatus {
    font-size: 0.625rem;
    padding: 0.125rem 0.5rem;
}

@media (max-width: 640px) {
    #connectionStatus {
        display: none;
    }
    
    /* Show status in title instead */
    #activity-tab h2 .fa-tower-broadcast {
        position: relative;
    }
}

/* ==================== FULLSCREEN ACTIVITY WALL ==================== */
#fullscreenActivityWall {
    position: fixed;
    inset: 0;
    z-index: 9999;
    background: #0a0b0d;
    display: none;
    flex-direction: column;
}

#fullscreenActivityWall.active {
    display: flex;
}

#fullscreenActivityWall .fullscreen-header {
    padding: 0.75rem 1rem;
    background: rgba(26, 29, 35, 0.9);
    border-bottom: 1px solid rgba(100, 108, 255, 0.2);
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
}

#fullscreenActivityWall .fullscreen-content {
    flex: 1;
    overflow-y: auto;
    padding: 1rem;
}

@media (max-width: 640px) {
    #fullscreenActivityWall .fullscreen-header {
        padding: 0.5rem 0.75rem;
    }
    
    #fullscreenActivityWall .fullscreen-content {
        padding: 0.5rem;
    }
}

/* ==================== SUBSCRIPTION ITEM CARDS ==================== */
.subscription-item {
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: 0.75rem;
    padding: 1rem;
    transition: all 0.2s ease;
}

.subscription-item:hover {
    background: rgba(255, 255, 255, 0.04);
    border-color: rgba(100, 108, 255, 0.2);
}

@media (max-width: 640px) {
    .subscription-item {
        padding: 0.75rem;
    }
    
    .subscription-item .flex.items-center.justify-between {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.75rem;
    }
    
    .subscription-item .flex.items-center.gap-2:last-child {
        width: 100%;
        justify-content: flex-end;
    }
}

/* ==================== WEBHOOK ITEM CARDS ==================== */
.webhook-item {
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: 0.75rem;
    padding: 1rem;
}

@media (max-width: 640px) {
    .webhook-item {
        padding: 0.75rem;
    }
    
    .webhook-item .flex.items-center.justify-between {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
    }
    
    .webhook-item .flex.gap-2 {
        width: 100%;
        flex-wrap: wrap;
    }
    
    .webhook-item .flex.gap-2 button {
        flex: 1;
        min-width: calc(50% - 0.25rem);
    }
}

/* ==================== HISTORY ITEM CARDS ==================== */
.history-item {
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: 0.5rem;
    padding: 0.75rem;
}

@media (max-width: 640px) {
    .history-item {
        padding: 0.5rem;
    }
    
    .history-item .flex.items-start.gap-3 {
        gap: 0.5rem;
    }
    
    .history-item .w-8.h-8 {
        width: 1.5rem;
        height: 1.5rem;
        font-size: 0.625rem;
    }
}

/* ==================== ANIMATIONS ==================== */
@keyframes slideInFromLeft {
    from {
        transform: translateX(-20px);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

.animate-slide-in {
    animation: slideInFromLeft 0.3s ease-out;
}

/* ==================== TOUCH FRIENDLY ==================== */
@media (max-width: 768px) {
    button, 
    .btn, 
    .btn-outline,
    .tab-btn,
    select,
    input[type="checkbox"] {
        min-height: 44px; /* Apple's recommended touch target */
    }
    
    input[type="checkbox"] {
        min-height: auto;
        width: 20px;
        height: 20px;
    }
}
