/**
 * Kabar Papua - Layout Styles
 */

/* App Navbar */
.app-navbar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 64px;
    background: var(--color-surface);
    border-bottom: 1px solid var(--color-border);
    z-index: var(--z-fixed);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 var(--space-md);
}

.app-logo {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    cursor: pointer;
    text-decoration: none;
}

.app-logo-icon {
    width: 36px;
    height: 36px;
    background: linear-gradient(135deg, var(--color-primary), var(--color-primary-dark));
    color: white;
    border-radius: var(--radius-lg);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
}

.app-logo-text {
    font-weight: 700;
    font-size: 1.25rem;
    color: var(--color-text);
    display: none;
}

@media (min-width: 768px) {
    .app-logo-text {
        display: block;
    }

    .app-navbar {
        padding: 0 var(--space-lg);
    }
}

/* Search */
.app-search {
    flex: 1;
    max-width: 560px;
    margin: 0 var(--space-md);
    display: none;
}

@media (min-width: 768px) {
    .app-search {
        display: block;
    }
}

.search-input-wrap {
    position: relative;
}

.search-input-wrap i {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--color-text-light);
}

.search-input {
    width: 100%;
    padding: 10px 16px;
    background: var(--color-bg);
    border: 1px solid transparent;
    border-radius: var(--radius-full);
    font-size: 0.875rem;
    transition: all var(--transition-fast);
}

.search-input:focus {
    background: var(--color-surface);
    border-color: var(--color-secondary);
    outline: none;
}

/* Main layout */
.app-main {
    margin-top: 0;
    /* Follows ticker */
    min-height: calc(100vh - 104px);
}

.app-grid {
    max-width: 1400px;
    margin: 0 auto;
    display: grid;
    grid-template-columns: 1fr;
    gap: var(--space-lg);
    padding: var(--space-lg) 0;
}

@media (min-width: 1024px) {
    .app-grid {
        grid-template-columns: 250px 1fr 280px;
        padding: var(--space-lg);
    }
}

/* Sidebar */
.sidebar {
    display: none;
    position: sticky;
    top: 88px;
    height: calc(100vh - 100px);
    overflow-y: auto;
}

@media (min-width: 1024px) {
    .sidebar {
        display: block;
    }
}

.sidebar-menu-item {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    width: 100%;
    padding: var(--space-sm) var(--space-md);
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--color-text-muted);
    background: transparent;
    border: none;
    border-radius: var(--radius-lg);
    cursor: pointer;
    transition: background var(--transition-fast);
    text-align: left;
    text-decoration: none;
}

.sidebar-menu-item:hover {
    background: var(--color-bg);
    text-decoration: none;
}

.sidebar-menu-item.active {
    background: var(--color-bg);
    color: var(--color-text);
}

.sidebar-menu-item i {
    width: 24px;
    text-align: center;
    font-size: 1.125rem;
}

.sidebar-section-title {
    padding: var(--space-md) var(--space-md) var(--space-xs);
    font-size: 0.625rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--color-text-light);
}

/* Feed */
.feed-section {
    padding: 0 var(--space-sm);
}

@media (min-width: 768px) {
    .feed-section {
        padding: 0;
    }
}

.feed-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: var(--space-md);
    padding: 0 var(--space-sm);
}

.feed-title {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--color-text);
}

.posts-container {
    display: flex;
    flex-direction: column;
    gap: var(--space-md);
}

/* Mobile tabs */
.mobile-tabs {
    display: flex;
    background: var(--color-surface);
    border-bottom: 1px solid var(--color-border);
    position: sticky;
    top: 64px;
    z-index: var(--z-sticky);
    margin-bottom: var(--space-md);
    overflow-x: auto;
}

@media (min-width: 1024px) {
    .mobile-tabs {
        display: none;
    }
}

.mobile-tab {
    flex: 1;
    padding: var(--space-sm) var(--space-md);
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--color-text-muted);
    background: transparent;
    border: none;
    border-bottom: 2px solid transparent;
    cursor: pointer;
    white-space: nowrap;
    transition: all var(--transition-fast);
    text-decoration: none;
    text-align: center;
}

.mobile-tab:hover {
    text-decoration: none;
}

.mobile-tab.active {
    color: var(--color-secondary);
    border-bottom-color: var(--color-secondary);
}

/* Single post view */
.single-view {
    display: block;
}

