/* ==========================================================================
   Document Hub — Main CSS Styles
   Modern SaaS Dashboard UI, Light & Dark friendly, Mobile Responsive
   ========================================================================== */

:root {
  --font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  
  /* Primary & Brand Colors */
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --primary-subtle: #eff6ff;
  --primary-border: #bfdbfe;
  
  /* Workspace Types */
  --color-docs: #1a73e8;
  --color-docs-subtle: #e8f0fe;
  --color-sheets: #0f9d58;
  --color-sheets-subtle: #e6f4ea;
  --color-slides: #f4b400;
  --color-slides-subtle: #fef7e0;
  
  /* Semantics */
  --success: #10b981;
  --success-subtle: #ecfdf5;
  --warning: #f59e0b;
  --warning-subtle: #fffbeb;
  --danger: #ef4444;
  --danger-hover: #dc2626;
  --danger-subtle: #fef2f2;
  
  /* Neutrals */
  --bg-page: #f8fafc;
  --bg-surface: #ffffff;
  --bg-sidebar: #ffffff;
  --bg-subtle: #f1f5f9;
  --bg-hover: #f1f5f9;
  
  --text-main: #0f172a;
  --text-secondary: #475569;
  --text-muted: #64748b;
  --text-inverse: #ffffff;
  
  --border-color: #e2e8f0;
  --border-focus: #3b82f6;
  
  /* Shadows */
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.08), 0 2px 4px -1px rgba(0, 0, 0, 0.04);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
  --shadow-modal: 0 20px 25px -5px rgba(0, 0, 0, 0.15), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
  
  /* Radii & Sizes */
  --radius-sm: 6px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --radius-full: 9999px;
  
  --sidebar-width: 260px;
  --topbar-height: 64px;
  --transition-fast: 0.15s ease;
  --transition-normal: 0.2s ease;
}

/* Reset cơ bản */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  height: 100%;
  font-family: var(--font-family);
  font-size: 14px;
  line-height: 1.5;
  color: var(--text-main);
  background-color: var(--bg-page);
  -webkit-font-smoothing: antialiased;
}

a {
  color: var(--primary);
  text-decoration: none;
}
a:hover {
  text-decoration: underline;
}

button, input, select, textarea {
  font: inherit;
  color: inherit;
}

ul, ol {
  list-style: none;
}

/* Tiện ích ẩn hiện */
.hidden {
  display: none !important;
}

.text-muted { color: var(--text-muted); }
.text-danger { color: var(--danger); }
.text-warning { color: var(--warning); }
.text-docs { color: var(--color-docs); }
.text-sheets { color: var(--color-sheets); }
.text-slides { color: var(--color-slides); }
.text-fav { color: #eab308; }
.font-mono { font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace; }

/* Layout gốc */
.app-root {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.view {
  width: 100%;
  min-height: 100vh;
}

/* ==========================================================================
   1. Màn hình Chưa Đăng Nhập (Login View)
   ========================================================================== */
.login-view {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: radial-gradient(circle at 50% 20%, #eff6ff 0%, #f8fafc 100%);
}

.login-container {
  max-width: 720px;
  width: 100%;
}

.login-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 40px 32px;
  box-shadow: var(--shadow-lg);
  text-align: center;
  margin-bottom: 32px;
}

.brand-logo {
  display: inline-flex;
  margin-bottom: 16px;
}

.brand-title {
  font-size: 28px;
  font-weight: 700;
  color: var(--text-main);
  margin-bottom: 8px;
  letter-spacing: -0.02em;
}

.brand-subtitle {
  font-size: 15px;
  color: var(--text-secondary);
  max-width: 480px;
  margin: 0 auto 24px auto;
}

.login-actions {
  display: flex;
  justify-content: center;
  margin-bottom: 24px;
}

.btn-google {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  background: #ffffff;
  color: #3c4043;
  border: 1px solid #dadce0;
  border-radius: var(--radius-sm);
  padding: 12px 24px;
  font-size: 15px;
  font-weight: 500;
  box-shadow: var(--shadow-sm);
  transition: all var(--transition-fast);
  cursor: pointer;
  text-decoration: none;
}
.btn-google:hover {
  background: #f8fafc;
  border-color: #c2c7d0;
  box-shadow: var(--shadow-md);
  text-decoration: none;
}

.login-footer {
  border-top: 1px solid var(--border-color);
  padding-top: 20px;
  margin-top: 12px;
}

.security-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  font-weight: 600;
  color: var(--primary);
  background: var(--primary-subtle);
  padding: 4px 12px;
  border-radius: var(--radius-full);
  margin-bottom: 10px;
}

.security-note {
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.6;
}
.security-note code {
  background: var(--bg-subtle);
  padding: 2px 5px;
  border-radius: 4px;
  font-family: ui-monospace, monospace;
}

.features-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
}

.feature-item {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 20px;
  text-align: left;
  box-shadow: var(--shadow-sm);
}

