/**
 * LinkedFit - Desktop Layout System
 *
 * Breakpoints:
 * - < 1024px  : Mobile App (KEINE Änderungen)
 * - 1024px+   : Desktop 3-Spalten Layout (LinkedIn-Stil)
 * - 1280px+   : Desktop mit mehr Platz
 * - 1536px+   : Large Desktop
 *
 * WICHTIG: Unter 1024px wird NICHTS verändert!
 */


/* ==========================================
   DESKTOP LAYOUT (1024px+)
   ========================================== */
@media (min-width: 1024px) {

    /* --- Body & Background --- */
    body {
        background-color: #F4F2EE;
    }

    /* Hide the old mobile branding sidebar */
    .md\:fixed.md\:inset-y-0.md\:left-8 {
        display: none !important;
    }

    /* --- Desktop Header --- */
    .desktop-header {
        display: flex !important;
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        height: 56px;
        background: #FFFFFF;
        border-bottom: 1px solid #E5E7EB;
        z-index: 100;
        box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
    }

    .desktop-header-inner {
        display: flex;
        align-items: center;
        justify-content: space-between;
        max-width: 1400px;
        margin: 0 auto;
        padding: 0 24px;
        width: 100%;
        height: 100%;
    }

    .desktop-header-left {
        display: flex;
        align-items: center;
        gap: 16px;
    }

    .desktop-header-search {
        width: 280px;
        height: 36px;
        padding: 0 16px 0 40px;
        border-radius: 8px;
        border: none;
        background: #EEF3F8;
        font-size: 14px;
        color: #333;
        transition: all 0.2s;
        cursor: pointer;
    }

    .desktop-header-search:focus {
        outline: none;
        background: #FFFFFF;
        box-shadow: 0 0 0 2px #FF6B35;
    }

    .desktop-header-search-wrapper {
        position: relative;
    }

    .desktop-header-search-icon {
        position: absolute;
        left: 12px;
        top: 50%;
        transform: translateY(-50%);
        color: #6B7280;
        pointer-events: none;
    }

    .desktop-header-nav {
        display: flex;
        align-items: center;
        gap: 0;
        height: 100%;
    }

    .desktop-header-nav-item {
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        padding: 0 20px;
        height: 100%;
        color: #6B7280;
        text-decoration: none;
        font-size: 11px;
        font-weight: 500;
        border-bottom: 2px solid transparent;
        transition: all 0.2s;
        gap: 2px;
    }

    .desktop-header-nav-item:hover {
        color: #111827;
    }

    .desktop-header-nav-item.active {
        color: #FF6B35;
        border-bottom-color: #FF6B35;
    }

    .desktop-header-nav-item svg {
        width: 24px;
        height: 24px;
    }

    .desktop-header-right {
        display: flex;
        align-items: center;
        gap: 4px;
    }

    .desktop-header-icon-btn {
        display: flex;
        align-items: center;
        justify-content: center;
        width: 40px;
        height: 40px;
        border-radius: 50%;
        color: #6B7280;
        transition: all 0.15s;
        position: relative;
        background: none;
        border: none;
        cursor: pointer;
        text-decoration: none;
    }

    .desktop-header-icon-btn:hover {
        background: #F3F4F6;
        color: #111827;
    }

    .desktop-header-icon-btn svg {
        width: 22px;
        height: 22px;
    }

    .desktop-header-avatar {
        width: 32px;
        height: 32px;
        border-radius: 50%;
        object-fit: cover;
        cursor: pointer;
        border: 2px solid transparent;
        transition: border-color 0.15s;
    }

    .desktop-header-avatar:hover {
        border-color: #FF6B35;
    }

    /* --- App Container: 3-Spalten Grid --- */
    .app-container {
        max-width: 1400px !important;
        margin: 0 auto !important;
        padding-top: 72px !important; /* Header (56px) + gap (16px) */
        padding-left: 24px;
        padding-right: 24px;
        display: grid !important;
        grid-template-columns: 280px 1fr 300px;
        grid-template-rows: auto;
        gap: 24px;
        min-height: 100vh;
        background: transparent !important;
        box-shadow: none !important;
        border: none !important;
    }

    /* --- Explicit Grid Placement (prevent intermediate elements from breaking layout) --- */
    .desktop-sidebar-left {
        grid-column: 1;
        grid-row: 1;
    }

    .app-container > main {
        grid-column: 2;
        grid-row: 1;
    }

    .desktop-sidebar-right {
        grid-column: 3;
        grid-row: 1;
    }

    /* --- Mobile Header: verstecken --- */
    .app-container > header.sticky {
        display: none !important;
    }

    /* --- Linke Sidebar --- */
    .desktop-sidebar-left {
        display: block !important;
        position: sticky;
        top: 72px;
        height: fit-content;
        max-height: calc(100vh - 72px);
        overflow-y: auto;
        scrollbar-width: none;
        align-self: start;
    }

    .desktop-sidebar-left::-webkit-scrollbar {
        display: none;
    }

    /* --- Main Content --- */
    .app-container > main {
        max-width: 680px;
        width: 100%;
        justify-self: center;
        padding-bottom: 2rem !important;
        min-width: 0; /* Prevent grid blowout */
    }

    /* Remove max-w-lg on desktop main content */
    .app-container > main .max-w-lg {
        max-width: 100% !important;
    }

    /* --- Rechte Sidebar --- */
    .desktop-sidebar-right {
        display: block !important;
        position: sticky;
        top: 72px;
        height: fit-content;
        max-height: calc(100vh - 72px);
        overflow-y: auto;
        scrollbar-width: none;
        align-self: start;
    }

    .desktop-sidebar-right::-webkit-scrollbar {
        display: none;
    }

    /* --- Bottom Navigation: verstecken --- */
    .app-nav-bottom,
    nav[class*="fixed"][class*="bottom-0"] {
        display: none !important;
    }

    /* --- Drawer Menu: verstecken auf Desktop --- */
    /* The drawer is controlled by Alpine x-show, CSS hides the trigger */

    /* --- Hamburger-Button im Mobile-Header: verstecken --- */
    button[aria-label="Menü öffnen"] {
        display: none !important;
    }

    /* --- Toast Container: zentriert über Content --- */
    #toast-container {
        max-width: 680px;
        margin: 0 auto;
    }

    /* --- XP/Achievement Toasts --- */
    #xp-toast,
    #achievement-toast {
        max-width: 680px;
    }

    /* --- Global Loading --- */
    #global-loading {
        bottom: 2rem;
    }

    /* --- Feed Cards: Desktop-optimiert --- */
    .feed-card,
    .feed-item {
        border-radius: 12px;
    }

    /* Increase padding inside feed cards for wider layout */
    .feed-card .px-4,
    .feed-item .px-4 {
        padding-left: 1.25rem;
        padding-right: 1.25rem;
    }

    /* Wider spacing between feed cards */
    #feed-container.space-y-4 > * + * {
        margin-top: 1.25rem;
    }

    /* --- Images & Media in Feed: Desktop-optimiert --- */
    .feed-card img:not(.rounded-full),
    .feed-item img:not(.rounded-full) {
        border-radius: 0;
    }

    /* Limit very tall images in feed */
    .feed-card .max-h-96 {
        max-height: 32rem;
    }

    /* --- Desktop Content Area Adjustments --- */
    .app-container > main .max-w-md {
        max-width: 100% !important;
    }

    .app-container > main .max-w-xl {
        max-width: 100% !important;
    }

    .app-container > main .max-w-2xl {
        max-width: 100% !important;
    }

    /* Adjust padding for pages that use px-4 at root */
    .app-container > main > .px-4 {
        padding-left: 0;
        padding-right: 0;
    }

    /* --- Remove mobile bottom padding (pb-20 for bottom nav) --- */
    .app-container > main.pb-20 {
        padding-bottom: 2rem !important;
    }

    /* --- Desktop Typography --- */
    .app-container > main h1 {
        font-size: 1.75rem;
    }

    .app-container > main h2 {
        font-size: 1.375rem;
    }

    /* --- Sidebar Widget Cards --- */
    .desktop-widget {
        background: #FFFFFF;
        border-radius: 12px;
        border: 1px solid #E5E7EB;
        margin-bottom: 16px;
        overflow: hidden;
    }

    .desktop-widget-header {
        padding: 16px 16px 0;
        font-size: 16px;
        font-weight: 600;
        color: #111827;
        display: flex;
        align-items: center;
        gap: 8px;
    }

    .desktop-widget-body {
        padding: 12px 16px 16px;
    }

    .desktop-widget-footer {
        padding: 12px 16px;
        text-align: center;
        border-top: 1px solid #F3F4F6;
    }

    .desktop-widget-footer a {
        color: #6B7280;
        font-size: 14px;
        font-weight: 500;
        text-decoration: none;
        transition: color 0.15s;
    }

    .desktop-widget-footer a:hover {
        color: #FF6B35;
    }

    /* --- Profile Card (Left Sidebar) --- */
    .desktop-profile-card {
        background: #FFFFFF;
        border-radius: 12px;
        border: 1px solid #E5E7EB;
        overflow: hidden;
        margin-bottom: 16px;
    }

    .desktop-profile-banner {
        height: 64px;
        background: linear-gradient(135deg, #FF6B35 0%, #E55A2B 100%);
    }

    .desktop-profile-avatar-wrapper {
        display: flex;
        justify-content: center;
        margin-top: -32px;
    }

    .desktop-profile-avatar {
        width: 64px;
        height: 64px;
        border-radius: 50%;
        border: 3px solid #FFFFFF;
        object-fit: cover;
    }

    .desktop-profile-avatar-placeholder {
        width: 64px;
        height: 64px;
        border-radius: 50%;
        border: 3px solid #FFFFFF;
        background: #E5E7EB;
        display: flex;
        align-items: center;
        justify-content: center;
        font-size: 24px;
        font-weight: 700;
        color: #6B7280;
    }

    .desktop-profile-info {
        text-align: center;
        padding: 8px 16px 16px;
    }

    .desktop-profile-name {
        font-size: 16px;
        font-weight: 600;
        color: #111827;
    }

    .desktop-profile-name:hover {
        color: #FF6B35;
    }

    .desktop-profile-username {
        font-size: 13px;
        color: #6B7280;
        margin-top: 2px;
    }

    .desktop-profile-stats {
        display: flex;
        justify-content: space-around;
        padding: 12px 16px;
        border-top: 1px solid #F3F4F6;
    }

    .desktop-profile-stat {
        text-align: center;
        text-decoration: none;
    }

    .desktop-profile-stat-value {
        font-size: 16px;
        font-weight: 700;
        color: #FF6B35;
    }

    .desktop-profile-stat-label {
        font-size: 11px;
        color: #6B7280;
        margin-top: 2px;
    }

    /* --- Navigation (Left Sidebar) --- */
    .desktop-nav {
        background: #FFFFFF;
        border-radius: 12px;
        border: 1px solid #E5E7EB;
        padding: 8px 0;
        margin-bottom: 16px;
    }

    .desktop-nav-section-title {
        padding: 8px 16px 4px;
        font-size: 11px;
        font-weight: 600;
        color: #9CA3AF;
        text-transform: uppercase;
        letter-spacing: 0.05em;
    }

    .desktop-nav-item {
        display: flex;
        align-items: center;
        gap: 12px;
        padding: 10px 16px;
        color: #374151;
        text-decoration: none;
        font-size: 14px;
        font-weight: 500;
        transition: all 0.15s;
        border-left: 3px solid transparent;
    }

    .desktop-nav-item:hover {
        background: #F9FAFB;
        color: #FF6B35;
    }

    .desktop-nav-item.active {
        background: #FFF5F0;
        color: #FF6B35;
        border-left-color: #FF6B35;
        font-weight: 600;
    }

    .desktop-nav-item svg {
        width: 20px;
        height: 20px;
        flex-shrink: 0;
    }

    .desktop-nav-badge {
        margin-left: auto;
        min-width: 20px;
        height: 20px;
        padding: 0 6px;
        border-radius: 10px;
        background: #FF6B35;
        color: white;
        font-size: 11px;
        font-weight: 700;
        display: flex;
        align-items: center;
        justify-content: center;
    }

    /* --- Feed Card Containers: Desktop-optimiert --- */
    .bg-white.rounded-xl,
    .bg-white.rounded-2xl {
        border: 1px solid #E5E7EB;
        box-shadow: none;
        transition: box-shadow 0.2s ease;
    }

    .bg-white.rounded-xl:hover,
    .bg-white.rounded-2xl:hover {
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.06);
    }

    /* Ensure feed cards have consistent rounded borders */
    .feed-card.rounded-2xl,
    .feed-item .rounded-2xl {
        border-radius: 12px;
    }

    /* --- Action Buttons Desktop --- */
    .like-btn,
    .comment-btn,
    .share-btn {
        padding: 8px 16px;
        border-radius: 8px;
        transition: all 0.15s ease;
        font-size: 14px;
    }

    .like-btn:hover {
        background-color: #FEF2F2;
        color: #EF4444;
    }

    .comment-btn:hover {
        background-color: #EFF6FF;
        color: #3B82F6;
    }

    .share-btn:hover {
        background-color: #F0FDF4;
        color: #22C55E;
    }

    /* Post action row */
    .post-action {
        padding: 8px 16px;
        font-size: 14px;
    }

    /* --- Modals: zentriert statt Bottom-Sheet --- */
    [x-show][class*="fixed"][class*="inset-0"] > div[class*="bg-white"][class*="rounded"] {
        max-width: 560px;
        margin: 10vh auto;
        max-height: 80vh;
        border-radius: 16px;
        overflow-y: auto;
    }

    /* Full-screen modals: constrained on desktop */
    [x-show][class*="fixed"][class*="inset-0"] > div[class*="bg-white"].rounded-t-2xl,
    [x-show][class*="fixed"][class*="inset-0"] > div[class*="bg-white"].rounded-t-3xl {
        max-width: 560px;
        margin: 5vh auto;
        max-height: 90vh;
        border-radius: 16px;
        overflow-y: auto;
    }

    /* Comment/Share modal overlay - center content */
    .fixed.inset-0.z-50 > div {
        max-width: 560px;
        margin-left: auto;
        margin-right: auto;
    }

    /* --- Form Inputs: Desktop-optimiert --- */
    input:focus,
    textarea:focus,
    select:focus {
        box-shadow: 0 0 0 3px rgba(255, 107, 53, 0.12);
    }

    /* Wider inputs on desktop */
    input[type="text"],
    input[type="email"],
    input[type="password"],
    input[type="number"],
    input[type="url"],
    input[type="search"],
    textarea,
    select {
        font-size: 14px;
    }

    /* --- Buttons: Desktop-optimiert --- */
    .bg-primary {
        transition: all 0.15s ease;
    }

    .bg-primary:hover {
        filter: brightness(1.05);
        box-shadow: 0 2px 8px rgba(255, 107, 53, 0.3);
    }

    /* --- Scrollbar: dezent auf Desktop --- */
    .app-container > main {
        scrollbar-width: thin;
        scrollbar-color: #D1D5DB transparent;
    }

    .app-container > main::-webkit-scrollbar {
        width: 6px;
    }

    .app-container > main::-webkit-scrollbar-track {
        background: transparent;
    }

    .app-container > main::-webkit-scrollbar-thumb {
        background-color: #D1D5DB;
        border-radius: 3px;
    }
}


