/**
 * Gripar Profile Management - Main CSS - FIXED VERSION
 * Version: 2.2.0 - Dropdown & Modal Fixes
 * Fixes: 1) Dropdown visibility in modals, 2) Modal overflow issues
 */

/* ========================================
   ROOT VARIABLES
   ======================================== */
:root {
    --gpm-primary: #667eea;
    --gpm-primary-dark: #764ba2;
    --gpm-success: #28a745;
    --gpm-danger: #dc3545;
    --gpm-warning: #ffc107;
    --gpm-info: #17a2b8;
    --gpm-light: #f8f9fa;
    --gpm-dark: #2c3e50;
    --gpm-border: #e9ecef;
    --gpm-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    --gpm-radius: 8px;
    --gpm-radius-lg: 12px;
}

/* ========================================
   CONTAINER & LAYOUT
   ======================================== */
.gpm-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: var(--gpm-light);
}

/* ========================================
   HEADER - WITH PHOTO
   ======================================== */
.gpm-header {
    background: linear-gradient(135deg, var(--gpm-primary) 0%, var(--gpm-primary-dark) 100%);
    color: white;
    padding: 30px;
    border-radius: var(--gpm-radius-lg);
    margin-bottom: 30px;
    box-shadow: var(--gpm-shadow);
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 20px;
}

.gpm-header-with-photo {
    display: flex;
    align-items: center;
    gap: 25px;
    padding: 25px 30px;
}

.gpm-header-photo-section {
    flex-shrink: 0;
}

.gpm-header-content {
    flex: 1;
    min-width: 300px;
}

.gpm-header-subtitle {
    color: rgba(255, 255, 255, 0.9);
    margin: 10px 0 0 0;
    font-size: 16px;
}

.gpm-back-btn {
    background: rgba(255, 255, 255, 0.2);
    color: white;
    border: 1px solid rgba(255, 255, 255, 0.3);
    padding: 8px 16px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    transition: all 0.3s ease;
    margin-bottom: 15px;
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.gpm-back-btn:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: translateX(-3px);
}

.gpm-title {
    font-size: 32px;
    font-weight: 700;
    margin: 0;
    display: flex;
    align-items: center;
    gap: 12px;
}

.gpm-title .gpm-icon {
    font-size: 40px;
}

.gpm-header-actions {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    align-items: center;
}

/* ========================================
   PHOTO IN HEADER
   ======================================== */
.gpm-photo-wrapper {
    width: 120px;
    height: 120px;
    border-radius: 50%;
    overflow: hidden;
    border: 4px solid rgba(255, 255, 255, 0.3);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
    position: relative;
    background: rgba(255, 255, 255, 0.1);
    transition: all 0.3s ease;
}

.gpm-photo-wrapper:hover {
    border-color: rgba(255, 255, 255, 0.5);
    transform: scale(1.05);
}

.gpm-profile-photo {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.gpm-photo-placeholder {
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.2), rgba(255, 255, 255, 0.1));
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    color: white;
}

.gpm-photo-icon {
    font-size: 50px;
    opacity: 0.8;
}

.gpm-photo-edit-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.3s ease;
    border-radius: 50%;
    z-index: 2;
}

.gpm-photo-wrapper:hover .gpm-photo-edit-overlay {
    opacity: 1;
}

.gpm-change-photo-btn {
    background: white;
    color: var(--gpm-primary);
    border: none;
    border-radius: 50%;
    width: 50px;
    height: 50px;
    font-size: 24px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.gpm-change-photo-btn:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.3);
}

/* ========================================
   LOADING & MESSAGES
   ======================================== */
.gpm-loading {
    text-align: center;
    padding: 60px 20px;
    background: white;
    border-radius: var(--gpm-radius-lg);
    box-shadow: var(--gpm-shadow);
}

.gpm-spinner {
    width: 50px;
    height: 50px;
    margin: 0 auto 20px;
    border: 4px solid #f3f3f3;
    border-top: 4px solid var(--gpm-primary);
    border-radius: 50%;
    animation: gpm-spin 1s linear infinite;
}

.gpm-spinner-sm {
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid #f3f3f3;
    border-top: 2px solid var(--gpm-primary);
    border-radius: 50%;
    animation: gpm-spin 0.8s linear infinite;
    margin-right: 8px;
}

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

