/* =========================================================
   CreatorNexus - Complete Design System
   Twitter/X Inspired + iOS Flavor
   ========================================================= */

/* ========== CSS Variables ========== */
:root {
  /* Colors */
  --ios-blue: #1D9BF0;
  --ios-blue-hover: #1A8CD8;
  --ios-red: #FF3B30;
  --ios-green: #34C759;
  --ios-orange: #FF9500;
  --ios-purple: #AF52DE;
  --ios-pink: #FF2D55;

  /* Light Mode */
  --ios-bg: #F2F2F7;
  --ios-bg-secondary: #FFFFFF;
  --ios-bg-tertiary: #E5E5EA;
  --ios-text: #000000;
  --ios-text-secondary: #8E8E93;
  --ios-text-tertiary: #AEAEB2;
  --ios-border: #D1D1D6;
  --ios-separator: #E5E5EA;
  --ios-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
  --ios-shadow-md: 0 4px 20px rgba(0, 0, 0, 0.08);
  --ios-shadow-lg: 0 8px 40px rgba(0, 0, 0, 0.12);

  /* Radius */
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 20px;
  --radius-full: 9999px;

  /* Font */
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro Text", "Helvetica Neue", Arial, sans-serif;

  /* Spacing */
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --space-8: 32px;
  --space-10: 40px;
  --space-12: 48px;

  /* Header */
  --header-height: 56px;
}

/* ========== Dark Mode ========== */
@media (prefers-color-scheme: dark) {
  :root {
    --ios-bg: #000000;
    --ios-bg-secondary: #1C1C1E;
    --ios-bg-tertiary: #2C2C2E;
    --ios-text: #FFFFFF;
    --ios-text-secondary: #8E8E93;
    --ios-text-tertiary: #636366;
    --ios-border: #38383A;
    --ios-separator: #38383A;
    --ios-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
    --ios-shadow-md: 0 4px 20px rgba(0, 0, 0, 0.4);
    --ios-shadow-lg: 0 8px 40px rgba(0, 0, 0, 0.5);
  }
}

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

body {
  font-family: var(--font);
  background: var(--ios-bg);
  color: var(--ios-text);
  line-height: 1.5;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

a {
  text-decoration: none;
  color: var(--ios-blue);
}

img {
  max-width: 100%;
  display: block;
}

/* ========== Scrollbar ========== */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: var(--ios-text-tertiary);
  border-radius: var(--radius-full);
}
::-webkit-scrollbar-thumb:hover {
  background: var(--ios-text-secondary);
}

/* =========================================================
   TOP HEADER
   ========================================================= */
.top-header {
  position: sticky;
  top: 0;
  z-index: 1000;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(30px);
  -webkit-backdrop-filter: blur(30px);
  border-bottom: 0.5px solid var(--ios-separator);
  height: var(--header-height);
}

@media (prefers-color-scheme: dark) {
  .top-header {
    background: rgba(0, 0, 0, 0.92);
  }
}

.header-inner {
  max-width: 1280px;
  margin: 0 auto;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 var(--space-4);
  gap: var(--space-4);
}

/* Left */
.header-left {
  flex-shrink: 0;
}

.logo {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-weight: 700;
  font-size: 18px;
  color: var(--ios-text);
}

.logo i {
  font-size: 24px;
  color: var(--ios-blue);
}

/* Center - Search */
.header-center {
  flex: 1;
  max-width: 480px;
}

.search-form {
  width: 100%;
}

.search-input-wrap {
  display: flex;
  align-items: center;
  background: var(--ios-bg-tertiary);
  border-radius: var(--radius-full);
  padding: 8px var(--space-4);
  gap: var(--space-2);
  transition: all 0.2s ease;
}

.search-input-wrap:focus-within {
  background: var(--ios-bg-secondary);
  box-shadow: 0 0 0 2px var(--ios-blue);
}

.search-input-wrap i {
  color: var(--ios-text-secondary);
  font-size: 14px;
}

.search-input-wrap input {
  border: none;
  background: transparent;
  outline: none;
  width: 100%;
  font-size: 14px;
  color: var(--ios-text);
}

.search-input-wrap input::placeholder {
  color: var(--ios-text-secondary);
}

/* Right */
.header-right {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  flex-shrink: 0;
}