/* ==========================================
   LARGE DESKTOP (1280px+)
   ========================================== */
@media (min-width: 1280px) {

    .app-container {
        gap: 28px;
        grid-template-columns: 280px 1fr 320px;
    }

    .desktop-header-search {
        width: 360px;
    }

    .desktop-header-nav-item {
        padding: 0 24px;
    }

    /* Slightly wider main content area */
    .app-container > main {
        max-width: 720px;
    }
}


/* ==========================================
   EXTRA LARGE DESKTOP (1536px+)
   ========================================== */
@media (min-width: 1536px) {

    .app-container {
        gap: 32px;
        grid-template-columns: 300px 1fr 340px;
    }

    .app-container > main {
        max-width: 760px;
    }

    .desktop-header-inner {
        max-width: 1600px;
    }
}


/* ==========================================
   HOVER STATES (Desktop, präziser Pointer)
   ========================================== */
@media (hover: hover) and (pointer: fine) {

    .card-hover:hover {
        transform: translateY(-1px);
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
    }

    .post-action:hover {
        color: #FF6B35;
        background-color: rgba(255, 107, 53, 0.08);
        border-radius: 8px;
    }

    .desktop-nav-item:hover svg {
        color: #FF6B35;
    }

    /* Profile stat hover */
    .desktop-profile-stat:hover .desktop-profile-stat-value {
        color: #E55A2B;
    }

    /* Widget link hover */
    .desktop-widget a:hover {
        color: #FF6B35;
    }

    /* Feed card avatar hover */
    .feed-card .rounded-full:hover,
    .feed-item .rounded-full:hover {
        opacity: 0.9;
    }
}