.gpm-messages {
    margin-bottom: 20px;
}

.gpm-notice {
    padding: 15px 20px;
    border-radius: var(--gpm-radius);
    margin-bottom: 15px;
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 15px;
    animation: gpm-slideIn 0.3s ease;
}

.gpm-notice-icon {
    font-size: 20px;
    flex-shrink: 0;
}

.gpm-notice-success {
    background: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}

.gpm-notice-error {
    background: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}

.gpm-notice-warning {
    background: #fff3cd;
    color: #856404;
    border: 1px solid #ffeeba;
}

.gpm-notice-info {
    background: #d1ecf1;
    color: #0c5460;
    border: 1px solid #bee5eb;
}

@keyframes gpm-slideIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ========================================
   SECTIONS
   ======================================== */
.gpm-content {
    background: white;
    border-radius: var(--gpm-radius-lg);
    box-shadow: var(--gpm-shadow);
    overflow: hidden;
}

.gpm-section {
    border-bottom: 1px solid var(--gpm-border);
    padding: 30px;
}

.gpm-section:last-child {
    border-bottom: none;
}

.gpm-section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 25px;
    padding-bottom: 15px;
    border-bottom: 2px solid var(--gpm-border);
}

.gpm-section-title {
    font-size: 24px;
    font-weight: 600;
    margin: 0;
    color: var(--gpm-dark);
    display: flex;
    align-items: center;
    gap: 12px;
}

.gpm-section-icon {
    font-size: 28px;
}

.gpm-section-edit-btn {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    border-radius: 8px;
    padding: 10px 20px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: all 0.3s ease;
    box-shadow: 0 2px 8px rgba(102, 126, 234, 0.3);
}

.gpm-section-edit-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

.gpm-section-edit-btn .gpm-icon {
    font-size: 16px;
}

/* ========================================
   INFO GRIDS (View Mode)
   ======================================== */
.gpm-info-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 20px;
}

.gpm-info-item {
    display: flex;
    flex-direction: column;
}

.gpm-info-label {
    font-size: 13px;
    font-weight: 600;
    color: #6c757d;
    margin-bottom: 6px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.gpm-info-value {
    font-size: 16px;
    color: var(--gpm-dark);
    font-weight: 500;
}

.gpm-info-value.empty {
    color: #adb5bd;
    font-style: italic;
}

.gpm-info-value a {
    color: var(--gpm-primary);
    text-decoration: none;
}

.gpm-info-value a:hover {
    text-decoration: underline;
}

/* ========================================
   FORM ELEMENTS (Edit Mode)
   ======================================== */
.gpm-form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 20px;
}

.gpm-form-group {
    display: flex;
    flex-direction: column;
}

.gpm-form-group-full {
    grid-column: 1 / -1;
}

.gpm-label {
    font-size: 14px;
    font-weight: 600;
    color: #495057;
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.gpm-required {
    color: var(--gpm-danger);
    font-size: 16px;
}

.gpm-input,
.gpm-select,
.gpm-textarea {
    width: 100%;
    padding: 12px 15px;
    border: 2px solid var(--gpm-border);
    border-radius: var(--gpm-radius);
    font-size: 15px;
    font-family: inherit;
    transition: all 0.3s ease;
    background: white;
}

.gpm-input:focus,
.gpm-select:focus,
.gpm-textarea:focus {
    outline: none;
    border-color: var(--gpm-primary);
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.gpm-input:disabled,
.gpm-select:disabled,
.gpm-textarea:disabled {
    background: var(--gpm-light);
    cursor: not-allowed;
    color: #6c757d;
}

.gpm-textarea {
    resize: vertical;
    min-height: 100px;
}

.gpm-help-text {
    font-size: 13px;
    color: #6c757d;
    margin-top: 6px;
    font-style: italic;
}

/* ========================================
   BUTTONS
   ======================================== */
.gpm-btn {
    padding: 12px 24px;
    border: none;
    border-radius: var(--gpm-radius);
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    text-decoration: none;
    white-space: nowrap;
}

.gpm-btn .gpm-icon {
    font-size: 18px;
}

.gpm-btn-primary {
    background: linear-gradient(135deg, var(--gpm-primary) 0%, var(--gpm-primary-dark) 100%);
    color: white;
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}

.gpm-btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(102, 126, 234, 0.4);
}

.gpm-btn-secondary {
    background: white;
    color: #495057;
    border: 2px solid var(--gpm-border);
}

.gpm-btn-secondary:hover {
    background: var(--gpm-light);
    border-color: #dee2e6;
}

.gpm-btn-success {
    background: var(--gpm-success);
    color: white;
}

.gpm-btn-danger {
    background: var(--gpm-danger);
    color: white;
}

.gpm-btn-sm {
    padding: 8px 16px;
    font-size: 14px;
}

.gpm-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none !important;
}