.single-header {
    position: sticky;
    top: 64px;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(8px);
    border-bottom: 1px solid var(--color-border);
    padding: var(--space-sm) var(--space-md);
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    z-index: var(--z-sticky);
}

.single-content {
    padding: var(--space-md);
    padding-bottom: var(--space-2xl);
}

@media (min-width: 768px) {
    .single-content {
        padding: var(--space-lg);
    }
}

/* Article prose */
.prose {
    font-family: var(--font-serif);
    line-height: 1.75;
}

.prose p {
    margin-bottom: 1.25em;
    text-align: justify;
}

.prose img {
    border-radius: var(--radius-lg);
    margin: var(--space-lg) auto;
    width: 100%;
    height: auto;
}

.prose iframe {
    width: 100%;
    border-radius: var(--radius-lg);
}

.prose h2,
.prose h3 {
    font-family: var(--font-sans);
    margin-top: 1.5em;
    margin-bottom: 0.5em;
}

/* Widget */
.widget {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-xl);
    padding: var(--space-md);
    margin-bottom: var(--space-md);
}

.widget-title {
    font-weight: 700;
    margin-bottom: var(--space-sm);
    color: var(--color-text);
}

/* Notification styles */
.notif-badge {
    position: absolute;
    top: 4px;
    right: 4px;
    min-width: 18px;
    height: 18px;
    background: var(--color-error);
    color: white;
    font-size: 0.625rem;
    font-weight: 700;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

#notifBtn {
    position: relative;
}

/* Old Notification Styles Removed - Moved to Bottom */

.notif-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--space-md);
    border-bottom: 1px solid var(--color-border);
}

.notif-list {
    max-height: 340px;
    overflow-y: auto;
}

/* Modern Notification Items */
.notif-item {
    display: flex;
    gap: 14px;
    padding: 16px 20px;
    border-bottom: 1px solid #f5f5f5;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
}

.notif-item:last-child {
    border-bottom: none;
}

