/**
 * Play Golf Pro - PWA & Mobile Optimization Styles
 * Version: 3.1.0
 */

/* ==========================================================================
   PWA Install Banner & Update Notification
   ========================================================================== */

.gsp-install-banner {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: linear-gradient(135deg, #166534 0%, #15803d 100%);
    color: white;
    padding: 16px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    z-index: 9999;
    box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.15);
    transform: translateY(100%);
    transition: transform 0.3s ease;
}

.gsp-install-banner.show {
    transform: translateY(0);
}

.gsp-install-banner__content {
    display: flex;
    align-items: center;
    gap: 12px;
    flex: 1;
}

.gsp-install-banner__icon {
    width: 48px;
    height: 48px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.gsp-install-banner__icon svg {
    width: 28px;
    height: 28px;
}

.gsp-install-banner__text h4 {
    font-size: 16px;
    font-weight: 600;
    margin: 0 0 4px;
}

.gsp-install-banner__text p {
    font-size: 13px;
    opacity: 0.9;
    margin: 0;
}

.gsp-install-banner__actions {
    display: flex;
    gap: 8px;
    flex-shrink: 0;
}

.gsp-install-banner__btn {
    padding: 10px 20px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    border: none;
}

.gsp-install-banner__btn--primary {
    background: white;
    color: #166534;
}

.gsp-install-banner__btn--primary:hover {
    background: #f0fdf4;
    transform: translateY(-1px);
}

.gsp-install-banner__btn--secondary {
    background: transparent;
    color: white;
    border: 1px solid rgba(255, 255, 255, 0.3);
}

.gsp-install-banner__btn--secondary:hover {
    background: rgba(255, 255, 255, 0.1);
}

/* Update Banner */
.gsp-update-banner {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    background: #1e40af;
    color: white;
    padding: 12px 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 16px;
    z-index: 9999;
    font-size: 14px;
}

.gsp-update-banner button {
    padding: 6px 16px;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    border: none;
    transition: all 0.2s;
}

.gsp-update-banner button:first-of-type {
    background: white;
    color: #1e40af;
}

.gsp-update-banner button:last-of-type {
    background: transparent;
    color: white;
    border: 1px solid rgba(255, 255, 255, 0.3);
}

/* ==========================================================================
   Toast Notifications
   ========================================================================== */

.gsp-toast {
    position: fixed;
    bottom: 80px;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    background: #1f2937;
    color: white;
    padding: 14px 24px;
    border-radius: 12px;
    font-size: 14px;
    font-weight: 500;
    z-index: 9998;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
    opacity: 0;
    transition: all 0.3s ease;
    max-width: calc(100% - 40px);
    text-align: center;
}

.gsp-toast.show {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
}

.gsp-toast-success {
    background: #166534;
}

.gsp-toast-warning {
    background: #b45309;
}

.gsp-toast-error {
    background: #b91c1c;
}

.gsp-toast-info {
    background: #1e40af;
}

/* ==========================================================================
   Offline Indicator
   ========================================================================== */

.gsp-offline-indicator {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    background: #b45309;
    color: white;
    padding: 8px 16px;
    text-align: center;
    font-size: 13px;
    font-weight: 500;
    z-index: 9997;
    display: none;
}

body.gsp-offline .gsp-offline-indicator {
    display: block;
}

body.gsp-offline .gsp-app-container {
    padding-top: 36px;
}

/* ==========================================================================
   Mobile Navigation - Bottom Tab Bar
   ========================================================================== */

@media (max-width: 768px) {
    .gsp-nav {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        top: auto;
        background: white;
        border-top: 1px solid #e5e7eb;
        border-radius: 0;
        padding: 0;
        z-index: 1000;
        box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.1);
    }
    
    .gsp-nav__list {
        display: flex;
        justify-content: space-around;
        padding: 8px 0;
        margin: 0;
        list-style: none;
    }
    
    .gsp-nav__item {
        flex: 1;
        text-align: center;
    }
    
    .gsp-nav__link {
        display: flex;
        flex-direction: column;
        align-items: center;
        gap: 4px;
        padding: 8px 4px;
        color: #6b7280;
        text-decoration: none;
        font-size: 11px;
        font-weight: 500;
        transition: color 0.2s;
    }
    
    .gsp-nav__link svg {
        width: 24px;
        height: 24px;
    }
    
    .gsp-nav__link.active {
        color: #166534;
    }
    
    .gsp-nav__link.active svg {
        transform: scale(1.1);
    }
    
    /* Main content padding for bottom nav */
    .gsp-app-content {
        padding-bottom: 80px;
    }
    
    /* Hide text labels on very small screens */
    @media (max-width: 360px) {
        .gsp-nav__link span {
            display: none;
        }
        
        .gsp-nav__link svg {
            width: 28px;
            height: 28px;
        }
    }
}

