/* Mobile-First Responsive Design for Phoenix Sports Platform */
/* Uses CSS variables defined in variables.css */

/* Touch-friendly improvements */
* {
    -webkit-tap-highlight-color: rgba(0, 123, 204, 0.3);
    -webkit-touch-callout: none;
}

/* Enhanced touch targets */
button, 
.btn, 
.action-button,
input[type="submit"],
input[type="button"],
.quick-link,
.dropdown-btn {
    min-height: 44px !important;
    min-width: 44px !important;
    padding: 12px 16px !important;
    border-radius: 8px !important;
    background: linear-gradient(135deg, var(--primary-blue) 0%, #0052a3 100%) !important;
    color: var(--text-primary) !important;
    border: none !important;
    transition: all 0.3s ease !important;
    box-shadow: 0 4px 16px rgba(0, 82, 163, 0.2) !important;
}

button:hover,
.btn:hover,
.action-button:hover {
    transform: translateY(-2px) !important;
    box-shadow: 0 8px 25px rgba(0, 82, 163, 0.3) !important;
}

/* Mobile form improvements */
input, 
textarea, 
select {
    font-size: 16px !important;
    padding: 12px !important;
    border-radius: 8px !important;
    border: 2px solid rgba(0, 82, 163, 0.2) !important;
    background: rgba(35, 35, 35, 0.8) !important;
    color: var(--text-primary) !important;
    width: 100% !important;
    box-sizing: border-box !important;
    transition: all 0.3s ease !important;
}

input:focus, 
textarea:focus, 
select:focus {
    border-color: var(--primary-blue) !important;
    outline: none !important;
    box-shadow: 0 0 0 3px rgba(0, 82, 163, 0.2) !important;
    background: rgba(35, 35, 35, 0.9) !important;
}

/* Mobile grid layouts */
@media (max-width: 768px) {
    .athlete-profile-section,
    .scout-profile-section,
    .coach-profile-section,
    .profile-quality-indicators {
        grid-template-columns: 1fr !important;
        gap: 15px !important;
    }
    
    .media-preview-section {
        margin-top: 20px;
    }
    
    .media-gallery,
    .comments-section {
        grid-template-columns: 1fr !important;
    }
    
    .profile-completeness-badge,
    .performance-stars {
        text-align: center;
        margin: 10px 0;
    }
}

/* Mobile cards and containers */
@media (max-width: 768px) {
    .hero-card,
    .profile-card,
    .stats-card {
        margin: 10px 0 !important;
        padding: 15px !important;
        border-radius: 12px !important;
        box-shadow: 0 2px 8px rgba(0,0,0,0.1) !important;
    }
    
    .pedestal-container {
        flex-direction: column !important;
        gap: 15px !important;
    }
    
    .selfie-box {
        width: 100% !important;
        max-width: none !important;
    }
}

/* Mobile media gallery */
@media (max-width: 768px) {
    .media-gallery {
        grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)) !important;
        gap: 10px !important;
    }
    
    video, img {
        width: 100% !important;
        height: auto !important;
        border-radius: 8px !important;
    }
    
    .media-preview {
        display: block !important;
        text-align: center !important;
        padding: 15px !important;
    }
}

/* Mobile navigation enhancements */
@media (max-width: 768px) {
    .connection-section,
    .interaction-section {
        text-align: center;
        margin: 15px 0;
    }
    
    .action-button,
    .message-button {
        width: 100% !important;
        margin: 8px 0 !important;
        display: block !important;
        text-align: center !important;
    }
}

/* Mobile modal improvements */
@media (max-width: 768px) {
    .modal,
    #speed-modal {
        padding: 10px !important;
    }
    
    .modal-content {
        width: 95% !important;
        max-width: none !important;
        margin: 20px auto !important;
        border-radius: 12px !important;
    }
    
    .modal h3,
    .modal h4 {
        font-size: 18px !important;
        margin-bottom: 15px !important;
    }
}

/* Mobile forms and inputs */
@media (max-width: 768px) {
    .form-group {
        margin-bottom: 20px !important;
    }
    
    .form-row {
        flex-direction: column !important;
        gap: 15px !important;
    }
    
    .background-options {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 10px !important;
    }
    
    .background-preview {
        padding: 8px !important;
    }
    
    .rating-form {
        padding: 15px !important;
    }
}

