/* ==========================================================================
   Connect Portal Design System - Variables & Base
   ========================================================================== */

:root {
  /* Brand Colors (Based on corporate blue) */
  --brand-blue: #006eb2; /* Corporate Blue */
  --brand-blue-hover: #005a96;
  --brand-blue-light: #e6f3fb;
  
  /* Neutral Colors */
  --bg-main: #f5f7fa; /* Clean light gray for SaaS backgrounds */
  --bg-card: #ffffff;
  --text-main: #2d3748;
  --text-muted: #718096;
  --border-light: #e2e8f0;
  
  /* Semantic Colors */
  --success: #38a169;
  --warning: #dd6b20;
  --danger: #e53e3e;
  
  /* Typography */
  --font-family: 'Inter', 'Noto Sans JP', sans-serif;
  
  /* Spacing & Sizes */
  --sidebar-width: 250px;
  --header-height: 60px;
  --radius-sm: 4px;
  --radius-md: 8px;
  --radius-lg: 12px;
  
  /* Shadows */
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.05);
  --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.05), 0 2px 4px -1px rgba(0,0,0,0.03);
  --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.05), 0 4px 6px -2px rgba(0,0,0,0.02);
  
  /* Transitions */
  --transition-fast: 0.15s ease-in-out;
  --transition-normal: 0.3s ease-in-out;
}

/* ==========================================================================
   Reset & Global Styles
   ========================================================================== */

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

body {
  font-family: var(--font-family);
  background-color: var(--bg-main);
  color: var(--text-main);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

a {
  color: var(--brand-blue);
  text-decoration: none;
  transition: color var(--transition-fast);
}

a:hover {
  color: var(--brand-blue-hover);
}

button {
  cursor: pointer;
  font-family: inherit;
  border: none;
  background: none;
}

/* ==========================================================================
   Layout (Sidebar + Main Content)
   ========================================================================== */

.layout {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

.sidebar {
  width: var(--sidebar-width);
  background-color: var(--bg-card);
  border-right: 1px solid var(--border-light);
  display: flex;
  flex-direction: column;
  transition: transform var(--transition-normal);
  z-index: 10;
}

.sidebar-header {
  height: var(--header-height);
  display: flex;
  align-items: center;
  padding: 0 1.5rem;
  border-bottom: 1px solid var(--border-light);
  font-weight: 700;
  font-size: 1.25rem;
  color: var(--brand-blue);
  letter-spacing: -0.5px;
}

.sidebar-nav {
  padding: 1.5rem 1rem;
  flex: 1;
  overflow-y: auto;
}

.nav-item {
  display: flex;
  align-items: center;
  padding: 0.75rem 1rem;
  color: var(--text-muted);
  border-radius: var(--radius-md);
  margin-bottom: 0.5rem;
  transition: all var(--transition-fast);
  font-weight: 500;
}

.nav-item i {
  margin-right: 0.75rem;
  font-size: 1.1rem;
}

.nav-item:hover, .nav-item.active {
  background-color: var(--brand-blue-light);
  color: var(--brand-blue);
}

.main-wrapper {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.topbar {
  height: var(--header-height);
  background-color: var(--bg-card);
  border-bottom: 1px solid var(--border-light);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 2rem;
  z-index: 5;
}

.user-profile {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-weight: 500;
  color: var(--text-main);
}

.avatar {
  width: 36px;
  height: 36px;
  background-color: var(--brand-blue);
  color: white;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: bold;
}

.content-area {
  flex: 1;
  padding: 2rem;
  overflow-y: auto;
}

/* ==========================================================================
   Components (SaaS Elements)
   ========================================================================== */

/* Cards */
.card {
  background-color: var(--bg-card);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border-light);
  padding: 1.5rem;
  margin-bottom: 1.5rem;
  transition: box-shadow var(--transition-normal), transform var(--transition-normal);
}

.card:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}

.card-title {
  font-size: 1.1rem;
  font-weight: 600;
  margin-bottom: 1rem;
  color: var(--text-main);
  border-bottom: 1px solid var(--border-light);
  padding-bottom: 0.75rem;
}

/* Utilities */
.text-muted { color: var(--text-muted); }
.text-h1 { font-size: 1.75rem; font-weight: 700; margin-bottom: 0.5rem; }
.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
.mb-4 { margin-bottom: 2rem; }

/* Grid Dashboard */
.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 1.5rem;
}