.header-icon-btn {
  width: 36px;
  height: 36px;
  border: none;
  background: transparent;
  border-radius: var(--radius-full);
  color: var(--ios-text-secondary);
  font-size: 18px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
}

.header-icon-btn:hover {
  background: var(--ios-bg-tertiary);
  color: var(--ios-text);
}

.header-btn {
  padding: 8px 18px;
  border-radius: var(--radius-full);
  font-weight: 600;
  font-size: 14px;
  border: none;
  cursor: pointer;
  transition: all 0.2s ease;
  font-family: inherit;
  color: var(--ios-text);
  background: transparent;
}

.header-btn:hover {
  background: var(--ios-bg-tertiary);
}

.header-btn.primary {
  background: var(--ios-blue);
  color: #FFFFFF;
}

.header-btn.primary:hover {
  background: var(--ios-blue-hover);
}

/* User Menu */
.header-user-menu {
  position: relative;
}

.header-user-btn {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: 4px 8px 4px 4px;
  border: none;
  background: transparent;
  border-radius: var(--radius-full);
  cursor: pointer;
  transition: all 0.2s ease;
  font-family: inherit;
}

.header-user-btn:hover {
  background: var(--ios-bg-tertiary);
}

.header-avatar {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-full);
  object-fit: cover;
}

.header-avatar.placeholder {
  background: var(--ios-bg-tertiary);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--ios-text-secondary);
  font-size: 14px;
}

.header-dropdown {
  display: none;
  position: absolute;
  right: 0;
  top: calc(100% + 8px);
  min-width: 220px;
  background: var(--ios-bg-secondary);
  border-radius: var(--radius-lg);
  box-shadow: var(--ios-shadow-lg);
  border: 0.5px solid var(--ios-separator);
  padding: 8px 0;
  z-index: 1001;
}

.header-dropdown.open {
  display: block;
}

.dropdown-item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: 10px var(--space-4);
  color: var(--ios-text);
  font-size: 14px;
  font-weight: 500;
  transition: all 0.15s ease;
  cursor: pointer;
}

.dropdown-item:hover {
  background: var(--ios-bg-tertiary);
}

.dropdown-item i {
  width: 20px;
  text-align: center;
  color: var(--ios-text-secondary);
}

.dropdown-item.text-danger {
  color: var(--ios-red);
}
.dropdown-item.text-danger i {
  color: var(--ios-red);
}

.dropdown-divider {
  border: none;
  border-top: 0.5px solid var(--ios-separator);
  margin: 4px 12px;
}

/* =========================================================
   APP SHELL
   ========================================================= */
.app-shell {
  display: block;
  width: 100%;
  max-width: 1280px;
  margin: 0 auto;
  padding: 0 var(--space-4);
}

/* =========================================================
   PC SIDEBAR - Twitter/X Inspired
   ========================================================= */
.pc-sidebar {
  display: none;
  position: sticky;
  top: calc(var(--header-height) + 8px);
  height: calc(100vh - var(--header-height) - 16px);
  padding: 0 8px;
  overflow-y: auto;
  flex-shrink: 0;
  scrollbar-width: thin;
}

.pc-sidebar::-webkit-scrollbar {
  width: 4px;
}
.pc-sidebar::-webkit-scrollbar-thumb {
  background: var(--ios-text-tertiary);
  border-radius: var(--radius-full);
}

/* Sidebar Logo */
.pc-side-logo {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: 16px 14px 20px;
  font-weight: 700;
  font-size: 20px;
  color: var(--ios-text);
  text-decoration: none;
  transition: opacity 0.2s ease;
}

.pc-side-logo:hover {
  opacity: 0.8;
}
.pc-side-logo i {
  font-size: 28px;
  color: var(--ios-blue);
}

/* Navigation */
.pc-sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.pc-side-item {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  padding: 12px 14px;
  border-radius: var(--radius-full);
  color: var(--ios-text);
  font-weight: 500;
  font-size: 17px;
  text-decoration: none;
  transition: all 0.15s ease;
  cursor: pointer;
  border: none;
  background: transparent;
  font-family: inherit;
  width: 100%;
}

.pc-side-item i {
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  color: var(--ios-text);
  flex-shrink: 0;
}

.pc-side-item span {
  white-space: nowrap;
}

