/**
 * MG Search + Profile Styles
 *
 * MastersGuild brand: primary #3d5a80, accent #ff4500
 * Mobile-first responsive design
 */

/* =========================================================================
   Design Tokens
   ========================================================================= */
:root {
    --mg-primary: #3d5a80;
    --mg-accent: #ff4500;
    --mg-text: #333333;
    --mg-text-light: #666666;
    --mg-text-muted: #999999;
    --mg-border: #e0e0e0;
    --mg-bg: #ffffff;
    --mg-bg-hover: #f5f7fa;
    --mg-radius: 8px;
    --mg-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    --mg-shadow-lg: 0 4px 16px rgba(0, 0, 0, 0.15);
    --mg-font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

/* =========================================================================
   Search Component
   ========================================================================= */
.mg-search-wrap {
    position: relative;
    max-width: 600px;
    margin: 0 auto;
    font-family: var(--mg-font);
}

.mg-search-box {
    display: flex;
    align-items: center;
    border: 2px solid var(--mg-border);
    border-radius: var(--mg-radius);
    padding: 12px 16px;
    background: var(--mg-bg);
    transition: border-color 0.2s;
}

.mg-search-box:focus-within {
    border-color: var(--mg-primary);
    box-shadow: 0 0 0 3px rgba(61, 90, 128, 0.15);
}

.mg-search-icon {
    flex-shrink: 0;
    color: var(--mg-text-muted);
    margin-right: 10px;
}

.mg-search-input {
    flex: 1;
    border: none;
    outline: none;
    font-size: 16px; /* 16px prevents iOS zoom */
    color: var(--mg-text);
    background: transparent;
    font-family: var(--mg-font);
}

.mg-search-input::placeholder {
    color: var(--mg-text-muted);
}

/* Spinner */
.mg-search-spinner {
    width: 20px;
    height: 20px;
    border: 2px solid var(--mg-border);
    border-top-color: var(--mg-primary);
    border-radius: 50%;
    animation: mg-spin 0.6s linear infinite;
    flex-shrink: 0;
}

@keyframes mg-spin {
    to { transform: rotate(360deg); }
}

/* Results Dropdown */
.mg-search-results {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    right: 0;
    background: var(--mg-bg);
    border: 1px solid var(--mg-border);
    border-radius: var(--mg-radius);
    box-shadow: var(--mg-shadow-lg);
    max-height: 400px;
    overflow-y: auto;
    z-index: 1000;
    list-style: none;
    margin: 0;
    padding: 0;
}

/* Result Item */
.mg-search-result {
    display: flex;
    align-items: center;
    padding: 12px 16px;
    gap: 12px;
    cursor: pointer;
    transition: background-color 0.15s;
    border-bottom: 1px solid var(--mg-border);
}

.mg-search-result:last-child {
    border-bottom: none;
}

.mg-search-result:hover,
.mg-search-result[aria-selected="true"] {
    background-color: var(--mg-bg-hover);
}

/* Avatar */
.mg-result-avatar {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
    background-color: var(--mg-border);
}

.mg-result-avatar-placeholder {
    background-color: var(--mg-primary);
    opacity: 0.3;
}

/* Result Info */
.mg-result-info {
    flex: 1;
    min-width: 0;
}

.mg-result-name {
    display: block;
    font-weight: 600;
    color: var(--mg-text);
    font-size: 0.95em;
}

.mg-result-headline {
    display: block;
    color: var(--mg-text-light);
    font-size: 0.85em;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.mg-result-meta {
    display: flex;
    gap: 12px;
    margin-top: 4px;
    font-size: 0.8em;
    color: var(--mg-text-muted);
}

.mg-result-rating {
    color: var(--mg-accent);
    font-weight: 600;
}

/* Empty & Error States */
.mg-search-empty,
.mg-search-error {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    right: 0;
    background: var(--mg-bg);
    border: 1px solid var(--mg-border);
    border-radius: var(--mg-radius);
    box-shadow: var(--mg-shadow);
    padding: 20px;
    text-align: center;
    color: var(--mg-text-light);
    font-size: 0.9em;
    z-index: 1000;
}

.mg-search-error {
    color: #d32f2f;
}

/* Skeleton Loader */
.mg-search-skeleton {
    display: flex;
    align-items: center;
    padding: 12px 16px;
    gap: 12px;
}

.mg-search-skeleton .skeleton-avatar {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: mg-shimmer 1.5s infinite;
}

.mg-search-skeleton .skeleton-text {
    height: 14px;
    border-radius: 4px;
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: mg-shimmer 1.5s infinite;
}

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

/* =========================================================================
   Profile Page
   ========================================================================= */
.mg-profile-container {
    font-family: var(--mg-font);
    color: var(--mg-text);
    width: 100%;
}

/* Hero */
.mg-profile-hero {
    position: relative;
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    background-color: var(--mg-primary);
    min-height: 400px;
    display: flex;
    align-items: flex-end;
}

.mg-profile-hero-overlay {
    background: linear-gradient(transparent 0%, rgba(0, 0, 0, 0.7) 100%);
    width: 100%;
    padding: 40px;
    box-sizing: border-box;
}

.mg-profile-hero-content {
    display: flex;
    align-items: flex-start;
    gap: 24px;
    max-width: 1200px;
    margin: 0 auto;
}

.mg-profile-hero-left {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
    flex-shrink: 0;
}

.mg-profile-avatar {
    width: 120px;
    height: 120px;
    border-radius: 50%;
    border: 4px solid white;
    object-fit: cover;
    background-color: rgba(255, 255, 255, 0.2);
}

.mg-profile-avatar-placeholder {
    background-color: rgba(255, 255, 255, 0.3);
}

.mg-profile-cta-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.mg-profile-hero-info {
    flex: 1;
    color: #ffffff;
    min-width: 0;
}

.mg-profile-name {
    font-size: 2em;
    margin: 0 0 8px;
    color: #ffffff;
}

.mg-profile-headline {
    font-style: italic;
    margin: 0 0 16px;
    opacity: 0.9;
    font-size: 1.1em;
}

.mg-profile-stats {
    display: flex;
    gap: 20px;
    color: rgba(255, 255, 255, 0.9);
    font-size: 0.9em;
    margin-bottom: 16px;
}

.mg-profile-about {
    margin: 0;
    line-height: 1.5;
    opacity: 0.9;
}

/* CTA Buttons */
.mg-cta-primary {
    display: inline-block;
    background: var(--mg-accent);
    color: #ffffff;
    padding: 14px 28px;
    border-radius: var(--mg-radius);
    font-weight: 600;
    font-size: 0.95em;
    text-decoration: none;
    text-align: center;
    transition: background-color 0.2s;
    border: none;
    cursor: pointer;
}

.mg-cta-primary:hover {
    background: #e63e00;
    color: #ffffff;
    text-decoration: none;
}

.mg-cta-secondary {
    display: inline-block;
    border: 2px solid #ffffff;
    color: #ffffff;
    padding: 12px 24px;
    border-radius: var(--mg-radius);
    font-weight: 600;
    font-size: 0.9em;
    text-decoration: none;
    text-align: center;
    transition: background-color 0.2s;
}

.mg-cta-secondary:hover {
    background: rgba(255, 255, 255, 0.15);
    color: #ffffff;
    text-decoration: none;
}

/* Content Grid */
.mg-profile-content {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
    max-width: 1200px;
    margin: 24px auto;
    padding: 0 20px;
}

.mg-profile-left,
.mg-profile-right {
    display: flex;
    flex-direction: column;
    gap: 24px;
}

/* Cards */
.mg-profile-card {
    background: var(--mg-bg);
    border: 1px solid var(--mg-border);
    border-radius: var(--mg-radius);
    padding: 20px;
}

.mg-profile-card h2 {
    margin: 0 0 16px;
    font-size: 1.2em;
    color: var(--mg-text);
}

/* Skills */
.mg-skill-list {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.mg-skill-chip {
    display: inline-block;
    background: var(--mg-primary);
    color: #ffffff;
    padding: 6px 14px;
    border-radius: 20px;
    font-size: 0.85em;
    font-weight: 600;
}

/* Experience & Education Lists */
.mg-experience-list,
.mg-education-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.mg-experience-list li,
.mg-education-list li {
    padding: 12px 0;
    border-bottom: 1px solid var(--mg-border);
    line-height: 1.5;
}

.mg-experience-list li:last-child,
.mg-education-list li:last-child {
    border-bottom: none;
    padding-bottom: 0;
}

.mg-date {
    display: block;
    font-size: 0.85em;
    color: var(--mg-text-muted);
    margin-top: 4px;
}

/* Photos Grid */
.mg-photos-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
}

.mg-photo-item img {
    width: 100%;
    aspect-ratio: 1;
    object-fit: cover;
    border-radius: 4px;
}

/* Posts */
.mg-post-item {
    padding: 16px 0;
    border-bottom: 1px solid var(--mg-border);
}

.mg-post-item:last-child {
    border-bottom: none;
    padding-bottom: 0;
}

.mg-post-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 10px;
}

.mg-post-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    object-fit: cover;
}

