/**
 * Mobile Responsive Enhancements
 * Additional styles for perfect mobile experience
 */

/* ===== Mobile-First Improvements ===== */

/* Touch-friendly elements */
@media (max-width: 768px) {
    /* Larger touch targets */
    .btn {
        min-height: 48px;
        padding: 14px 28px;
    }
    
    input, select, textarea {
        min-height: 48px;
        font-size: 16px; /* Prevents zoom on iOS */
    }
    
    /* Hamburger menu for navigation */
    .mobile-menu {
        display: block;
        position: fixed;
        top: 20px;
        right: 20px;
        z-index: 1000;
        background: var(--primary);
        color: white;
        border: none;
        border-radius: 8px;
        padding: 12px;
        font-size: 1.5rem;
        cursor: pointer;
    }
    
    /* Stack layout for forms */
    .form-group {
        margin-bottom: 20px;
    }
    
    /* Full width cards on mobile */
    .user-card,
    .scenario-card {
        margin-bottom: 15px;
    }
    
    /* Simplified header */
    .header h1 {
        font-size: 1.8rem;
    }
    
    .header p {
        font-size: 0.95rem;
    }
    
    /* Chat improvements */
    .chat-header {
        padding: 15px;
    }
    
    .chat-header h2 {
        font-size: 1.2rem;
    }
    
    .messages-container {
        padding: 10px;
    }
    
    .message-content {
        max-width: 90%;
    }
    
    /* Voice button prominent on mobile */
    .voice-controls {
        position: fixed;
        bottom: 80px;
        right: 20px;
        z-index: 999;
    }
    
    #voiceBtn {
        width: 60px;
        height: 60px;
        border-radius: 50%;
        background: var(--danger);
        color: white;
        border: none;
        font-size: 1.8rem;
        box-shadow: 0 4px 12px rgba(0,0,0,0.3);
        display: flex;
        align-items: center;
        justify-content: center;
    }
    
    #voiceBtn.listening {
        animation: pulse-voice 1s infinite;
        background: var(--success);
    }
    
    @keyframes pulse-voice {
        0%, 100% { transform: scale(1); }
        50% { transform: scale(1.1); }
    }
    
    /* Sticky footer for chat */
    .chat-footer {
        position: sticky;
        bottom: 0;
        background: white;
        padding: 15px;
        box-shadow: 0 -2px 10px rgba(0,0,0,0.1);
    }
    
    /* Hide sidebar on mobile by default */
    .evaluation-sidebar {
        position: fixed;
        top: 0;
        right: -100%;
        width: 90%;
        max-width: 320px;
        height: 100vh;
        transition: right 0.3s ease;
        z-index: 1001;
        box-shadow: -2px 0 10px rgba(0,0,0,0.3);
    }
    
    .evaluation-sidebar.show {
        right: 0;
    }
    
    /* Toggle button for sidebar */
    .sidebar-toggle {
        position: fixed;
        top: 20px;
        right: 20px;
        z-index: 1000;
        background: var(--primary);
        color: white;
        border: none;
        border-radius: 50%;
        width: 50px;
        height: 50px;
        font-size: 1.5rem;
        box-shadow: 0 2px 8px rgba(0,0,0,0.2);
    }
    
    /* Tables responsive */
    .users-table {
        display: block;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    
    .users-table thead {
        display: none;
    }
    
    .users-table tr {
        display: block;
        margin-bottom: 20px;
        border: 1px solid #e0e0e0;
        border-radius: 8px;
        padding: 15px;
    }
    
    .users-table td {
        display: block;
        text-align: left;
        padding: 8px 0;
        border: none;
    }
    
    .users-table td:before {
        content: attr(data-label);
        font-weight: bold;
        display: inline-block;
        width: 120px;
    }
    
    /* Report adjustments */
    .score-breakdown {
        grid-template-columns: 1fr;
    }
    
    .score-item {
        margin-bottom: 15px;
    }
}

/* ===== Tablet Optimizations ===== */
@media (min-width: 769px) and (max-width: 1024px) {
    .container {
        max-width: 90%;
    }
    
    .chat-main {
        grid-template-columns: 1fr 280px;
    }
    
    .scenarios-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .dashboard-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* ===== Landscape Phone ===== */
@media (max-width: 768px) and (orientation: landscape) {
    .chat-main {
        height: calc(100vh - 60px);
    }
    
    .messages-container {
        height: calc(100vh - 180px);
    }
}

/* ===== Small Phones ===== */
@media (max-width: 360px) {
    .header h1 {
        font-size: 1.5rem;
    }
    
    .btn {
        font-size: 0.9rem;
        padding: 12px 20px;
    }
    
    .score-big {
        font-size: 3rem !important;
    }
    
    .stat-value {
        font-size: 1.2rem;
    }
}

/* ===== PWA Support ===== */
@media (display-mode: standalone) {
    /* App-like experience when installed */
    body {
        padding-top: env(safe-area-inset-top);
        padding-bottom: env(safe-area-inset-bottom);
    }
    
    .chat-header {
        padding-top: calc(20px + env(safe-area-inset-top));
    }
}

/* ===== Toast Notifications ===== */
.toast {
    position: fixed;
    bottom: -100px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--dark);
    color: white;
    padding: 15px 25px;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
    z-index: 9999;
    transition: bottom 0.3s ease;
    max-width: 90%;
    text-align: center;
}

.toast.show {
    bottom: 80px;
}

.toast-success {
    background: var(--success);
}

.toast-error {
    background: var(--danger);
}

.toast-warning {
    background: var(--warning);
    color: var(--dark);
}

/* ===== Accessibility ===== */
@media (prefers-reduced-motion: reduce) {
    * {
        animation: none !important;
        transition: none !important;
    }
}

/* High contrast mode */
@media (prefers-contrast: high) {
    .btn {
        border: 2px solid currentColor;
    }
    
    .message-content {
        border: 2px solid currentColor;
    }
}

/* Dark mode support (optional) */
@media (prefers-color-scheme: dark) {
    /* Uncomment to enable dark mode
    :root {
        --dark: #ECF0F1;
        --light: #2C3E50;
        --white: #1a1a1a;
    }
    
    body {
        background: #1a1a1a;
        color: #ECF0F1;
    }
    */
}

/* ===== Print Styles ===== */
@media print {
    .btn,
    .actions,
    .chat-footer,
    .evaluation-sidebar,
    .header,
    .sidebar-toggle,
    .voice-controls {
        display: none !important;
    }
    
    .message {
        page-break-inside: avoid;
    }
    
    body {
        background: white;
    }
}