.pc-side-item:hover {
  background: rgba(0, 0, 0, 0.05);
}

@media (prefers-color-scheme: dark) {
  .pc-side-item:hover {
    background: rgba(255, 255, 255, 0.08);
  }
}

.pc-side-item.active {
  font-weight: 700;
}
.pc-side-item.active i {
  color: var(--ios-blue);
}

/* Post Button */
.pc-side-post-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  margin-top: var(--space-4);
  padding: 14px 20px;
  border: none;
  border-radius: var(--radius-full);
  background: var(--ios-blue);
  color: #FFFFFF;
  font-weight: 700;
  font-size: 16px;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.2s ease;
  width: 100%;
}

.pc-side-post-btn:hover {
  background: var(--ios-blue-hover);
  transform: scale(0.98);
}
.pc-side-post-btn i {
  font-size: 18px;
}

/* User Profile */
.pc-side-user {
  margin-top: auto;
  padding: 8px 0 var(--space-4);
  border-top: 0.5px solid var(--ios-separator);
}

.pc-side-user-link {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: 10px 14px;
  border-radius: var(--radius-full);
  text-decoration: none;
  color: var(--ios-text);
  transition: all 0.15s ease;
  cursor: pointer;
}

.pc-side-user-link:hover {
  background: rgba(0, 0, 0, 0.05);
}

@media (prefers-color-scheme: dark) {
  .pc-side-user-link:hover {
    background: rgba(255, 255, 255, 0.08);
  }
}

.pc-side-user-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
  background: var(--ios-bg-tertiary);
}

.pc-side-user-avatar.placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--ios-text-secondary);
  font-size: 18px;
}

.pc-side-user-meta {
  flex: 1;
  min-width: 0;
}

.pc-side-user-name {
  display: flex;
  align-items: center;
  gap: var(--space-1);
  font-weight: 700;
  font-size: 14px;
  color: var(--ios-text);
}

.pc-side-user-handle {
  font-size: 13px;
  color: var(--ios-text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.pc-side-user-more {
  color: var(--ios-text-secondary);
  font-size: 16px;
  padding: var(--space-1);
}

/* =========================================================
   MAIN CONTENT
   ========================================================= */
.main-content {
  padding: var(--space-4) 0 var(--space-8);
  min-height: calc(100vh - var(--header-height));
}

/* =========================================================
   FEED
   ========================================================= */
.feed {
  max-width: 680px;
  margin: 0 auto;
  width: 100%;
}

/* =========================================================
   RESPONSIVE
   ========================================================= */

/* Tablet: Show sidebar but smaller */
@media (min-width: 1024px) {
  .app-shell {
    display: flex;
    padding: 0 var(--space-4);
    gap: var(--space-4);
  }

  .pc-sidebar {
    display: flex;
    flex-direction: column;
    width: 220px;
  }

  .main-content {
    flex: 1;
    min-width: 0;
    padding: var(--space-4) 0 var(--space-8);
  }

  .feed {
    max-width: 100%;
    padding: 0 4px;
  }
}

@media (min-width: 1280px) {
  .app-shell {
    padding: 0 var(--space-6);
    gap: var(--space-6);
  }

  .pc-sidebar {
    width: 260px;
    padding: 0 12px;
  }

  .feed {
    max-width: 720px;
    margin: 0 auto;
  }
}

/* Mobile: Hide sidebar, show bottom nav */
@media (max-width: 1023px) {
  .pc-sidebar {
    display: none !important;
  }

  .app-shell {
    padding: 0;
  }

  .main-content {
    padding: var(--space-2) 0 calc(60px + var(--space-4));
  }

  .feed {
    padding: 0 var(--space-2);
  }
}

/* Hide search on mobile */
@media (max-width: 767px) {
  .header-center {
    display: none;
  }
  .logo span {
    display: none;
  }
  .header-right .header-btn:not(.primary) {
    display: none;
  }
}

/* =========================================================
   BOTTOM NAV (Mobile)
   ========================================================= */
.bottom-nav {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: 60px;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(30px);
  -webkit-backdrop-filter: blur(30px);
  border-top: 0.5px solid var(--ios-separator);
  z-index: 1000;
  padding-bottom: env(safe-area-inset-bottom);
}

@media (prefers-color-scheme: dark) {
  .bottom-nav {
    background: rgba(0, 0, 0, 0.92);
  }
}

@media (max-width: 1023px) {
  .bottom-nav {
    display: flex;
    justify-content: space-around;
    align-items: center;
  }
}

.nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  flex: 1;
  height: 100%;
  color: var(--ios-text-secondary);
  font-size: 11px;
  transition: all 0.2s ease;
  cursor: pointer;
  border: none;
  background: transparent;
  font-family: inherit;
}

.nav-item i {
  font-size: 20px;
  transition: all 0.2s ease;
}

.nav-item.active {
  color: var(--ios-blue);
}

.nav-item:hover {
  color: var(--ios-blue);
}

.nav-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  object-fit: cover;
}

