/**
 * Mobile Responsive Styles for ScamSentinel Dashboard
 */

/* Desktop: Show desktop header, hide mobile wrapper */
.view-header-mobile-wrapper {
    display: none;
}

.desktop-view-header {
    display: flex;
}

/* Hide mobile logout button on desktop */
.btn-logout-mobile-dashboard {
    display: none;
}

/* Mobile breakpoints */
@media screen and (max-width: 768px) {
    /* Show mobile wrapper, hide desktop header */
    .view-header-mobile-wrapper {
        display: block;
        margin-bottom: 1.5rem;
    }

    .desktop-view-header {
        display: none !important;
    }

    /* Mobile button row styling */
    .mobile-button-row {
        display: flex !important;
        justify-content: center;
        align-items: center;
        gap: 1rem;
        margin-bottom: 1.5rem;
    }

    .mobile-button-row .btn-back,
    .mobile-button-row .btn-logout-mobile {
        display: flex !important;
        align-items: center;
        justify-content: center;
        gap: 0.5rem;
        padding: 0.75rem 1.5rem !important;
        font-size: 0.875rem;
        font-weight: 500;
        flex: 1;
        max-width: 130px;
        background: rgba(59, 130, 246, 0.2);
        border: 1px solid rgba(59, 130, 246, 0.3);
        color: #60a5fa;
        border-radius: 8px;
        cursor: pointer;
        transition: all 0.2s ease;
    }

    .mobile-button-row .btn-logout-mobile {
        background: rgba(220, 38, 38, 0.2);
        border-color: rgba(220, 38, 38, 0.3);
        color: #f87171;
    }

    .mobile-button-row .btn-back:hover,
    .mobile-button-row .btn-back:active {
        background: rgba(59, 130, 246, 0.3);
        border-color: rgba(59, 130, 246, 0.5);
    }

    .mobile-button-row .btn-logout-mobile:hover,
    .mobile-button-row .btn-logout-mobile:active {
        background: rgba(220, 38, 38, 0.3);
        border-color: rgba(220, 38, 38, 0.5);
    }

    /* Mobile view title - centered */
    .mobile-view-title {
        text-align: center;
        font-size: 1.75rem;
        font-weight: 600;
        color: #f1f5f9;
        margin: 0 0 1rem 0;
    }

    /* Mobile connection status - centered */
    .mobile-connection-status {
        display: flex !important;
        justify-content: center;
        align-items: center;
        gap: 0.5rem;
        font-size: 0.9rem;
        color: #cbd5e1;
    }

    /* Dashboard header adjustments */
    .dashboard-header {
        padding: 0.75rem 1rem;
        flex-wrap: wrap;
    }

    .header-logo h1 {
        font-size: 1.4rem;
    }

    .header-logo img {
        height: 30px;
    }

    .header-user {
        font-size: 0.875rem;
        gap: 0.5rem;
    }

    .header-user span {
        display: none; /* Hide username on mobile */
    }

    .header-user .btn-logout {
        display: none !important; /* Hide logout button from header on mobile */
    }

    /* Mobile logout button on dashboard view */
    .btn-logout-mobile-dashboard {
        display: inline-block !important;
        padding: 0.5rem 1rem;
        background: #dc2626;
        border: none;
        color: white;
        border-radius: 6px;
        cursor: pointer;
        font-weight: 500;
        font-size: 0.9rem;
        transition: background-color 0.3s ease;
    }

    .btn-logout-mobile-dashboard:hover {
        background: #b91c1c;
    }

    /* Main dashboard padding - reduced for more content width */
    .dashboard-main {
        padding: 0.5rem;
    }
    
    /* View header adjustments */
    .view-header {
        flex-direction: column;
        gap: 1rem;
        align-items: stretch;
        margin-bottom: 1rem;
    }
    
    .view-header h2 {
        font-size: 1.5rem;
    }
    
    .view-filters {
        flex-wrap: wrap;
        gap: 0.5rem;
    }
    
    .filter-select, .filter-input {
        width: 100%;
        font-size: 0.875rem;
    }
    
    /* Transform table to card layout on mobile */
    .call-table {
        background: transparent;
        border: none;
    }

    .call-table-header {
        display: none !important; /* Hide header on mobile */
    }

    .call-table-row {
        display: block !important;
        background: rgba(30, 41, 59, 0.95) !important;
        border-radius: 12px !important;
        padding: 1.25rem !important;
        margin-bottom: 1rem !important;
        border: 1px solid #475569 !important;
        position: relative;
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
        grid-template-columns: none !important; /* Override desktop grid */
    }

    .call-table-row > div {
        display: flex !important;
        justify-content: space-between !important;
        align-items: center !important;
        padding: 0.75rem 0 !important;
        border-bottom: 1px solid rgba(71, 85, 105, 0.3);
        min-height: 44px; /* Touch-friendly */
    }

    .call-table-row > div:last-child {
        border-bottom: none !important;
        padding-bottom: 0 !important;
    }

    /* Add labels for mobile card view */
    .call-table-row > div::before {
        content: attr(data-label);
        font-weight: 600;
        color: #94a3b8;
        font-size: 0.7rem;
        text-transform: uppercase;
        letter-spacing: 0.05em;
        flex-shrink: 0;
        margin-right: 1rem;
    }

    /* Hide empty labels (like the actions column) */
    .call-table-row > div[data-label=""]::before {
        display: none;
    }

    /* Mobile value styling */
    .call-table-row > div {
        font-size: 0.9rem;
        color: #e2e8f0;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    /* Risk and status badges on mobile */
    .risk-badge, .status-badge {
        font-size: 0.7rem !important;
        padding: 0.3rem 0.6rem !important;
        white-space: nowrap;
    }

    /* Action buttons on mobile */
    .btn-view-transcript {
        width: 100% !important;
        padding: 0.875rem !important;
        font-size: 0.9rem !important;
        margin-top: 0.5rem !important;
        font-weight: 600;
        border-radius: 8px;
    }
    
    /* Pagination on mobile */
    .pagination {
        display: flex;
        flex-wrap: wrap;
        justify-content: center;
        gap: 0.5rem;
        margin-top: 1rem;
    }
    
    .pagination button {
        padding: 0.5rem 0.75rem;
        font-size: 0.875rem;
    }
    
    /* Live transcription view mobile */
    .transcription-container {
        padding: 0.5rem;
        margin-bottom: 1rem;
    }

    .transcript-area {
        max-height: 400px;
        font-size: 0.875rem;
        padding: 0.5rem;
    }

    /* Reduce padding in transcript segments for more content width */
    .transcript-segment {
        padding: 0.5rem !important;
        margin-bottom: 0.75rem !important;
    }

    .segment-text {
        line-height: 1.4;
        word-break: break-word;
    }

    /* Hide inline detailed AI analysis within transcript segments on mobile */
    /* This keeps the transcript readable while preserving the overall scam analysis panel */
    .transcript-segment .ai-explanation {
        display: none !important;
    }

    .transcript-segment .known-pattern {
        display: none !important;
    }

    /* Keep category badges visible within segments - they're compact visual indicators */
    .transcript-segment .category-details {
        display: flex !important;
    }

    /* Keep the overall scam analysis panel visible below the transcript */
    .scam-analysis,
    #scam-summary,
    .risk-summary,
    .detected-categories,
    .analysis-summary {
        display: block !important;
    }
    
    .transcript-controls {
        flex-wrap: wrap;
    }
    
    .transcript-controls .btn {
        flex: 1;
        min-width: 100px;
    }
    
    /* Back button mobile */
    .btn-back {
        font-size: 0.75rem;
        padding: 0.4rem 0.8rem;
    }
    
    /* Connection status mobile */
    .connection-status {
        font-size: 0.875rem;
    }
    
    /* Scam analysis mobile */
    .scam-analysis {
        padding: 1rem;
    }
    
    .scam-analysis h3 {
        font-size: 1.2rem;
    }
}

/* Small mobile devices */
@media screen and (max-width: 480px) {
    .dashboard-header {
        padding: 0.5rem;
    }

    .header-logo h1 {
        font-size: 1.2rem;
    }

    .dashboard-main {
        padding: 0.5rem;
    }

    /* Even more compact transcription on small screens */
    .transcription-container {
        padding: 0.25rem;
    }

    .transcript-area {
        padding: 0.25rem;
    }

    .transcript-segment {
        padding: 0.25rem !important;
    }
    
    .view-header h2 {
        font-size: 1.25rem;
    }
    
    .call-table-row {
        padding: 0.75rem;
        font-size: 0.875rem;
    }
    
    .btn-logout {
        padding: 0.4rem 0.8rem;
        font-size: 0.875rem;
    }
}

/* Landscape mobile adjustments */
@media screen and (max-width: 896px) and (orientation: landscape) {
    .dashboard-header {
        padding: 0.5rem 1rem;
    }
    
    .transcript-area {
        max-height: 250px;
    }
    
    .view-header {
        margin-bottom: 0.75rem;
    }
}

/* Touch-friendly adjustments for all mobile devices */
@media (hover: none) and (pointer: coarse) {
    /* Increase touch target sizes */
    .btn, button, .btn-view-transcript, .btn-logout, .btn-back {
        min-height: 44px;
        min-width: 44px;
    }
    
    .filter-select, .filter-input {
        min-height: 44px;
    }
    
    /* Remove hover effects on mobile */
    .call-table-row:hover {
        background: rgba(30, 41, 59, 0.8);
    }
    
    .btn:hover, button:hover {
        transform: none;
    }
}

/* High resolution mobile screens */
@media screen and (min-resolution: 2dppx) and (max-width: 768px) {
    /* Crisp borders for retina displays */
    .call-table-row {
        border-width: 0.5px;
    }
    
    .risk-badge, .status-badge {
        border-width: 0.5px;
    }
}

/* iOS safe area adjustments */
@supports (padding-top: env(safe-area-inset-top)) {
    .dashboard-header {
        padding-top: max(1rem, env(safe-area-inset-top));
    }
    
    .dashboard-main {
        padding-bottom: max(2rem, env(safe-area-inset-bottom));
    }
}