/* ==================== GOOGLE FONTS ==================== */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;700;800&display=swap');

/* ==================== CSS VARIABLES ==================== */
:root {
    /* 60-30-10 Color Rule (Light Mode) */
    --color-primary-hue: 210;
    /* Blue */
    --color-accent-hue: 38;
    /* Orange */

    /* 60% - Primary (Backgrounds & Whitespace) */
    --color-background: hsl(0, 0%, 100%);
    --color-surface: hsl(0, 0%, 98%);

    /* 30% - Secondary (Text & UI) */
    --color-text: hsl(0, 0%, 13%);
    --color-text-light: hsl(0, 0%, 40%);
    --color-border: hsl(0, 0%, 90%);

    /* 10% - Accent (CTAs & Highlights) */
    --color-accent: hsl(var(--color-accent-hue), 100%, 50%);
    --color-primary: hsl(var(--color-primary-hue), 100%, 50%);
    --color-primary-alt: hsl(var(--color-primary-hue), 100%, 45%);

    /* Other */
    --font-family: 'Inter', sans-serif;
    --shadow-light: 0 4px 12px hsla(0, 0%, 0%, 0.05);
    --shadow-medium: 0 8px 24px hsla(0, 0%, 0%, 0.1);
    --border-radius: 12px;
    --transition-smooth: all 0.3s ease-in-out;
    --header-height: 4.5rem;
}

[data-theme="dark"] {
    /* Apple-inspired Dark Mode Palette */
    --color-background: hsl(0, 0%, 7%);
    --color-surface: hsl(240, 2%, 12%);
    --color-text: hsl(0, 0%, 95%);
    --color-text-light: hsl(0, 0%, 70%);
    --color-border: hsl(240, 2%, 20%);
    --color-accent: hsl(var(--color-accent-hue), 100%, 55%);
    --color-primary: hsl(var(--color-primary-hue), 100%, 55%);
    --color-primary-alt: hsl(var(--color-primary-hue), 100%, 50%);
    --shadow-light: 0 4px 12px hsla(0, 0%, 0%, 0.1);
    --shadow-medium: 0 8px 24px hsla(0, 0%, 0%, 0.2);
}

/* ==================== BASE ==================== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: var(--font-family);
    font-size: 1rem;
    background-color: var(--color-background);
    color: var(--color-text);
    transition: background-color 0.3s ease, color 0.3s ease;
}

h1,
h2,
h3 {
    font-weight: 700;
    line-height: 1.2;
}

ul {
    list-style: none;
}

a {
    text-decoration: none;
    color: inherit;
}

img {
    max-width: 100%;
    height: auto;
}

/* ==================== REUSABLE CSS ==================== */
.container {
    max-width: 1120px;
    /* UPDATE: Centered container with side padding */
    margin-left: auto;
    margin-right: auto;
    padding-left: 1.5rem;
    padding-right: 1.5rem;
}

.section {
    padding-top: 5rem;
    padding-bottom: 4rem;
}

.section__title {
    font-size: 2.25rem;
    text-align: center;
    margin-bottom: 3rem;
    font-weight: 800;
}

.grid {
    display: grid;
    gap: 2rem;
}

/* ==================== BUTTONS ==================== */
.button {
    display: inline-block;
    padding: 0.9rem 2rem;
    border: none;
    border-radius: var(--border-radius);
    font-weight: 500;
    font-size: 1rem;
    cursor: pointer;
    transition: var(--transition-smooth);
    text-align: center;
    white-space: nowrap;
    /* Prevents wrapping */
}

.button--primary {
    background-color: var(--color-primary);
    color: #fff;
}

.button--primary:hover {
    background-color: var(--color-primary-alt);
    transform: translateY(-3px);
    box-shadow: 0 8px 20px hsla(var(--color-primary-hue), 100%, 50%, 0.3);
}

.button--secondary {
    background-color: transparent;
    color: var(--color-primary);
    border: 2px solid var(--color-primary);
}

.button--secondary:hover {
    background-color: var(--color-primary);
    color: #fff;
}

.button--large {
    padding: 1.1rem 2.5rem;
    font-size: 1.1rem;
}

.button--small {
    padding: 0.5rem 1rem;
    font-size: 0.9rem;
    border-radius: 8px;
}

/* ==================== HEADER & NAV ==================== */
.header {
    position: sticky;
    top: 0;
    left: 0;
    width: 100%;
    background-color: var(--color-background);
    box-shadow: var(--shadow-light);
    z-index: 1000;
    transition: var(--transition-smooth);
}

[data-theme="dark"] .header {
    background-color: hsla(0, 0%, 7%, 0.8);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--color-border);
    box-shadow: none;
}