/* ==========================================
   FOCUS STATES (Accessibility)
   ========================================== */
@media (min-width: 1024px) {

    a:focus-visible,
    button:focus-visible,
    input:focus-visible,
    textarea:focus-visible,
    select:focus-visible {
        outline: 2px solid #FF6B35;
        outline-offset: 2px;
    }
}


/* ==========================================
   PRINT
   ========================================== */
@media print {

    .desktop-header,
    .desktop-sidebar-left,
    .desktop-sidebar-right,
    .app-nav-bottom {
        display: none !important;
    }

    .app-container {
        display: block !important;
        max-width: 100%;
        padding-top: 0;
    }

    body {
        background: white;
    }
}


/* ==========================================
   UTILITY CLASSES
   ========================================== */

.desktop-only {
    display: none !important;
}

@media (min-width: 1024px) {
    .desktop-only {
        display: block !important;
    }

    .desktop-only-flex {
        display: flex !important;
    }

    .mobile-only {
        display: none !important;
    }
}


/* ==========================================
   HIDE-NAV PAGES (Chat, Add, etc.)
   Single-column layout when sidebars hidden
   ========================================== */
@media (min-width: 1024px) {

    /* Single-column layout for pages with $hideNav = true */
    .app-container[data-hide-nav="true"] {
        display: block !important;
        max-width: 100% !important;
        padding-top: 72px !important;
    }

    /* Center main content with reasonable max-width */
    .app-container[data-hide-nav="true"] > main {
        max-width: 680px;
        margin: 0 auto;
    }

    /* Chat conversation: full-height layout below desktop header */
    .chat-conversation-container {
        height: calc(100vh - 72px) !important;
        max-width: 680px !important;
        margin: 0 auto;
        background: white;
        border-left: 1px solid #E5E7EB;
        border-right: 1px solid #E5E7EB;
    }

    /* Chat messages area: proper scrolling */
    .chat-conversation-container > .flex-1 {
        scrollbar-width: thin;
        scrollbar-color: #D1D5DB transparent;
    }

    /* === Add Page: Desktop Dashboard Layout === */

    .add-page-container {
        min-height: auto !important;
        border-radius: 16px;
        max-width: 900px !important;
        margin: 24px auto 32px;
        position: relative;
        box-shadow: 0 4px 24px rgba(0, 0, 0, 0.15);
        overflow: hidden;
    }

    /* Hero section: more compact on desktop */
    .add-page-container > .pt-16.pb-8 {
        padding-top: 2.5rem !important;
        padding-bottom: 1.5rem !important;
    }

    .add-page-container > .pt-16.pb-8 .w-20.h-20 {
        width: 3.5rem !important;
        height: 3.5rem !important;
    }

    .add-page-container > .pt-16.pb-8 .w-10.h-10 {
        width: 2.5rem;
        height: 2.5rem;
    }

    .add-page-container > .pt-16.pb-8 h1 {
        font-size: 1.5rem !important;
        margin-bottom: 0.25rem !important;
    }

    /* Close button: top-right inside container */
    .add-page-container > .absolute.top-4.right-4 {
        top: 1rem;
        right: 1rem;
    }

    /* Action cards: 2-column grid */
    .add-cards-grid {
        display: grid !important;
        grid-template-columns: 1fr 1fr;
        gap: 16px;
        padding: 0 2rem 2rem !important;
    }

    /* Reset space-y-3 margins in grid */
    .add-cards-grid > * {
        margin-top: 0 !important;
    }

    /* Divider spans full width */
    .add-cards-grid > .flex.items-center.gap-3 {
        grid-column: 1 / -1;
    }

    /* Today's progress: wider on desktop */
    .add-page-container > div:not(.add-cards-grid):not(.absolute) {
        padding-left: 2rem !important;
        padding-right: 2rem !important;
    }

    /* Remove mobile bottom spacer */
    .add-page-container > .h-20:last-child {
        display: none;
    }
}