/* ==========================================================================
   Touch-Friendly UI Elements
   ========================================================================== */

/* Larger touch targets */
.gsp-btn,
.gsp-button,
button,
[role="button"] {
    min-height: 44px;
    min-width: 44px;
}

/* Touch-friendly form inputs */
.gsp-input,
.gsp-select,
input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
input[type="tel"],
input[type="date"],
input[type="time"],
select,
textarea {
    min-height: 48px;
    font-size: 16px; /* Prevents zoom on iOS */
    padding: 12px 16px;
    border-radius: 12px;
    border: 2px solid #e5e7eb;
    transition: border-color 0.2s, box-shadow 0.2s;
    -webkit-appearance: none;
    appearance: none;
}

.gsp-input:focus,
.gsp-select:focus,
input:focus,
select:focus,
textarea:focus {
    outline: none;
    border-color: #166534;
    box-shadow: 0 0 0 3px rgba(22, 101, 52, 0.1);
}

/* Touch-friendly checkboxes and radios */
.gsp-checkbox,
.gsp-radio {
    width: 24px;
    height: 24px;
    cursor: pointer;
}

/* Touch-friendly links */
.gsp-link {
    padding: 8px 0;
    display: inline-block;
}

/* ==========================================================================
   Mobile Cards & Lists
   ========================================================================== */

