/* ---------- GLOBAL STYLES ---------- */
html {
    box-sizing: border-box;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    scroll-behavior: smooth;
}
*,
*::before,
*::after {
    box-sizing: inherit;
    margin: 0;
    padding: 0;
}

:root {
    --primary-bg: #0f172a;
    --secondary-bg: #1e293b;
    --accent-bg: #3b82f6;
    --primary-color: #f8fafc;
    --secondary-color: #cbd5e1;
    --accent-color: #60a5fa;
    --border-color: #334155;
    --success-color: #10b981;
    --warning-color: #f59e0b;
    --danger-color: #ef4444;
    
    /* Font sizes responsive */
    --username-size: clamp(1.75rem, 4vw, 2.5rem);
    --title-size: clamp(1.25rem, 3vw, 1.75rem);
    --section-title: clamp(1.125rem, 2.5vw, 1.5rem);
    --card-title: clamp(1rem, 2vw, 1.25rem);
    --body-text: clamp(0.9375rem, 1.5vw, 1rem);
    --small-text: clamp(0.875rem, 1.2vw, 0.9375rem);
}

/* ---------- CUSTOM SCROLLBAR UNTUK HALAMAN ---------- */
/* Untuk browser WebKit (Chrome, Safari, Edge) */
html::-webkit-scrollbar {
    width: 14px;
}