/* ========================================
   QUICK LINKS
   ======================================== */
.gpm-link-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 20px;
}

.gpm-quick-link-card {
    background: white;
    border: 2px solid var(--gpm-border);
    border-radius: var(--gpm-radius);
    padding: 20px;
    display: flex;
    align-items: center;
    gap: 15px;
    text-decoration: none;
    transition: all 0.3s ease;
    cursor: pointer;
}

.gpm-quick-link-card:hover {
    border-color: var(--gpm-primary);
    transform: translateY(-3px);
    box-shadow: 0 4px 16px rgba(102, 126, 234, 0.2);
}

.gpm-quick-link-card:hover .gpm-link-icon {
    transform: scale(1.1);
}

.gpm-link-icon {
    font-size: 36px;
    flex-shrink: 0;
    transition: transform 0.3s ease;
}

.gpm-link-content {
    flex: 1;
}

.gpm-link-title {
    font-size: 17px;
    font-weight: 600;
    color: var(--gpm-dark);
    margin-bottom: 5px;
}

.gpm-link-desc {
    font-size: 14px;
    color: #6c757d;
    line-height: 1.4;
}

.gpm-link-arrow {
    font-size: 24px;
    color: var(--gpm-primary);
    transition: transform 0.3s ease;
}

.gpm-quick-link-card:hover .gpm-link-arrow {
    transform: translateX(5px);
}

/* ========================================
   MODALS - FIXED VERSION
   ======================================== */
.gpm-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 99999; /* INCREASED z-index */
    animation: gpm-fadeIn 0.3s ease;
}

.gpm-modal.active {
    display: block;
}

.gpm-modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    z-index: 99998; /* Ensure overlay is below content */
}

.gpm-modal-content {
    position: relative;
    background: white;
    max-width: 700px;
    width: 90%;
    max-height: 90vh;
    margin: 30px auto;
    border-radius: 12px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    display: flex;
    flex-direction: column;
    animation: gpm-slideUp 0.3s ease;
    z-index: 99999; /* Ensure modal content is on top */
}

.gpm-modal-header {
    padding: 25px 30px;
    border-bottom: 2px solid #e9ecef;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 12px 12px 0 0;
    flex-shrink: 0; /* Prevent header from shrinking */
}

.gpm-modal-title {
    margin: 0;
    font-size: 22px;
    font-weight: 700;
    color: white;
}

.gpm-modal-close {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: white;
    font-size: 32px;
    line-height: 1;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
}

.gpm-modal-close:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: rotate(90deg);
}

/* CRITICAL FIX: Modal Body - Allow Dropdowns to Overflow */
.gpm-modal-body {
    padding: 30px;
    overflow-y: auto;
    overflow-x: hidden; /* Changed from visible to hidden to prevent horizontal scroll */
    flex: 1;
    position: relative; /* IMPORTANT: Allow positioned children */
}

/* CRITICAL FIX: Form Select Elements in Modals */
.gpm-modal-body .gpm-select {
    position: relative;
    z-index: 100000; /* Ensure dropdown is above everything */
}

/* CRITICAL FIX: Ensure select dropdowns appear above modal content */
.gpm-modal-body select {
    position: relative;
    z-index: 100001;
}

/* Fix for iOS Safari */
.gpm-modal-body select:focus {
    position: relative;
    z-index: 100002;
}

.gpm-modal-footer {
    padding: 20px 30px;
    border-top: 2px solid #e9ecef;
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    background: #f8f9fa;
    border-radius: 0 0 12px 12px;
    flex-shrink: 0; /* Prevent footer from shrinking */
}

@keyframes gpm-fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes gpm-slideUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ========================================
   PHOTO UPLOAD MODAL STYLES
   ======================================== */