.feature-icon {
  font-size: 24px;
  margin-bottom: 12px;
}

.feature-item h3 {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-main);
  margin-bottom: 6px;
}

.feature-item p {
  font-size: 12px;
  color: var(--text-secondary);
  line-height: 1.5;
}

@media (max-width: 640px) {
  .features-grid {
    grid-template-columns: 1fr;
  }
  .login-card {
    padding: 32px 20px;
  }
}

/* ==========================================================================
   2. Layout Chính Sau Đăng Nhập (Main View / Dashboard)
   ========================================================================== */
.main-view {
  display: flex;
  background-color: var(--bg-page);
  min-height: 100vh;
}

/* Sidebar */
.sidebar {
  width: var(--sidebar-width);
  background-color: var(--bg-sidebar);
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  bottom: 0;
  left: 0;
  z-index: 40;
  transition: transform var(--transition-normal);
}

.sidebar-header {
  height: var(--topbar-height);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  border-bottom: 1px solid var(--border-color);
}

.brand-compact {
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand-name {
  font-size: 16px;
  font-weight: 700;
  color: var(--text-main);
  letter-spacing: -0.01em;
}

.mobile-close-sidebar {
  display: none;
}

.sidebar-actions {
  padding: 16px;
}

.btn-create {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 42px;
  font-weight: 600;
  box-shadow: 0 2px 4px rgba(37, 99, 235, 0.2);
}

.btn-icon-plus {
  font-size: 18px;
  line-height: 1;
}

/* Navigation */
.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  padding: 8px 12px;
}

.nav-section-title {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  color: var(--text-muted);
  letter-spacing: 0.05em;
  padding: 12px 8px 6px 8px;
}

.nav-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-right: 6px;
}

.nav-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-weight: 500;
  transition: all var(--transition-fast);
  text-decoration: none;
}
.nav-item:hover {
  background-color: var(--bg-hover);
  color: var(--text-main);
  text-decoration: none;
}
.nav-item.active {
  background-color: var(--primary-subtle);
  color: var(--primary);
  font-weight: 600;
}

.nav-icon {
  font-size: 16px;
  width: 20px;
  text-align: center;
}

.nav-text {
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.nav-badge {
  font-size: 11px;
  font-weight: 600;
  background-color: var(--bg-subtle);
  color: var(--text-muted);
  padding: 2px 7px;
  border-radius: var(--radius-full);
}
.nav-item.active .nav-badge {
  background-color: #dbeafe;
  color: var(--primary);
}

/* User Card in Sidebar */
.sidebar-user {
  border-top: 1px solid var(--border-color);
  padding: 12px 16px;
  display: flex;
  align-items: center;
  gap: 10px;
  background-color: #fafbfc;
}

.user-avatar {
  width: 34px;
  height: 34px;
  border-radius: var(--radius-full);
  background-color: var(--primary);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 13px;
  overflow: hidden;
  flex-shrink: 0;
}
.user-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.user-info {
  flex: 1;
  min-width: 0;
}

.user-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-main);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-email {
  font-size: 11px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Main Content Area */
.main-content {
  flex: 1;
  margin-left: var(--sidebar-width);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Topbar */
.topbar {
  height: var(--topbar-height);
  background-color: var(--bg-surface);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  position: sticky;
  top: 0;
  z-index: 30;
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 16px;
  flex: 1;
  max-width: 480px;
}

.mobile-menu-btn {
  display: none;
}

.search-box {
  display: flex;
  align-items: center;
  gap: 8px;
  background-color: var(--bg-subtle);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 0 12px;
  height: 38px;
  width: 100%;
  transition: all var(--transition-fast);
}
.search-box:focus-within {
  background-color: var(--bg-surface);
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}

.search-icon {
  color: var(--text-muted);
  font-size: 14px;
}

.search-box input {
  border: none;
  background: transparent;
  width: 100%;
  outline: none;
  font-size: 13px;
}

.search-clear {
  border: none;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  padding: 2px 4px;
  font-size: 12px;
}
.search-clear:hover {
  color: var(--text-main);
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

/* Page Body */
.page-body {
  flex: 1;
  padding: 24px;
  max-width: 1280px;
  width: 100%;
  margin: 0 auto;
}

.page-title {
  font-size: 20px;
  font-weight: 700;
  color: var(--text-main);
  letter-spacing: -0.01em;
}

.section-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-main);
  margin-bottom: 16px;
}

.section-header-flex {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.link-see-all {
  font-size: 13px;
  font-weight: 600;
}

/* Responsive Breakpoints */
@media (max-width: 860px) {
  .sidebar {
    transform: translateX(-100%);
  }
  .sidebar.open {
    transform: translateX(0);
  }
  .main-content {
    margin-left: 0;
  }
  .mobile-menu-btn, .mobile-close-sidebar {
    display: inline-flex;
  }
  .sidebar-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.4);
    z-index: 35;
    display: none;
  }
  .sidebar-backdrop.active {
    display: block;
  }
}