/* Mobile text and readability */
@media (max-width: 768px) {
    body {
        font-size: 14px !important;
        line-height: 1.5 !important;
    }
    
    h1 { font-size: 24px !important; }
    h2 { font-size: 20px !important; }
    h3 { font-size: 18px !important; }
    h4 { font-size: 16px !important; }
    
    .athlete-name,
    .hero-profile-name {
        font-size: 22px !important;
        text-align: center !important;
    }
    
    .welcome-text {
        display: none !important;
    }
}

/* Mobile-specific utilities */
@media (max-width: 768px) {
    .desktop-only {
        display: none !important;
    }
    
    .mobile-center {
        text-align: center !important;
    }
    
    .mobile-full-width {
        width: 100% !important;
        display: block !important;
    }
    
    .mobile-stack {
        flex-direction: column !important;
        gap: 10px !important;
    }
    
    .mobile-hide {
        display: none !important;
    }
}

/* Swipe gesture indicators */
.swipe-indicator {
    position: relative;
}

.swipe-indicator::after {
    content: "← Swipe →";
    position: absolute;
    bottom: 5px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0,0,0,0.7);
    color: white;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 10px;
    opacity: 0.8;
}

/* Loading states for mobile */
.loading {
    position: relative;
    pointer-events: none;
}