.gpm-photo-upload-area {
    border: 2px dashed #667eea;
    border-radius: 12px;
    padding: 40px;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s ease;
    background: #f8f9ff;
}

.gpm-photo-upload-area:hover {
    border-color: #764ba2;
    background: #f0f3ff;
}

.gpm-upload-placeholder {
    pointer-events: none;
}

.gpm-upload-icon {
    font-size: 48px;
    margin-bottom: 15px;
}

.gpm-upload-text {
    font-size: 16px;
    font-weight: 600;
    color: #2c3e50;
    margin-bottom: 8px;
}

.gpm-upload-hint {
    font-size: 13px;
    color: #6c757d;
}

.gpm-photo-preview {
    position: relative;
}

.gpm-photo-preview img {
    max-width: 100%;
    max-height: 300px;
    border-radius: 8px;
}

.gpm-remove-preview {
    position: absolute;
    top: 10px;
    right: 10px;
    background: rgba(220, 53, 69, 0.9);
    color: white;
    border: none;
    border-radius: 50%;
    width: 32px;
    height: 32px;
    font-size: 24px;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
}

.gpm-remove-preview:hover {
    background: #dc3545;
    transform: scale(1.1);
}

.gpm-current-photo {
    margin-bottom: 25px;
}

.gpm-photo-preview-wrapper {
    text-align: center;
    margin-top: 10px;
}

.gpm-photo-preview-wrapper img {
    max-width: 200px;
    max-height: 200px;
    border-radius: 8px;
    border: 2px solid #e9ecef;
}

.gpm-upload-progress {
    margin-top: 20px;
}

.gpm-progress-bar {
    width: 100%;
    height: 30px;
    background: #e9ecef;
    border-radius: 15px;
    overflow: hidden;
    margin-bottom: 10px;
}

.gpm-progress-fill {
    height: 100%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    transition: width 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 12px;
    font-weight: 600;
}

.gpm-progress-text {
    text-align: center;
    font-size: 14px;
    font-weight: 600;
    color: #667eea;
}

.gpm-upload-error {
    background: #fee;
    border: 1px solid #fcc;
    color: #c33;
    padding: 12px;
    border-radius: 6px;
    margin-top: 15px;
    font-size: 14px;
}

/* ========================================
   RESPONSIVE
   ======================================== */
@media (max-width: 768px) {
    .gpm-container {
        padding: 15px;
    }

    .gpm-header,
    .gpm-header-with-photo {
        padding: 20px;
        flex-direction: column;
        align-items: center;
        text-align: center;
    }

    .gpm-header-photo-section {
        margin-bottom: 15px;
    }

    .gpm-photo-wrapper {
        width: 100px;
        height: 100px;
    }

    .gpm-title {
        font-size: 24px;
        justify-content: center;
    }

    .gpm-title .gpm-icon {
        font-size: 28px;
    }

    .gpm-header-actions {
        width: 100%;
        justify-content: center;
    }

    .gpm-section {
        padding: 20px;
    }

    .gpm-section-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 15px;
    }

    .gpm-section-title {
        font-size: 20px;
    }

    .gpm-section-edit-btn {
        width: 100%;
        justify-content: center;
    }

    .gpm-info-grid,
    .gpm-form-grid,
    .gpm-link-grid {
        grid-template-columns: 1fr;
    }

    .gpm-modal-content {
        width: 95%;
        margin: 10px auto;
        max-height: 95vh;
    }
    
    .gpm-modal-header,
    .gpm-modal-body,
    .gpm-modal-footer {
        padding: 20px;
    }
}

/* ========================================
   UTILITIES
   ======================================== */
.gpm-text-center {
    text-align: center;
}

.gpm-mt-20 {
    margin-top: 20px;
}

.gpm-mb-20 {
    margin-bottom: 20px;
}

.gpm-hidden {
    display: none !important;
}

/* ========================================
   PRINT STYLES
   ======================================== */
@media print {
    .gpm-header-actions,
    .gpm-quick-links,
    .gpm-btn,
    .gpm-section-edit-btn,
    .gpm-photo-edit-overlay {
        display: none !important;
    }

    .gpm-container {
        background: white;
    }

    .gpm-section {
        page-break-inside: avoid;
    }
}