.nav {
    height: var(--header-height);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.nav__logo {
    font-weight: 700;
    font-size: 1.25rem;
    color: var(--color-primary);
}

.nav__logo-img {
    /* Adjust this height to fit your header (which is 4.5rem) */
    height: 40px; 
    width: auto; /* Maintains aspect ratio */
    display: block; /* Fixes potential alignment issues */
}

.nav__menu {
    /* This rule will be overridden on desktop */
    margin-left: auto;
}

.nav__list {
    display: flex;
    gap: 2rem;
}

.nav__link {
    font-weight: 500;
    color: var(--color-text-light);
    transition: var(--transition-smooth);
}

.nav__link:hover {
    color: var(--color-primary);
}

.nav__actions {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    /* Reduced gap */
    margin-left: 1.5rem;
}

/* Hide auth buttons on mobile by default */
.nav__button {
    display: none;
}

/* Mobile nav toggle */
.nav__toggle {
    display: none;
    background: none;
    border: none;
    cursor: pointer;
    width: 30px;
    height: 24px;
    position: relative;
    z-index: 1001;
}

.nav__toggle-icon span {
    display: block;
    width: 100%;
    height: 3px;
    background-color: var(--color-text);
    border-radius: 3px;
    transition: all 0.3s ease;
    position: absolute;
}

.nav__toggle-icon span:nth-child(1) {
    top: 0;
}

.nav__toggle-icon span:nth-child(2) {
    top: 50%;
    transform: translateY(-50%);
}

.nav__toggle-icon span:nth-child(3) {
    bottom: 0;
}

/* Mobile nav "X" animation */
.nav__toggle--active .nav__toggle-icon span:nth-child(1) {
    top: 50%;
    transform: translateY(-50%) rotate(45deg);
}

.nav__toggle--active .nav__toggle-icon span:nth-child(2) {
    opacity: 0;
}

.nav__toggle--active .nav__toggle-icon span:nth-child(3) {
    bottom: 50%;
    transform: translateY(50%) rotate(-45deg);
}

/* Hide mobile auth items on desktop */
.nav__item--mobile-auth {
    display: none;
}


/* ==================== ACTIVE NAV LINK ==================== */
.nav__link.active-link {
    color: var(--color-primary);
    font-weight: 700; /* Makes it slightly bolder */
    position: relative;
}

/* Optional: Add a small underline */
.nav__link.active-link::after {
    content: '';
    position: absolute;
    bottom: -5px;
    left: 0;
    width: 100%;
    height: 2px;
    background-color: var(--color-primary);
}

/* On mobile, we don't want the underline */
@media screen and (max-width: 992px) {
    .nav__link.active-link::after {
        display: none;
    }
}

/* ==================== ACTIVE DROPDOWN LINK ==================== */
.profile__dropdown-link.active-link {
    color: var(--color-primary);
    background-color: var(--color-surface);
}

[data-theme="dark"] .profile__dropdown-link.active-link {
    background-color: var(--color-background);
}


/* ==================== THEME TOGGLE ==================== */
.theme-toggle {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: 20px;
    cursor: pointer;
    width: 50px;
    height: 26px;
    position: relative;
    display: flex;
    align-items: center;
    overflow: hidden;
}

.theme-toggle::before {
    content: '';
    position: absolute;
    width: 20px;
    height: 20px;
    background: var(--color-primary);
    border-radius: 50%;
    top: 2px;
    left: 3px;
    transition: var(--transition-smooth);
}

[data-theme="dark"] .theme-toggle::before {
    transform: translateX(23px);
}

.theme-toggle__icon {
    font-size: 0.9rem;
    position: absolute;
    transition: var(--transition-smooth);
}

.theme-toggle__icon--sun {
    left: 5px;
    opacity: 1;
}

.theme-toggle__icon--moon {
    right: 5px;
    opacity: 0;
}

[data-theme="dark"] .theme-toggle__icon--sun {
    opacity: 0;
}

[data-theme="dark"] .theme-toggle__icon--moon {
    opacity: 1;
}


/* ==================== FOOTER ==================== */
.footer {
    background-color: var(--color-surface);
    padding-top: 6rem;
    padding-bottom: 2rem;
}

[data-theme="dark"] .footer {
    background-color: hsl(0, 0%, 4%);
    /* Even darker for footer */
    border-top: 1px solid var(--color-border);
}

.footer__container {
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 3rem;
}

.footer__title {
    font-size: 1.2rem;
    margin-bottom: 1rem;
}

.footer__description {
    font-size: 0.9rem;
    line-height: 1.6;
    color: var(--color-text-light);
}

.footer__list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.footer__link {
    font-size: 0.9rem;
    color: var(--color-text-light);
    transition: var(--transition-smooth);
}

.footer__link:hover {
    color: var(--color-primary);
}

.footer__socials {
    display: flex;
    gap: 1rem;
}

.footer__social-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    background-color: var(--color-background);
    border: 1px solid var(--color-border);
    border-radius: 50%;
    color: var(--color-text-light);
    transition: var(--transition-smooth);
    font-size: 1rem;
}

[data-theme="dark"] .footer__social-link {
    background-color: var(--color-surface);
}

.footer__social-link:hover {
    background-color: var(--color-primary);
    color: #fff;
    border-color: var(--color-primary);
}

.footer__copyright {
    text-align: center;
    margin-top: 4rem;
    padding-top: 2rem;
    border-top: 1px solid var(--color-border);
    font-size: 0.85rem;
    color: var(--color-text-light);
}