/* =========================================================
   VERIFIED BADGE
   ========================================================= */
.verified-badge {
  display: inline-block !important;
  vertical-align: middle !important;
  margin-left: 2px;
  flex-shrink: 0 !important;
  width: 16px !important;
  height: 16px !important;
  max-width: 16px !important;
  max-height: 16px !important;
  object-fit: contain !important;
}

/* =========================================================
   PROFILE PAGE
   ========================================================= */

.profile-header {
    background: var(--ios-bg-secondary);
    border-radius: var(--radius-lg);
    box-shadow: var(--ios-shadow);
    overflow: hidden;
    margin-bottom: var(--space-4);
}

.profile-cover {
    position: relative;
    width: 100%;
    height: 120px;
    background: var(--ios-bg-tertiary);
    overflow: hidden;
}

.profile-cover img,
.profile-cover .profile-cover-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.profile-cover-fallback {
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, var(--ios-blue) 0%, var(--ios-purple) 100%);
}

/* Profile Info */
.profile-info {
    padding: 0 var(--space-4) var(--space-4);
    background: var(--ios-bg-secondary);
    position: relative;
}

.profile-avatar-wrap {
    margin-top: -40px;
    margin-bottom: var(--space-2);
    position: relative;
    z-index: 5;
    line-height: 0;
}

.profile-avatar {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    border: 4px solid var(--ios-bg-secondary);
    background: var(--ios-bg-tertiary);
    object-fit: cover;
    display: block;
    box-shadow: var(--ios-shadow-md);
}

.profile-name-row {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    flex-wrap: wrap;
}

.profile-name {
    font-size: 22px;
    font-weight: 700;
    color: var(--ios-text);
}

.profile-username {
    color: var(--ios-text-secondary);
    font-size: 15px;
    margin-bottom: var(--space-2);
}

.profile-bio {
    font-size: 15px;
    margin: var(--space-2) 0 var(--space-3);
    white-space: pre-wrap;
    word-break: break-word;
    color: var(--ios-text);
}

/* Profile Stats */
.profile-stats {
    display: flex;
    gap: var(--space-5);
    font-size: 15px;
    color: var(--ios-text-secondary);
}

.profile-stats strong {
    font-weight: 700;
    color: var(--ios-text);
}

.profile-stats a {
    color: var(--ios-text-secondary);
    text-decoration: none;
    transition: color 0.15s ease;
}

.profile-stats a:hover {
    color: var(--ios-text);
}

/* Profile Actions */
.profile-actions {
    margin-top: var(--space-4);
    display: flex;
    gap: var(--space-2);
    flex-wrap: wrap;
}

.profile-actions .btn {
    padding: var(--space-2) var(--space-5);
    font-size: 14px;
}

/* Profile Tabs */
.profile-tabs {
    display: flex;
    gap: 0;
    border-bottom: 0.5px solid var(--ios-separator);
    margin-bottom: var(--space-4);
    background: var(--ios-bg-secondary);
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    overflow: hidden;
}

.profile-tab {
    flex: 1;
    padding: var(--space-3) var(--space-4);
    border: none;
    background: transparent;
    color: var(--ios-text-secondary);
    font-weight: 600;
    font-size: 14px;
    font-family: inherit;
    cursor: pointer;
    transition: all 0.2s ease;
    position: relative;
    text-align: center;
}

.profile-tab:hover {
    color: var(--ios-text);
}

.profile-tab.active {
    color: var(--ios-text);
}

.profile-tab.active::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 30%;
    right: 30%;
    height: 3px;
    background: var(--ios-blue);
    border-radius: var(--radius-full);
}