.loading::after {
    content: "";
    position: absolute;
    top: 50%;
    left: 50%;
    width: 20px;
    height: 20px;
    margin: -10px 0 0 -10px;
    border: 2px solid #f3f3f3;
    border-top: 2px solid #0052a3;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

/* Pull-to-refresh indicator */
.pull-to-refresh {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 60px;
    background: linear-gradient(to bottom, #0052a3, transparent);
    transform: translateY(-60px);
    transition: transform 0.3s ease;
    z-index: 999;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: bold;
}

.pull-to-refresh.visible {
    transform: translateY(0);
}

/* Mobile-optimized animations */
@media (max-width: 768px) {
    * {
        animation-duration: 0.2s !important;
        transition-duration: 0.2s !important;
    }
    
    .dropdown-content {
        animation: mobileDropdownSlide 0.25s ease-out;
    }
}

@keyframes mobileDropdownSlide {
    from {
        opacity: 0;
        transform: translateY(-5px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* High DPI/Retina display optimizations */
@media (-webkit-min-device-pixel-ratio: 2) {
    .logo,
    .generated-avatar,
    .profile-image {
        image-rendering: -webkit-optimize-contrast;
        image-rendering: crisp-edges;
    }
}

/* Dark mode support for mobile */
@media (prefers-color-scheme: dark) and (max-width: 768px) {
    .modal-content,
    .hero-card,
    .profile-card {
        background-color: #2d3748 !important;
        color: #fff !important;
        border: 1px solid #4a5568 !important;
    }
    
    input, textarea, select {
        background-color: #4a5568 !important;
        color: #fff !important;
        border-color: #718096 !important;
    }
}

/* iOS Safari specific fixes */
@supports (-webkit-touch-callout: none) {
    .navbar {
        padding-top: env(safe-area-inset-top, 0) !important;
    }
    
    .main-content {
        padding-bottom: env(safe-area-inset-bottom, 20px) !important;
    }
    
    input[type="file"] {
        font-size: 17px !important; /* Prevents zoom */
    }
}

/* Mobile-specific icon-only quick links */
@media (max-width: 768px) {
    /* Ensure navbar-left maintains row layout on mobile */
    .navbar-left {
        display: flex !important;
        flex-direction: row !important;
        align-items: flex-end !important;
        justify-content: flex-start !important;
        height: 100% !important;
        padding-top: 15px !important;
        padding-bottom: 15px !important;
        gap: 8px !important;
    }
    
    .quick-links {
        gap: 8px !important;
    }
    
    .quick-link.icon-only {
        min-width: 32px !important;
        min-height: 26px !important;
        padding: 8px 10px !important;
        border-radius: 8px !important;
    }
    
    .quick-link.icon-only .icon {
        font-size: 16px !important;
    }
    
    /* Hide tooltips on mobile since we have touch */
    .quick-link.icon-only::after,
    .quick-link.icon-only::before {
        display: none !important;
    }
    
    /* Mobile dropdown button styling - small rectangle to match quick-links */
    .dropdown-btn.icon-only {
        min-width: 32px !important;
        min-height: 26px !important;
        padding: 8px 10px !important;
        border-radius: 8px !important;
    }
    
    .dropdown-btn.icon-only .hamburger-icon {
        font-size: 16px !important;
    }

}

/* ==================== DASHBOARD MOBILE LAYOUTS ==================== */

/* Athletic Director Dashboard Mobile */
@media (max-width: 768px) {
    /* Force all dashboard grids to single column */
    .athletic-director-dashboard [style*="display: grid"],
    .coach-dashboard [style*="display: grid"] {
        display: flex !important;
        flex-direction: column !important;
        gap: 12px !important;
    }
    
    /* Dashboard action buttons - full width, easy to tap */
    .athletic-director-dashboard a[style*="background-color"],
    .coach-dashboard a[style*="background-color"] {
        display: block !important;
        width: 100% !important;
        text-align: center !important;
        padding: 16px 20px !important;
        margin-bottom: 10px !important;
        border-radius: 8px !important;
        font-size: 16px !important;
        font-weight: 600 !important;
        text-decoration: none !important;
        box-sizing: border-box !important;
    }
    
    /* Dashboard sections - better mobile spacing */
    .athletic-director-dashboard > div,
    .coach-dashboard > div {
        margin-bottom: 20px !important;
        padding: 15px !important;
        border-radius: 8px !important;
    }
    
    /* Dashboard headers */
    .athletic-director-dashboard h2,
    .coach-dashboard h2,
    .athletic-director-dashboard h3,
    .coach-dashboard h3 {
        font-size: 18px !important;
        margin-bottom: 15px !important;
        text-align: center !important;
    }
    
    /* Dashboard stats grid - single column on mobile */
    .athletic-director-dashboard .stats-grid,
    .coach-dashboard .stats-grid {
        display: flex !important;
        flex-direction: column !important;
        gap: 10px !important;
    }
    
    /* Stats cards - full width */
    .athletic-director-dashboard .stat-card,
    .coach-dashboard .stat-card {
        width: 100% !important;
        padding: 15px !important;
        text-align: center !important;
        border-radius: 8px !important;
        margin-bottom: 10px !important;
    }
    
    /* Program info sections */
    .athletic-director-dashboard .program-info,
    .coach-dashboard .team-info {
        padding: 15px !important;
        margin-bottom: 15px !important;
    }
    
    .athletic-director-dashboard .program-info p,
    .coach-dashboard .team-info p {
        margin-bottom: 8px !important;
        font-size: 14px !important;
        line-height: 1.4 !important;
    }
    
    /* Management tools section */
    .athletic-director-dashboard .management-tools,
    .coach-dashboard .coaching-tools {
        padding: 15px !important;
    }
    
    .athletic-director-dashboard .management-tools h3,
    .coach-dashboard .coaching-tools h3 {
        margin-bottom: 15px !important;
        text-align: center !important;
    }
    
    /* Quick actions section - stack vertically */
    .athletic-director-dashboard .quick-actions,
    .coach-dashboard .quick-actions {
        display: flex !important;
        flex-direction: column !important;
        gap: 10px !important;
    }
    
    /* Recent activity section */
    .athletic-director-dashboard .recent-activity,
    .coach-dashboard .recent-activity {
        padding: 15px !important;
    }
    
    .athletic-director-dashboard .activity-item,
    .coach-dashboard .activity-item {
        padding: 12px !important;
        margin-bottom: 10px !important;
        border-radius: 6px !important;
        font-size: 14px !important;
    }
    
    /* Make sure all text is readable on mobile */
    .athletic-director-dashboard,
    .coach-dashboard {
        font-size: 14px !important;
        line-height: 1.5 !important;
    }
    
    /* Override any fixed widths */
    .athletic-director-dashboard *,
    .coach-dashboard * {
        max-width: 100% !important;
        box-sizing: border-box !important;
    }
    
    /* Better spacing for mobile */
    .athletic-director-dashboard,
    .coach-dashboard {
        padding: 10px !important;
        margin: 0 !important;
    }
    
    /* Responsive button sizing for mobile touch */
    .athletic-director-dashboard button,
    .coach-dashboard button,
    .athletic-director-dashboard .btn,
    .coach-dashboard .btn {
        min-height: 44px !important; /* iOS touch target minimum */
        padding: 12px 16px !important;
        font-size: 16px !important;
        border-radius: 8px !important;
        width: 100% !important;
        margin-bottom: 10px !important;
    }
}

/* Extra small screens (phones in portrait) */
@media (max-width: 480px) {
    .athletic-director-dashboard a[style*="background-color"],
    .coach-dashboard a[style*="background-color"] {
        padding: 18px 16px !important;
        font-size: 15px !important;
    }
    
    .athletic-director-dashboard h2,
    .coach-dashboard h2 {
        font-size: 16px !important;
    }
    
    .athletic-director-dashboard h3,
    .coach-dashboard h3 {
        font-size: 15px !important;
    }
}