.notif-item:hover {
    background: linear-gradient(to right, #fafafa, #ffffff);
    transform: translateX(2px);
}

.notif-item:active {
    transform: translateX(1px) scale(0.99);
}

.notif-item.unread {
    background: linear-gradient(to right, #fef2f2, #ffffff);
    border-left: 3px solid #dc2626;
}

.notif-item.unread::before {
    content: '';
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 6px;
    height: 6px;
    background: #dc2626;
    border-radius: 50%;
    box-shadow: 0 0 0 3px rgba(220, 38, 38, 0.1);
}

.notif-avatar {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: linear-gradient(135deg, #f3f4f6, #e5e7eb);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #6b7280;
    flex-shrink: 0;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
    transition: transform 0.2s ease;
}

.notif-item:hover .notif-avatar {
    transform: scale(1.05);
}

.notif-content {
    flex: 1;
    min-width: 0;
}

.notif-text {
    font-size: 14px;
    color: #1f2937;
    line-height: 1.5;
    margin-bottom: 4px;
    font-weight: 500;
}

.notif-time {
    font-size: 12px;
    color: #9ca3af;
    margin-top: 4px;
    font-weight: 400;
}

/* Profile styles - Reddit-style */
.profile-header {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: 8px;
    overflow: hidden;
}

.profile-banner {
    height: 120px;
    background: linear-gradient(135deg, #ff4500 0%, #ff6b35 60%, #ffb347 100%);
}

.profile-info {
    padding: 0 24px 24px;
    text-align: center;
}

.profile-avatar {
    width: 100px;
    height: 100px;
    border-radius: 50%;
    background: white;
    margin: -50px auto 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2.5rem;
    font-weight: 700;
    color: #ff4500;
    border: 4px solid white;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.profile-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.profile-name {
    font-size: 1.5rem;
    font-weight: 700;
    color: #1a1a1b;
    margin-bottom: 4px;
}

.profile-bio {
    color: #787c7e;
    font-size: 0.9rem;
    line-height: 1.5;
    margin-bottom: 16px;
}

.profile-stats {
    display: flex;
    justify-content: center;
    gap: 32px;
    margin: 16px 0;
    padding: 16px 0;
    border-top: 1px solid var(--color-border);
    border-bottom: 1px solid var(--color-border);
}

.profile-stat {
    text-align: center;
}

.profile-stat-value {
    font-size: 1.25rem;
    font-weight: 700;
    color: #1a1a1b;
}

.profile-stat-label {
    font-size: 0.75rem;
    color: #787c7e;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.profile-actions {
    display: flex;
    gap: 12px;
    justify-content: center;
    margin-top: 16px;
}

/* Mobile Search Bar */
#mobileSearch {
    position: fixed;
    top: 64px;
    left: 0;
    right: 0;
    background: var(--color-surface);
    padding: var(--space-sm);
    border-bottom: 1px solid var(--color-border);
    z-index: var(--z-sticky);
}

/* Utility spacing */
.space-y-1>*+* {
    margin-top: var(--space-xs);
}

.space-y-2>*+* {
    margin-top: var(--space-sm);
}

.mt-4 {
    margin-top: var(--space-md);
}

.mt-6 {
    margin-top: var(--space-lg);
}

.mb-3 {
    margin-bottom: var(--space-md);
}

.mb-4 {
    margin-bottom: var(--space-md);
}

.mb-10 {
    margin-bottom: var(--space-2xl);
}

.py-4 {
    padding-top: var(--space-md);
    padding-bottom: var(--space-md);
}

.px-2 {
    padding-left: var(--space-sm);
    padding-right: var(--space-sm);
}

.w-full {
    width: 100%;
}

/* =============================================
   Refactored Header Styles (Moved from header.php)
   ============================================= */

/* Branding Logo */
.app-logo {
    display: flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
}

.app-logo-text {
    display: block;
    /* Ensure visibility */
    font-family: 'Inter', sans-serif;
    font-weight: 800;
    font-size: 1.1rem;
    color: #1a1a1a;
    line-height: 1;
}

.app-logo-icon {
    width: 32px;
    height: 32px;
    background: #dc2626;
    /* Specific Red for Kabar Papua */
    color: white;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    flex-shrink: 0;
}

/* Navbar Sticky & Layout */
body {
    padding-top: 0;
}

.app-navbar {
    position: sticky;
    /* Prefer sticky over fixed for this layout context */
    top: 0;
    left: 0;
    right: 0;
    height: 64px;
    background: #ffffff;
    border-bottom: 1px solid #e5e7eb;
    padding: 0 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    z-index: 1000;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

/* Search Bar Desktop */
/* Search Bar Visibility Control */
.header-search-wrap {
    flex: 1;
    max-width: 600px;
    margin: 0 auto;
    padding: 0 16px;
}

/* Hide desktop search on mobile (< 1024px) */
@media (max-width: 1023px) {
    .header-search-wrap {
        display: none;
    }
}

@media (min-width: 1024px) {
    .header-search-wrap {
        display: block;
        /* Visible ONLY on Desktop */
    }
}

.header-search-input {
    width: 100%;
    height: 40px;
    padding: 0 20px;
    background-color: #f3f4f6;
    border: 1px solid transparent;
    border-radius: 99px;
    font-size: 0.9rem;
    color: #333;
    transition: all 0.2s ease;
}

.header-search-input:focus {
    background-color: #ffffff;
    border-color: #dc2626;
    outline: none;
    box-shadow: 0 0 0 3px rgba(220, 38, 38, 0.1);
}

/* 
   Modern Floating Notification Dropdown 
   - Clean, minimal design
   - Smooth animations
   - Better visual hierarchy
   - Always above ticker (z-index 2100 > 900)
*/
.notif-dropdown {
    position: fixed;
    top: 72px;
    right: 20px;
    width: 420px;
    max-height: calc(100vh - 100px);
    background: #ffffff;
    border-radius: 16px;
    box-shadow:
        0 0 0 1px rgba(0, 0, 0, 0.05),
        0 20px 40px rgba(0, 0, 0, 0.12),
        0 10px 20px rgba(0, 0, 0, 0.08);
    z-index: 2100;
    /* Above ticker (900) and header (1000) */
    overflow: hidden;
    border: none;
    transform-origin: top right;
    animation: notifSlideIn 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

/* Modern Arrow Pointer */
.notif-dropdown::before {
    content: '';
    position: absolute;
    top: -10px;
    right: 55px;
    width: 20px;
    height: 20px;
    background: #ffffff;
    transform: rotate(45deg);
    box-shadow: -3px -3px 8px rgba(0, 0, 0, 0.08);
    border-radius: 3px 0 0 0;
    z-index: 1;
}

/* Smooth Slide-in Animation */
@keyframes notifSlideIn {
    from {
        opacity: 0;
        transform: translateY(-8px) scale(0.96);
    }

    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* Responsive Dropdown */
@media (max-width: 480px) {
    .notif-dropdown {
        right: 12px;
        left: 12px;
        width: auto;
        max-width: 100%;
    }

    .notif-dropdown::before {
        right: 50px;
    }
}

/* Notification Header - Modern Style */
.notif-dropdown .p-3 {
    padding: 18px 20px;
    background: linear-gradient(to bottom, #fafafa, #ffffff);
    border-bottom: 1px solid #f0f0f0;
}

.notif-dropdown .font-bold {
    font-size: 16px;
    font-weight: 700;
    color: #1a1a1a;
    letter-spacing: -0.3px;
}

.notif-dropdown button {
    font-size: 13px;
    font-weight: 600;
    color: #dc2626;
    transition: color 0.2s ease;
}

.notif-dropdown button:hover {
    color: #b91c1c;
}

/* Notification List Container */
.notif-dropdown #notifList {
    max-height: calc(80vh - 100px);
    overflow-y: auto;
    background: #ffffff;
}

/* Custom Scrollbar for Modern Look */
.notif-dropdown #notifList::-webkit-scrollbar {
    width: 6px;
}

.notif-dropdown #notifList::-webkit-scrollbar-track {
    background: transparent;
}

.notif-dropdown #notifList::-webkit-scrollbar-thumb {
    background: #e5e5e5;
    border-radius: 10px;
}

.notif-dropdown #notifList::-webkit-scrollbar-thumb:hover {
    background: #d4d4d4;
}

/* Action Buttons */
.header-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

.btn-header-icon {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    color: #4b5563;
    background: transparent;
    border: none;
    cursor: pointer;
    transition: background 0.2s;
}

.btn-header-icon:hover {
    background: #f3f4f6;
    color: #111;
}

/* Mobile Search Button - Show on Mobile, Hide on Desktop */
.btn-search-mobile {
    display: flex;
    /* Visible by default (Mobile) */
}

@media (min-width: 1024px) {
    .btn-search-mobile {
        display: none;
        /* Hidden on Desktop */
    }
}

/* News Ticker */
.news-ticker-bar {
    width: 100%;
    height: 40px;
    background: #0f172a;
    border-bottom: 1px solid #333;
    display: flex;
    align-items: stretch;
    overflow: hidden;
    position: relative;
    z-index: 900;
}

.ticker-label {
    background: #dc2626;
    color: white;
    padding: 0 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 1px;
    white-space: nowrap;
    z-index: 10;
}

.ticker-content {
    flex: 1;
    position: relative;
    overflow: hidden;
    display: flex;
    align-items: center;
    color: white;
}

.ticker-wrap {
    position: absolute;
    white-space: nowrap;
    animation: tickerSlide 30s linear infinite;
    padding-left: 20px;
}

.ticker-item {
    display: inline-block;
    margin-right: 40px;
    font-size: 13px;
    color: #e2e8f0;
}

@keyframes tickerSlide {
    0% {
        transform: translate3d(0, 0, 0);
    }

    100% {
        transform: translate3d(-100%, 0, 0);
    }
}

/* Mobile Search Form */
#mobileSearchPanel {
    background: white;
    padding: 12px 16px;
    border-bottom: 1px solid #e5e7eb;
    display: none;
}

/* =============================================
   Refactored Footer/Modal Z-Indexes (Moved from footer.php)
   ============================================= */

/* Ensure Modals & Drawers appear above Sticky Header */
.modal-overlay,
.drawer-overlay {
    z-index: 2000;
}

.modal,
.drawer {
    z-index: 2001;
}

.fab {
    z-index: 1500;
    bottom: 24px;
    right: 24px;
}

/* Toastify notifications must be on top */
.toastify {
    z-index: 3000;
}

/* =============================================
   Tailwind-like Utility Classes
   ============================================= */

/* Flex */
.flex {
    display: flex;
}

.flex-1 {
    flex: 1 1 0%;
}

.flex-shrink-0 {
    flex-shrink: 0;
}

.flex-wrap {
    flex-wrap: wrap;
}

.items-start {
    align-items: flex-start;
}

.items-center {
    align-items: center;
}

.justify-center {
    justify-content: center;
}

.justify-between {
    justify-content: space-between;
}

.justify-end {
    justify-content: end;
}

/* Gap */
.gap-1 {
    gap: 4px;
}

.gap-2 {
    gap: 8px;
}

.gap-3 {
    gap: 12px;
}

.gap-4 {
    gap: 16px;
}

/* Padding */
.p-2 {
    padding: 8px;
}

.p-3 {
    padding: 12px;
}

.p-4 {
    padding: 16px;
}

.p-5 {
    padding: 20px;
}

.pt-3 {
    padding-top: 12px;
}

.py-8 {
    padding-top: 32px;
    padding-bottom: 32px;
}

/* Margin */
.mx-auto {
    margin-left: auto;
    margin-right: auto;
}

.mx-1 {
    margin-left: 4px;
    margin-right: 4px;
}

.mr-2 {
    margin-right: 8px;
}

.ml-6 {
    margin-left: 24px;
}

.mt-1 {
    margin-top: 4px;
}

.mt-2 {
    margin-top: 8px;
}

.mt-3 {
    margin-top: 12px;
}

/* Width/Height */
.w-9 {
    width: 36px;
}

.w-10 {
    width: 40px;
}

.h-9 {
    height: 36px;
}

.h-10 {
    height: 40px;
}

.min-w-0 {
    min-width: 0;
}

/* Border Radius */
.rounded-full {
    border-radius: 9999px;
}

.rounded-lg {
    border-radius: 8px;
}

/* Object Fit */
.object-cover {
    object-fit: cover;
}

.object-contain {
    object-fit: contain;
}

/* Text */
.text-sm {
    font-size: 0.875rem;
}

.text-xs {
    font-size: 0.75rem;
}

.text-base {
    font-size: 1rem;
}

.text-lg {
    font-size: 1.125rem;
}

.text-4xl {
    font-size: 2.25rem;
}

.text-center {
    text-align: center;
}

.font-medium {
    font-weight: 500;
}

.font-semibold {
    font-weight: 600;
}

.font-bold {
    font-weight: 700;
}

.leading-relaxed {
    line-height: 1.625;
}

.whitespace-pre-wrap {
    white-space: pre-wrap;
}

.break-words {
    word-wrap: break-word;
    overflow-wrap: break-word;
}

.truncate {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Colors */
.text-gray-300 {
    color: #d1d5db;
}

.text-gray-400 {
    color: #9ca3af;
}

.text-gray-500 {
    color: #6b7280;
}

.text-gray-600 {
    color: #4b5563;
}

.text-gray-800 {
    color: #1f2937;
}

.text-gray-900 {
    color: #111827;
}

.text-red-300 {
    color: #fca5a5;
}

.text-red-500 {
    color: #ef4444;
}

.text-green-600 {
    color: #16a34a;
}

.text-purple-500 {
    color: #8b5cf6;
}

.text-orange-500 {
    color: #f97316;
}

.text-white {
    color: white;
}

/* Background */
.bg-gray-50 {
    background-color: #f9fafb;
}

.bg-gray-100 {
    background-color: #f3f4f6;
}

.bg-white {
    background-color: white;
}

.bg-gradient-to-br {
    background-image: linear-gradient(to bottom right, var(--tw-gradient-stops));
}

.from-purple-600 {
    --tw-gradient-from: #9333ea;
    --tw-gradient-stops: var(--tw-gradient-from), var(--tw-gradient-to, transparent);
}

.to-purple-500 {
    --tw-gradient-to: #a855f7;
}

.from-blue-600 {
    --tw-gradient-from: #2563eb;
    --tw-gradient-stops: var(--tw-gradient-from), var(--tw-gradient-to, transparent);
}

.to-blue-500 {
    --tw-gradient-to: #3b82f6;
}

/* Border */
.border {
    border-width: 1px;
}

.border-t {
    border-top-width: 1px;
}

.border-gray-100 {
    border-color: #f3f4f6;
}

.border-gray-200 {
    border-color: #e5e7eb;
}

/* Transition */
.transition {
    transition: all 0.2s ease;
}

/* Shadow */
.shadow-sm {
    box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
}

/* Display */
.block {
    display: block;
}

.hidden {
    display: none;
}

/* Spinner */
.spinner {
    width: 32px;
    height: 32px;
    border: 3px solid #e5e7eb;
    border-top-color: #ff4500;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

@keyframes btnPop {
    0% { transform: scale(1); }
    45% { transform: scale(1.12); }
    100% { transform: scale(1); }
}

.btn-pop {
    animation: btnPop 180ms ease-out;
}