.gsp-card {
    background: white;
    border-radius: 16px;
    padding: 20px;
    margin-bottom: 16px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

@media (max-width: 768px) {
    .gsp-card {
        border-radius: 0;
        margin-left: -16px;
        margin-right: -16px;
        padding: 16px;
    }
}

.gsp-list-item {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 16px;
    border-bottom: 1px solid #f3f4f6;
    transition: background 0.2s;
    -webkit-tap-highlight-color: transparent;
}

.gsp-list-item:active {
    background: #f9fafb;
}

.gsp-list-item:last-child {
    border-bottom: none;
}

/* ==========================================================================
   Swipe Actions
   ========================================================================== */

.gsp-swipeable {
    position: relative;
    overflow: hidden;
}

.gsp-swipeable__content {
    position: relative;
    z-index: 1;
    background: white;
    transition: transform 0.3s ease;
}

.gsp-swipeable__actions {
    position: absolute;
    top: 0;
    bottom: 0;
    right: 0;
    display: flex;
    z-index: 0;
}

.gsp-swipeable__action {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 80px;
    color: white;
    font-size: 13px;
    font-weight: 600;
}

.gsp-swipeable__action--delete {
    background: #dc2626;
}

.gsp-swipeable__action--edit {
    background: #2563eb;
}

.gsp-swipeable__action--archive {
    background: #7c3aed;
}

/* ==========================================================================
   Pull to Refresh
   ========================================================================== */

.gsp-pull-refresh {
    position: relative;
    overflow: hidden;
}

.gsp-pull-refresh__indicator {
    position: absolute;
    top: -60px;
    left: 50%;
    transform: translateX(-50%);
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: white;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.3s;
}

.gsp-pull-refresh__indicator svg {
    width: 24px;
    height: 24px;
    color: #166534;
    transition: transform 0.3s;
}

.gsp-pull-refresh.pulling .gsp-pull-refresh__indicator {
    transform: translateX(-50%) translateY(80px);
}

.gsp-pull-refresh.refreshing .gsp-pull-refresh__indicator svg {
    animation: spin 1s linear infinite;
}

@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

/* ==========================================================================
   Responsive Grid
   ========================================================================== */

.gsp-grid {
    display: grid;
    gap: 16px;
}

.gsp-grid--2 {
    grid-template-columns: repeat(2, 1fr);
}

.gsp-grid--3 {
    grid-template-columns: repeat(3, 1fr);
}

.gsp-grid--4 {
    grid-template-columns: repeat(4, 1fr);
}

@media (max-width: 768px) {
    .gsp-grid--3,
    .gsp-grid--4 {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 480px) {
    .gsp-grid--2,
    .gsp-grid--3,
    .gsp-grid--4 {
        grid-template-columns: 1fr;
    }
}

/* ==========================================================================
   Responsive Typography
   ========================================================================== */

@media (max-width: 768px) {
    h1, .gsp-h1 {
        font-size: 24px;
    }
    
    h2, .gsp-h2 {
        font-size: 20px;
    }
    
    h3, .gsp-h3 {
        font-size: 18px;
    }
    
    p, .gsp-text {
        font-size: 15px;
    }
    
    .gsp-text-sm {
        font-size: 13px;
    }
}

/* ==========================================================================
   Responsive Tables
   ========================================================================== */

@media (max-width: 768px) {
    .gsp-table-responsive {
        display: block;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    
    /* Card-style table for mobile */
    .gsp-table-cards {
        display: block;
    }
    
    .gsp-table-cards thead {
        display: none;
    }
    
    .gsp-table-cards tbody {
        display: block;
    }
    
    .gsp-table-cards tr {
        display: block;
        background: white;
        border-radius: 12px;
        padding: 16px;
        margin-bottom: 12px;
        box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    }
    
    .gsp-table-cards td {
        display: flex;
        justify-content: space-between;
        padding: 8px 0;
        border-bottom: 1px solid #f3f4f6;
    }
    
    .gsp-table-cards td:last-child {
        border-bottom: none;
    }
    
    .gsp-table-cards td::before {
        content: attr(data-label);
        font-weight: 600;
        color: #6b7280;
    }
}

/* ==========================================================================
   Image Optimization
   ========================================================================== */

.gsp-img-lazy {
    opacity: 0;
    transition: opacity 0.3s;
}

.gsp-img-lazy.loaded {
    opacity: 1;
}

.gsp-img-placeholder {
    background: linear-gradient(90deg, #f3f4f6 25%, #e5e7eb 50%, #f3f4f6 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
}

@keyframes shimmer {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* Responsive images */
.gsp-img-responsive {
    max-width: 100%;
    height: auto;
}

/* Avatar sizes */
.gsp-avatar {
    border-radius: 50%;
    object-fit: cover;
}

.gsp-avatar--sm { width: 32px; height: 32px; }
.gsp-avatar--md { width: 48px; height: 48px; }
.gsp-avatar--lg { width: 64px; height: 64px; }
.gsp-avatar--xl { width: 96px; height: 96px; }

/* ==========================================================================
   Safe Areas (Notch Support)
   ========================================================================== */

@supports (padding: env(safe-area-inset-top)) {
    .gsp-app-header {
        padding-top: env(safe-area-inset-top);
    }
    
    .gsp-nav {
        padding-bottom: env(safe-area-inset-bottom);
    }
    
    .gsp-install-banner {
        padding-bottom: calc(16px + env(safe-area-inset-bottom));
    }
}

/* ==========================================================================
   Dark Mode Support (System Preference)
   ========================================================================== */

@media (prefers-color-scheme: dark) {
    :root {
        --gsp-bg: #111827;
        --gsp-bg-card: #1f2937;
        --gsp-text: #f9fafb;
        --gsp-text-muted: #9ca3af;
        --gsp-border: #374151;
    }
    
    body.gsp-dark-mode-auto {
        background: var(--gsp-bg);
        color: var(--gsp-text);
    }
    
    body.gsp-dark-mode-auto .gsp-card {
        background: var(--gsp-bg-card);
        border-color: var(--gsp-border);
    }
    
    body.gsp-dark-mode-auto .gsp-nav {
        background: var(--gsp-bg-card);
        border-color: var(--gsp-border);
    }
    
    body.gsp-dark-mode-auto .gsp-input,
    body.gsp-dark-mode-auto input,
    body.gsp-dark-mode-auto select,
    body.gsp-dark-mode-auto textarea {
        background: var(--gsp-bg);
        border-color: var(--gsp-border);
        color: var(--gsp-text);
    }
}

/* ==========================================================================
   Reduced Motion Support
   ========================================================================== */

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* ==========================================================================
   Print Styles
   ========================================================================== */

@media print {
    .gsp-nav,
    .gsp-install-banner,
    .gsp-update-banner,
    .gsp-toast,
    .gsp-offline-indicator {
        display: none !important;
    }
    
    .gsp-card {
        box-shadow: none;
        border: 1px solid #e5e7eb;
    }
}