/* ==================== PAGE HEADER ==================== */
.page-header {
    background-color: var(--color-surface);
    text-align: center;
    padding-top: 6rem;
    padding-bottom: 6rem;
}

[data-theme="dark"] .page-header {
    background-image: linear-gradient(135deg, hsla(var(--color-primary-hue), 80%, 20%, 0.3) 0%, hsla(0, 0%, 7%, 0) 60%);
}

.page-header__title {
    font-size: 3rem;
    font-weight: 800;
    margin-bottom: 1rem;

    /* YOUR NEW GRADIENT STYLE - NOW APPLIES GLOBALLY */
    background: linear-gradient(90deg, var(--color-primary), var(--color-accent));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    color: transparent;
    /* Fallback for browsers */
}

.page-header__subtitle {
    font-size: 1.25rem;
    color: var(--color-text-light);
    max-width: 600px;
    margin: 0 auto;
}

/* ==================== PROFILE DROPDOWN ==================== */
/* Styles for the logged-in user profile button and dropdown */

.profile {
    position: relative;
    margin-left: 0.5rem;
}

.profile__button {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    cursor: pointer;
    border: 2px solid var(--color-primary);
    padding: 0;
    overflow: hidden;
    /* In case of no image */
    background-color: var(--color-surface);
    display: flex;
    align-items: center;
    justify-content: center;
}

.profile__image {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* Fallback icon if no image */
.profile__icon {
    font-size: 1.25rem;
    color: var(--color-primary);
}

.profile__dropdown {
    position: absolute;
    top: calc(100% + 15px);
    right: 0;
    width: 220px;
    background-color: var(--color-background);
    border: 1px solid var(--color-border);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-medium);
    padding: 0.75rem;
    opacity: 0;
    visibility: hidden;
    transform: translateY(10px);
    transition: var(--transition-smooth);
    z-index: 1100;
}

[data-theme="dark"] .profile__dropdown {
    background-color: var(--color-surface);
}

/* Show dropdown when profile button is clicked */
.profile__dropdown--active {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.profile__dropdown-header {
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--color-border);
    margin-bottom: 0.5rem;
}

.profile__dropdown-name {
    font-weight: 700;
    font-size: 1rem;
    color: var(--color-text);
}

.profile__dropdown-email {
    font-size: 0.85rem;
    color: var(--color-text-light);
    /* Prevents long emails from breaking layout */
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.profile__dropdown-list {
    display: flex;
    flex-direction: column;
}

.profile__dropdown-link {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    font-size: 0.95rem;
    color: var(--color-text-light);
    border-radius: 8px;
}

.profile__dropdown-link:hover {
    background-color: var(--color-surface);
    color: var(--color-primary);
}

[data-theme="dark"] .profile__dropdown-link:hover {
    background-color: var(--color-background);
}

.profile__dropdown-link i {
    width: 20px;
    text-align: center;
}

/* Special styling for the Logout link */
.profile__dropdown-link--logout {
    color: hsl(0, 72%, 51%);
    margin-top: 0.5rem;
    padding-top: 0.75rem;
    border-top: 1px solid var(--color-border);
}

.profile__dropdown-link--logout:hover {
    background-color: hsl(0, 100%, 97%);
    color: hsl(0, 72%, 51%);
}

[data-theme="dark"] .profile__dropdown-link--logout:hover {
    background-color: hsla(0, 72%, 51%, 0.1);
}


/* ==================== MEDIA QUERIES ==================== */

/* For tablets and larger phones */
@media screen and (max-width: 992px) {
    .nav__menu {
        position: fixed;
        /* CHANGE 1: Start the menu *below* the header */
        top: var(--header-height);
        left: 0;
        width: 100%;
        background-color: var(--color-background);
        padding: 2rem 0;

        /* CHANGE 2: Remove the old padding-top line */
        /* padding-top: calc(var(--header-height) + 2rem); */
        /* <--- DELETE THIS LINE */

        box-shadow: 0 10px 20px hsla(0, 0%, 0%, 0.1);
        transform: translateY(-130%);
        /* Hides it above its position */
        transition: var(--transition-smooth);
        margin-left: 0;

        /* BEST PRACTICE: Ensure it fills the screen and scrolls if needed */
        height: calc(100vh - var(--header-height));
        overflow-y: auto;
    }

    [data-theme="dark"] .nav__menu {
        background-color: var(--color-surface);
        box-shadow: 0 10px 20px hsla(0, 0%, 0%, 0.2);
    }

    .nav__menu--active {
        transform: translateY(0);
    }

    .nav__list {
        flex-direction: column;
        align-items: center;
        gap: 2.5rem;
    }

    .nav__toggle {
        display: block;
    }

    .nav__item--mobile-auth {
        display: block;
    }

    .nav__item--mobile-auth:first-of-type {
        margin-top: 1rem;
        padding-top: 2rem;
        border-top: 1px solid var(--color-border);
    }
}

/* For desktops */
@media screen and (min-width: 993px) {
    .nav__button {
        display: inline-block;
    }
}

/* For small devices */
@media screen and (max-width: 375px) {
    .container {
        padding-left: 1rem;
        padding-right: 1rem;
    }

    .nav__actions {
        gap: 0.5rem;
    }
}