.mg-post-info {
    display: flex;
    flex-direction: column;
}

.mg-post-author {
    font-weight: 600;
    font-size: 0.9em;
}

.mg-post-date {
    font-size: 0.8em;
    color: var(--mg-text-muted);
}

.mg-post-content p {
    margin: 0 0 10px;
    line-height: 1.5;
}

.mg-post-image {
    max-width: 100%;
    border-radius: var(--mg-radius);
    margin-top: 8px;
}

.mg-post-stats {
    display: flex;
    gap: 16px;
    font-size: 0.85em;
    color: var(--mg-text-muted);
    margin-top: 10px;
}

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

/* Tablet */
@media (max-width: 768px) {
    .mg-profile-content {
        grid-template-columns: 1fr;
    }

    .mg-profile-hero {
        min-height: 300px;
    }

    .mg-profile-hero-overlay {
        padding: 20px;
    }

    .mg-profile-hero-content {
        flex-direction: column;
        align-items: center;
        text-align: center;
    }

    .mg-profile-stats {
        flex-direction: column;
        gap: 8px;
        align-items: center;
    }

    .mg-profile-cta-group {
        flex-direction: row;
    }

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

/* Mobile */
@media (max-width: 480px) {
    .mg-search-results {
        max-height: 300px;
    }

    .mg-profile-avatar {
        width: 80px;
        height: 80px;
    }

    .mg-profile-name {
        font-size: 1.4em;
    }

    .mg-profile-hero-overlay {
        padding: 16px;
    }

    .mg-cta-primary {
        padding: 12px 20px;
        font-size: 0.9em;
    }

    .mg-cta-secondary {
        padding: 10px 18px;
        font-size: 0.85em;
    }

    .mg-profile-cta-group {
        flex-direction: column;
        width: 100%;
    }

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