/* Micro animations for portal apps */
.app-widget {
  cursor: pointer;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  height: 100%;
}

.app-widget i {
  font-size: 2rem;
  color: var(--brand-blue);
  margin-bottom: 1rem;
}

.app-widget h3 {
  font-size: 1.25rem;
  margin-bottom: 0.5rem;
}

/* Page transitions */
.page {
  animation: fadeIn 0.3s ease-in-out;
  display: none !important; /* Hidden by default, JS will show 'active' */
}

.page.active {
  display: block !important;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ==========================================================================
   Login Overlay
   ========================================================================== */
.login-overlay {
  position: fixed;
  inset: 0;
  background: rgba(45, 55, 72, 0.95);
  backdrop-filter: blur(10px);
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
}

.login-overlay.hidden {
  display: none;
}

.login-card {
  background: #fff;
  padding: 3rem;
  border-radius: 24px;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
  max-width: 400px;
  width: 100%;
  text-align: center;
  animation: modalScaleUp 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes modalScaleUp {
  from { opacity: 0; transform: scale(0.9); }
  to { opacity: 1; transform: scale(1); }
}

.login-header {
  margin-bottom: 2rem;
}

.login-header h2 {
  margin-top: 1rem;
  font-size: 1.5rem;
  color: var(--brand-blue);
  font-weight: 700;
}

.login-card p {
  color: var(--text-muted);
  margin-bottom: 2.5rem;
  font-size: 1rem;
}

.g_id_signin {
  display: flex;
  justify-content: center;
}

.btn-demo-login {
  background-color: var(--brand-blue-light);
  color: var(--brand-blue);
  padding: 0.75rem 1.5rem;
  border-radius: var(--radius-md);
  font-weight: 600;
  font-size: 0.95rem;
  width: 100%;
  transition: all var(--transition-fast);
  border: 1px solid var(--brand-blue);
}

.btn-demo-login:hover {
  background-color: var(--brand-blue);
  color: #fff;
}

/* ==========================================================================
   Responsive Styles (High Specificity Fix)
   ========================================================================== */

/* ハンバーガーメニューボタン (デフォルト非表示) */
body .sidebar-toggle {
  display: none;
  font-size: 1.25rem;
  color: var(--text-main);
  padding: 0.5rem;
  margin-right: 0.75rem;
  border-radius: var(--radius-sm);
  transition: background var(--transition-fast);
  background: transparent;
  z-index: 300;
}

body .sidebar-toggle:hover {
  background: var(--brand-blue-light);
}

/* サイドバーオーバーレイ */
body .sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.5);
  backdrop-filter: blur(4px);
  z-index: 150;
  animation: fadeIn 0.2s ease;
}

/* モバイル表示 (900px以下) */
@media (max-width: 900px) {
  body .sidebar-toggle {
    display: block; /* 確実に出現させる */
  }

  body .layout {
    display: block !important; /* Flexを強制解除 */
    height: auto !important;
    overflow: visible !important;
  }

  body .sidebar {
    position: fixed !important;
    top: 0;
    left: -250px !important; /* 強制的に隠す */
    bottom: 0;
    width: 250px !important;
    z-index: 500 !important;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1) !important;
    box-shadow: 20px 0 50px rgba(0,0,0,0.15);
    background: #fff !important;
    transform: none !important;
  }

  /* サイドバーが開いている時の状態 */
  body .sidebar-open .sidebar {
    transform: translateX(250px) !important; /* スライドイン */
  }

  body .sidebar-open .sidebar-overlay {
    display: block !important;
  }

  body .main-wrapper {
    width: 100% !important;
    min-width: 100% !important;
    margin-left: 0 !important;
    height: 100vh;
    display: flex;
    flex-direction: column;
  }

  body .topbar {
    padding: 0 1rem !important;
    justify-content: flex-start !important; /* 左寄せにして重なり防止 */
    gap: 1rem;
  }

  body .page-title.text-h1 {
    font-size: 1.1rem !important;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  body .user-profile {
    margin-left: auto; /* プロフィールを右端へ */
  }

  body .user-profile .text-muted {
    display: none;
  }

  body .content-area {
    padding: 1rem !important;
    -webkit-overflow-scrolling: touch;
  }
}

@media (max-width: 480px) {
  body .topbar {
    gap: 0.5rem;
  }
}