/* Profile Posts */
.profile-posts {
    margin-top: var(--space-2);
}

/* Edit Profile Button */
.profile-edit-btn {
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
    padding: 8px 20px;
    border: 1px solid var(--ios-border);
    border-radius: var(--radius-full);
    background: transparent;
    color: var(--ios-text);
    font-weight: 600;
    font-size: 14px;
    font-family: inherit;
    cursor: pointer;
    transition: all 0.2s ease;
}

.profile-edit-btn:hover {
    background: var(--ios-bg-tertiary);
}

/* Follow Button */
.profile-follow-btn {
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
    padding: 8px 24px;
    border: none;
    border-radius: var(--radius-full);
    background: var(--ios-blue);
    color: #FFFFFF;
    font-weight: 700;
    font-size: 14px;
    font-family: inherit;
    cursor: pointer;
    transition: all 0.2s ease;
}

.profile-follow-btn:hover {
    background: var(--ios-blue-hover);
}

.profile-follow-btn.following {
    background: var(--ios-bg-tertiary);
    color: var(--ios-text);
}

.profile-follow-btn.following:hover {
    background: rgba(255, 59, 48, 0.1);
    color: var(--ios-red);
}

/* ========== Profile Page Responsive ========== */
@media (min-width: 900px) {
    .profile-cover {
        height: 200px;
    }

    .profile-avatar-wrap {
        margin-top: -50px;
    }

    .profile-avatar {
        width: 100px;
        height: 100px;
        border-width: 4px;
    }

    .profile-info {
        padding: 0 var(--space-6) var(--space-5);
    }

    .profile-name {
        font-size: 26px;
    }

    .profile-tabs {
        border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    }
}

@media (max-width: 767px) {
    .profile-cover {
        height: 80px;
    }

    .profile-avatar {
        width: 64px;
        height: 64px;
    }

    .profile-avatar-wrap {
        margin-top: -32px;
    }

    .profile-name {
        font-size: 18px;
    }

    .profile-stats {
        gap: var(--space-3);
        font-size: 13px;
    }

    .profile-actions .btn {
        font-size: 13px;
        padding: var(--space-1) var(--space-4);
    }

    .profile-tab {
        font-size: 13px;
        padding: var(--space-2) var(--space-3);
    }
}

/* Profile page feed override */
.profile-page-wrap .feed {
    max-width: 100% !important;
    padding: 0 !important;
}

.profile-page-wrap .post-card {
    border: 0.5px solid var(--ios-separator);
    border-radius: var(--radius-lg);
    margin-bottom: var(--space-3);
}

@media (min-width: 1024px) {
    .profile-page-wrap .feed {
        max-width: 100% !important;
    }
}

/* =========================================================
   UTILITIES
   ========================================================= */
.text-center { text-align: center; }
.hidden { display: none !important; }
.mt-2 { margin-top: var(--space-2); }
.mt-3 { margin-top: var(--space-3); }
.mt-4 { margin-top: var(--space-4); }
.mb-3 { margin-bottom: var(--space-3); }
.mb-4 { margin-bottom: var(--space-4); }

/* =========================================================
   THEME OVERRIDE (手動切替対応)
   ========================================================= */

/* data-theme="dark" で強制ダーク */
html[data-theme="dark"] {
    --ios-bg: #000000;
    --ios-bg-secondary: #1C1C1E;
    --ios-bg-tertiary: #2C2C2E;
    --ios-text: #FFFFFF;
    --ios-text-secondary: #8E8E93;
    --ios-text-tertiary: #636366;
    --ios-border: #38383A;
    --ios-separator: #38383A;
    --ios-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
    --ios-shadow-md: 0 4px 20px rgba(0, 0, 0, 0.4);
    --ios-shadow-lg: 0 8px 40px rgba(0, 0, 0, 0.5);
    color-scheme: dark;
}

/* data-theme="light" で強制ライト */
html[data-theme="light"] {
    --ios-bg: #F2F2F7;
    --ios-bg-secondary: #FFFFFF;
    --ios-bg-tertiary: #E5E5EA;
    --ios-text: #000000;
    --ios-text-secondary: #8E8E93;
    --ios-text-tertiary: #AEAEB2;
    --ios-border: #D1D1D6;
    --ios-separator: #E5E5EA;
    color-scheme: light;
}