/* ==========================================
   PROFILE PAGE DESKTOP FIXES
   ========================================== */
@media (min-width: 1024px) {

    /* Profile cover: rounded corners on desktop */
    .app-container > main .max-w-lg > .relative > .h-32 {
        border-radius: 12px 12px 0 0;
        overflow: hidden;
    }

    /* Profile sticky tabs: account for desktop header (56px + 16px gap) */
    .app-container > main #profile-tabs {
        top: 72px !important;
        background: white;
        border-radius: 0;
        z-index: 15;
    }

    /* Profile cover action buttons: ensure they're above cover */
    .app-container > main .max-w-lg > .relative > .absolute {
        z-index: 5;
    }

    /* Profile stats bar: desktop style */
    .app-container > main .max-w-lg .flex.justify-around.bg-gray-50.rounded-xl {
        background: white;
        border: 1px solid #E5E7EB;
    }

    /* Profile max-w-lg: ensure full width on desktop */
    .app-container > main > .max-w-lg {
        max-width: 100% !important;
    }
}


/* ==========================================
   LANDING PAGE / AUTH (nicht eingeloggt)
   ========================================== */
@media (min-width: 1024px) {

    body[data-logged-in="false"] .app-container {
        display: block !important;
        max-width: 100% !important;
        background: transparent !important;
        box-shadow: none !important;
        border: none !important;
        padding-top: 0 !important;
        padding-left: 0;
        padding-right: 0;
    }

    body[data-logged-in="false"] .desktop-header,
    body[data-logged-in="false"] .desktop-sidebar-left,
    body[data-logged-in="false"] .desktop-sidebar-right {
        display: none !important;
    }
}