html::-webkit-scrollbar-track {
    background: linear-gradient(180deg, 
        #0f172a 0%, 
        #1e293b 50%, 
        #0f172a 100%);
    border-left: 1px solid rgba(59, 130, 246, 0.1);
}

html::-webkit-scrollbar-thumb {
    background: linear-gradient(180deg, 
        #3b82f6 0%, 
        #2563eb 50%, 
        #1d4ed8 100%);
    border-radius: 10px;
    border: 3px solid #0f172a;
    min-height: 60px;
}

html::-webkit-scrollbar-thumb:hover {
    background: linear-gradient(180deg, 
        #60a5fa 0%, 
        #3b82f6 50%, 
        #2563eb 100%);
    box-shadow: 0 0 10px rgba(59, 130, 246, 0.5);
}

html::-webkit-scrollbar-thumb:active {
    background: linear-gradient(180deg, 
        #1d4ed8 0%, 
        #1e40af 50%, 
        #1e3a8a 100%);
}

/* Untuk Firefox */
html {
    scrollbar-width: thin;
    scrollbar-color: #3b82f6 #0f172a;
}

/* ---------- BODY & BACKGROUND ---------- */
body {
    background: linear-gradient(135deg, #0f172a 0%, #1e293b 100%);
    min-height: 100vh;
    margin: 0;
    -webkit-tap-highlight-color: transparent;
    padding: clamp(1rem, 3vw, 2rem);
    position: relative;
    overflow-x: hidden;
}

/* Parallax Background Effect */
body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: 
        radial-gradient(circle at 20% 80%, rgba(59, 130, 246, 0.15) 0%, transparent 50%),
        radial-gradient(circle at 80% 20%, rgba(96, 165, 250, 0.1) 0%, transparent 50%),
        radial-gradient(circle at 40% 40%, rgba(30, 64, 175, 0.08) 0%, transparent 50%);
    z-index: -1;
    pointer-events: none;
}

/* ---------- SCROLL INDICATOR ---------- */
.scroll-indicator {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 4px;
    background: linear-gradient(90deg, 
        #3b82f6 0%, 
        #2563eb 50%, 
        #1d4ed8 100%);
    transform-origin: left;
    transform: scaleX(0);
    z-index: 1000;
    transition: transform 0.1s ease;
}

/* ---------- BACK TO TOP BUTTON ---------- */
.back-to-top {
    position: fixed;
    bottom: 30px;
    right: 30px;
    width: 50px;
    height: 50px;
    background: linear-gradient(135deg, #3b82f6, #2563eb);
    border: none;
    border-radius: 50%;
    color: white;
    font-size: 1.5rem;
    cursor: pointer;
    opacity: 0;
    visibility: hidden;
    transform: translateY(20px);
    transition: all 0.3s ease;
    z-index: 999;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 5px 20px rgba(59, 130, 246, 0.4);
}

.back-to-top.show {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.back-to-top:hover {
    transform: translateY(-5px) scale(1.1);
    background: linear-gradient(135deg, #60a5fa, #3b82f6);
    box-shadow: 0 8px 25px rgba(59, 130, 246, 0.6);
}

.back-to-top:active {
    transform: translateY(-2px) scale(1.05);
}

/* ---------- CONTAINER ---------- */
.container {
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    gap: 2rem;
}

/* ---------- PROFILE HEADER ---------- */
.profile-header {
    background: linear-gradient(135deg, #1e40af 0%, #3b82f6 100%);
    padding: clamp(1.5rem, 3vw, 2.5rem);
    min-height: clamp(180px, 25vh, 220px);
    display: flex;
    align-items: center;
    border-radius: clamp(20px, 3vw, 30px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
    transition: all 0.3s ease;
    position: relative;
}

.main-profile {
    display: flex;
    align-items: center;
    gap: clamp(1rem, 3vw, 2rem);
    width: 100%;
    flex-wrap: wrap;
}

/* REVISI DI SINI - UNTUK GAMBAR KOTAK MENJADI LINGKARAN */
.profile-image {
    width: clamp(100px, 15vw, 150px);
    height: clamp(100px, 15vw, 150px);
    border-radius: 50%;
    border: clamp(4px, 0.5vw, 8px) solid rgba(255, 255, 255, 0.2);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
    flex-shrink: 0;
    position: relative;
    overflow: hidden;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    background-color: rgba(255, 255, 255, 0.1); /* Background fallback */
}

/* Container untuk gambar agar bisa diatur posisinya */
.profile-image .image-container {
    width: 100%;
    height: 100%;
    position: relative;
    border-radius: 50%;
    overflow: hidden;
}

/* Gambar di dalam container */
.profile-image img {
    width: 100%;
    height: 100%;
    object-fit: cover; /* Ini yang penting untuk gambar kotak jadi lingkaran */
    object-position: center; /* Fokus ke tengah gambar */
    display: block;
    transition: transform 0.5s ease;
}

/* Fallback jika tidak ada tag img (background image) */
.profile-image {
    background-image: url('images/profile-image.jpg');
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
}

/* Efek hover untuk foto profil */
.profile-image:hover {
    transform: scale(1.05);
    box-shadow: 0 15px 40px rgba(0, 0, 0, 0.5);
}

.profile-image:hover img {
    transform: scale(1.1);
}

/* Fallback jika gambar tidak ditemukan */
.profile-image::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, 
        #667eea 0%, 
        #764ba2 25%, 
        #f093fb 50%, 
        #f5576c 75%, 
        #ff6b6b 100%);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: clamp(2rem, 4vw, 2.5rem);
    font-weight: 800;
    content: 'FM';
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
    letter-spacing: 1px;
    z-index: -1; /* Di belakang gambar */
    opacity: 0;
    transition: opacity 0.3s ease;
}

/* Class untuk fallback */
.profile-image.broken-image::before {
    opacity: 1;
    z-index: 1; /* Di depan jika gambar rusak */
}

.profile-names {
    color: var(--primary-color);
    flex: 1;
    min-width: 200px;
}

.username {
    font-size: var(--username-size);
    font-weight: 800;
    margin-bottom: 0.5rem;
    color: white;
    line-height: 1.2;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

.page-title {
    color: rgba(255, 255, 255, 0.95);
    font-size: var(--body-text);
    font-weight: 500;
    letter-spacing: 0.5px;
}

/* ---------- MAIN CONTENT LAYOUT ---------- */
.main-content {
    display: grid;
    grid-template-columns: minmax(200px, 1fr) minmax(300px, 3fr);
    gap: clamp(1.5rem, 3vw, 3rem);
    align-items: start;
}

/* ---------- SIDEBAR ---------- */
.sidebar {
    position: sticky;
    top: 20px;
    height: fit-content;
}

.profile-actions {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.profile-actions button {
    background: none;
    border: 2px solid var(--accent-bg);
    padding: clamp(0.875rem, 1.5vw, 1rem);
    color: var(--primary-color);
    text-align: center;
    border-radius: 12px;
    font: inherit;
    cursor: pointer;
    font-weight: 600;
    font-size: var(--body-text);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    width: 100%;
    position: relative;
    overflow: hidden;
}

@keyframes ripple-animation {
    to {
        transform: scale(4);
        opacity: 0;
    }
}

.profile-actions button:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.2);
}

.profile-actions button:active {
    transform: translateY(0);
}

.profile-actions .follow {
    background: linear-gradient(135deg, var(--accent-bg), #2563eb);
    border: none;
}

.profile-actions .follow:hover {
    background: linear-gradient(135deg, #2563eb, #1d4ed8);
}

.profile-actions .message {
    background: var(--secondary-bg);
    border-color: var(--border-color);
}

.profile-actions .message:hover {
    border-color: var(--accent-color);
    background: rgba(59, 130, 246, 0.1);
}

/* BIO SECTION */
.bio {
    background-color: var(--secondary-bg);
    padding: clamp(1.25rem, 2vw, 1.5rem);
    border-radius: 16px;
    border: 1px solid var(--border-color);
    margin-top: 1rem;
}

.bio-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 1rem;
    color: var(--accent-color);
    font-weight: 600;
    font-size: var(--body-text);
}

.bio-header i {
    font-size: 1.25rem;
}

.bio-text {
    color: var(--secondary-color);
    line-height: 1.7;
    font-size: var(--small-text);
}

/* ---------- CONTENT WRAPPER ---------- */
.content-wrapper {
    display: flex;
    flex-direction: column;
    gap: clamp(2rem, 3vw, 3rem);
    padding-bottom: 3rem;
}

/* ---------- CONTENT SECTIONS ---------- */
.content-section {
    background-color: var(--secondary-bg);
    padding: clamp(1.5rem, 2.5vw, 2rem);
    border-radius: 20px;
    border: 1px solid var(--border-color);
    transition: all 0.3s ease;
}

.content-section:hover {
    border-color: var(--accent-color);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
}

.section-title {
    color: var(--primary-color);
    font-size: var(--section-title);
    margin-bottom: clamp(1.25rem, 2vw, 1.75rem);
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-weight: 700;
}

.section-title i {
    color: var(--accent-color);
    font-size: 1.5em;
}

/* ---------- PROJECTS ---------- */
.projects-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(300px, 100%), 1fr));
    gap: clamp(1rem, 1.5vw, 1.5rem);
}

.project-card {
    background: linear-gradient(145deg, #1e293b, #334155);
    padding: clamp(1.25rem, 2vw, 1.5rem);
    border-radius: 16px;
    border: 1px solid var(--border-color);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    height: 100%;
    display: flex;
    flex-direction: column;
}

.project-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 15px 40px rgba(0, 0, 0, 0.3);
    border-color: var(--accent-color);
}

.project-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 1rem;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.project-header h3 {
    color: var(--primary-color);
    font-size: var(--card-title);
    display: flex;
    justify-content: center; /* posisi icon + teks di tengah */
    align-items: center;      /* biar rapi vertical */
    text-align: center;
    gap: 0.5rem;
    font-weight: 600;
    flex: 1;
    min-width: 200px;
}

.project-header h3 i {
    color: var(--accent-color);
    font-size: 1.5em;
}

.project-badge {
    background: linear-gradient(135deg, var(--accent-bg), #2563eb);
    color: white;
    padding: 0.375rem 1rem;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
    white-space: nowrap;
    margin-left: auto;
    margin-right: auto;
    order: 2;
}

.project-desc {
    color: var(--secondary-color);
    font-size: var(--small-text);
    line-height: 1.7;
    margin-bottom: 1.25rem;
    flex: 1;
}

.project-stack {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: 1.25rem;
}

.project-stack span {
    background: rgba(59, 130, 246, 0.15);
    color: var(--accent-color);
    padding: 0.375rem 0.875rem;
    border-radius: 20px;
    font-size: 0.8125rem;
    font-weight: 500;
    border: 1px solid rgba(59, 130, 246, 0.3);
    transition: all 0.2s ease;
}

.project-stack span:hover {
    background: rgba(59, 130, 246, 0.25);
    transform: translateY(-1px);
}

.project-features {
    display: flex;
    flex-direction: column;
    gap: 0.625rem;
    margin-top: auto;
}

.project-features span {
    color: var(--secondary-color);
    font-size: 0.8125rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.375rem 0;
}

.project-features span::before {
    content: '✓';
    color: var(--success-color);
    font-weight: bold;
    font-size: 1em;
}

/* ---------- TECH STACK ---------- */
.stack-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(250px, 100%), 1fr));
    gap: clamp(1.25rem, 2vw, 1.75rem);
    margin-top: 1rem;
}

.stack-category {
    background: rgba(255, 255, 255, 0.05);
    padding: clamp(1.25rem, 2vw, 1.5rem);
    border-radius: 16px;
    border: 1px solid var(--border-color);
    transition: all 0.3s ease;
}

.stack-category:hover {
    border-color: var(--accent-color);
    transform: translateY(-3px);
}

.stack-category h3 {
    color: var(--accent-color);
    font-size: var(--body-text);
    margin-bottom: 1.25rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-weight: 600;
    padding-bottom: 0.75rem;
    border-bottom: 2px solid rgba(96, 165, 250, 0.3);
}

.stack-category h3 i {
    font-size: 1.25em;
}

.stack-items {
    display: flex;
    flex-wrap: wrap;
    gap: 0.625rem;
}

.stack-item {
    background: rgba(59, 130, 246, 0.1);
    color: var(--accent-color);
    padding: 0.5rem 1rem;
    border-radius: 20px;
    font-size: var(--small-text);
    font-weight: 500;
    border: 1px solid rgba(59, 130, 246, 0.2);
    transition: all 0.2s ease;
}

.stack-item:hover {
    background: rgba(59, 130, 246, 0.2);
    border-color: var(--accent-color);
    transform: translateY(-2px);
}

/* ---------- FEATURES ---------- */
.features-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(200px, 100%), 1fr));
    gap: clamp(1rem, 1.5vw, 1.25rem);
    margin-top: 1rem;
}

.feature-item {
    background: rgba(255, 255, 255, 0.05);
    padding: clamp(1.25rem, 2vw, 1.5rem);
    border-radius: 16px;
    text-align: center;
    border: 1px solid var(--border-color);
    transition: all 0.3s ease;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.feature-item:hover {
    border-color: var(--accent-color);
    transform: translateY(-5px);
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.2);
}

.feature-icon {
    font-size: clamp(2rem, 4vw, 2.5rem);
    color: var(--accent-color);
    margin-bottom: 1rem;
    display: inline-block;
    transition: transform 0.3s ease;
}

.feature-item:hover .feature-icon {
    transform: scale(1.1) rotate(5deg);
}

.feature-item h3 {
    color: var(--primary-color);
    font-size: var(--card-title);
    margin-bottom: 0.75rem;
    font-weight: 600;
}

.feature-item p {
    color: var(--secondary-color);
    font-size: var(--small-text);
    line-height: 1.6;
    flex: 1;
}

/* ---------- SOCIAL MEDIA ---------- */
.social-media {
    background: linear-gradient(135deg, rgba(59, 130, 246, 0.1), rgba(30, 64, 175, 0.1));
    padding: clamp(1.25rem, 2vw, 1.5rem);
    border-radius: 20px;
    border: 1px solid rgba(59, 130, 246, 0.2);
}

.social-content {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 1.5rem;
}

.social-content span {
    color: var(--secondary-color);
    font-weight: 600;
    font-size: var(--body-text);
    white-space: nowrap;
}

.media-links {
    display: flex;
    flex-wrap: wrap;
    gap: clamp(1rem, 1.5vw, 1.25rem);
    justify-content: center;
}

.media-link {
    text-decoration: none;
    color: var(--accent-color);
    font-size: clamp(1.75rem, 3vw, 2rem);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2.5em;
    height: 2.5em;
    border-radius: 12px;
    background: rgba(59, 130, 246, 0.1);
}

.media-link:hover {
    color: white;
    background: rgba(59, 130, 246, 0.3);
    transform: translateY(-3px) scale(1.1);
    box-shadow: 0 8px 20px rgba(59, 130, 246, 0.3);
}

/* ---------- SCROLL REVEAL ANIMATION ---------- */
.scroll-reveal {
    opacity: 0;
    transform: translateY(30px);
    transition: all 0.8s cubic-bezier(0.4, 0, 0.2, 1);
}

.scroll-reveal.visible {
    opacity: 1;
    transform: translateY(0);
}

/* ------------ RESPONSIVE BREAKPOINTS ------------ */

/* TABLET (768px - 1023px) */
@media screen and (max-width: 1023px) {
    .main-content {
        grid-template-columns: 1fr;
        gap: 2rem;
    }
    
    .sidebar {
        position: static;
    }
    
    .profile-actions {
        flex-direction: row;
        flex-wrap: wrap;
    }
    
    .profile-actions button {
        flex: 1;
        min-width: 150px;
    }
    
    .bio {
        margin-top: 1rem;
    }
    
    .projects-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .features-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .social-content {
        flex-direction: column;
        text-align: center;
    }
    
    .back-to-top {
        bottom: 20px;
        right: 20px;
        width: 45px;
        height: 45px;
        font-size: 1.25rem;
    }
}

/* MOBILE (< 768px) */
@media screen and (max-width: 767px) {
    body {
        padding: 0.5rem;
    }
    
    .container {
        gap: 1.5rem;
    }
    
    .profile-header {
        padding: 1.5rem 1rem;
        min-height: 160px;
        border-radius: 16px;
    }
    
    .main-profile {
        flex-direction: column;
        text-align: center;
        gap: 1rem;
    }
    
    .profile-names {
        text-align: center;
    }
    
    .main-content {
        gap: 1.5rem;
    }
    
    .content-wrapper {
        gap: 1.5rem;
        padding-bottom: 2rem;
    }
    
    .profile-actions {
        flex-direction: column;
    }
    
    .projects-grid,
    .stack-grid,
    .features-grid {
        grid-template-columns: 1fr;
    }
    
    .project-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.75rem;
    }
    
    .project-badge {
        align-self: flex-start;
    }
    
    .social-content {
        flex-direction: column;
        text-align: center;
        gap: 1.25rem;
    }
    
    .media-links {
        width: 100%;
        justify-content: center;
    }
    
    .back-to-top {
        bottom: 15px;
        right: 15px;
        width: 40px;
        height: 40px;
        font-size: 1.125rem;
    }
}

/* LARGE DESKTOP (> 1200px) */
@media screen and (min-width: 1200px) {
    .projects-grid {
        grid-template-columns: repeat(3, 1fr);
    }
    
    .features-grid {
        grid-template-columns: repeat(4, 1fr);
    }
}

/* TOUCH DEVICE ENHANCEMENTS */
@media (hover: none) and (pointer: coarse) {
    .project-card:hover,
    .stack-category:hover,
    .feature-item:hover,
    .media-link:hover,
    .back-to-top:hover,
    .content-section:hover {
        transform: none;
    }
    
    .profile-actions button:active,
    .project-card:active,
    .media-link:active,
    .back-to-top:active {
        transform: scale(0.98);
    }
}

/* SAFE AREA FOR NOTCH PHONES */
@supports (padding: max(0px)) {
    body {
        padding-left: max(0.5rem, env(safe-area-inset-left));
        padding-right: max(0.5rem, env(safe-area-inset-right));
        padding-top: max(0.5rem, env(safe-area-inset-top));
        padding-bottom: max(0.5rem, env(safe-area-inset-bottom));
    }
    
    .back-to-top {
        bottom: max(30px, env(safe-area-inset-bottom));
        right: max(30px, env(safe-area-inset-right));
    }
}

/* PERFORMANCE OPTIMIZATIONS */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
    
    .scroll-reveal {
        transition: none !important;
        opacity: 1 !important;
        transform: none !important;
    }
}