/* ============================================================
   小米网盘 · 界面样式
   方向：干净的浅色工作台 —— 冷灰底 / 纯白内容卡 / 克制的科技蓝
   策略：只改色彩、圆角、阴影、间距、对齐；不改 DOM 结构、不写死尺寸，
        因此升级 filebrowser 不会错版。
   ============================================================ */

/* ---------- 1. 色彩（浅色） ---------- */
:root {
  --blue: #2f6bff;
  --dark-blue: #1f4fd8;
  --red: #e5484d;
  --dark-red: #c62b30;

  --background: #f4f6fa;
  --surfacePrimary: #ffffff;
  --surfaceSecondary: #eef1f6;
  --moon-grey: #f3f5f9;

  --textPrimary: #5b6779;      /* 次要文字 / 元信息 */
  --textSecondary: #111827;    /* 主要文字 */

  --divider: rgba(17, 24, 39, 0.06);
  --borderPrimary: rgba(17, 24, 39, 0.08);
  --borderSecondary: rgba(17, 24, 39, 0.14);
  --dividerPrimary: rgba(17, 24, 39, 0.30);
  --dividerSecondary: rgba(17, 24, 39, 0.55);

  --item-selected: #edf3ff;
  --hover: rgba(17, 24, 39, 0.045);
  --action: #47566b;

  --iconPrimary: #2f6bff;
  --iconSecondary: #ffffff;

  --np-radius: 14px;
  --np-radius-sm: 8px;
  --np-shadow: 0 1px 2px rgba(17, 24, 39, 0.04), 0 1px 3px rgba(17, 24, 39, 0.06);
  --np-shadow-lg: 0 12px 32px rgba(17, 24, 39, 0.12), 0 2px 8px rgba(17, 24, 39, 0.06);
  --np-ring: 0 0 0 3px rgba(47, 107, 255, 0.14);
}

/* ---------- 2. 色彩（深色） ---------- */
:root.dark {
  --blue: #5b8cff;
  --dark-blue: #3f6fe8;
  --red: #f2555a;
  --dark-red: #d33a3f;

  --background: #0f141c;
  --surfacePrimary: #161d28;
  --surfaceSecondary: #1e2733;
  --moon-grey: #1a222d;

  --textPrimary: #93a1b5;
  --textSecondary: #e9eef7;

  --divider: rgba(255, 255, 255, 0.07);
  --borderPrimary: rgba(255, 255, 255, 0.08);
  --borderSecondary: rgba(255, 255, 255, 0.14);
  --dividerPrimary: rgba(255, 255, 255, 0.26);
  --dividerSecondary: rgba(255, 255, 255, 0.52);

  --item-selected: #1b2740;
  --hover: rgba(255, 255, 255, 0.05);
  --action: #c3cede;

  --iconPrimary: #5b8cff;

  --np-shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 1px 3px rgba(0, 0, 0, 0.24);
  --np-shadow-lg: 0 12px 32px rgba(0, 0, 0, 0.45), 0 2px 8px rgba(0, 0, 0, 0.3);
  --np-ring: 0 0 0 3px rgba(91, 140, 255, 0.22);
}

/* ---------- 3. 字体 ---------- */
body,
button,
input,
select,
textarea,
.button {
  font-family: -apple-system, BlinkMacSystemFont, "MiSans", "HarmonyOS Sans SC",
    "PingFang SC", "Source Han Sans SC", "Noto Sans SC", "Microsoft YaHei",
    Roboto, sans-serif;
}

body {
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  letter-spacing: 0.01em;
}

::selection {
  background: rgba(47, 107, 255, 0.16);
}

/* ---------- 4. 顶栏（filebrowser 顶栏是 <header> 元素） ---------- */
header {
  background: var(--surfacePrimary);
  border-bottom: 1px solid var(--borderPrimary);
}

/* 搜索框：默认是一大块灰底，收成描边胶囊 */
header #input {
  background: var(--surfaceSecondary) !important;
  border: 1px solid transparent;
  border-radius: 10px;
  transition: background 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
}

header #input:hover {
  border-color: var(--borderPrimary);
}

header #input:focus-within {
  background: var(--surfacePrimary) !important;
  border-color: var(--blue);
  box-shadow: var(--np-ring);
}

header #input input {
  background: transparent !important;
}

/* 顶栏右侧动作图标：统一到一个柔和的圆角方块 */
header .action,
header .button {
  border-radius: var(--np-radius-sm);
  transition: background 0.15s ease, color 0.15s ease;
}

header .action:hover,
header .button:hover {
  background: var(--hover);
}

/* ---------- 5. 面包屑 ---------- */
.breadcrumbs {
  background: transparent;
  border-bottom: 1px solid var(--borderPrimary);
}

.breadcrumbs .path-item {
  border-radius: 6px;
  padding: 0.15em 0.4em;
  transition: background 0.15s ease, color 0.15s ease;
}

.breadcrumbs .path-item:hover {
  background: var(--hover);
  color: var(--textSecondary);
}

/* ---------- 6. 文件列表：整块做成一张白色圆角卡 ---------- */
/* 表头那一格（与数据行是两个平级容器） */
#listing > div:nth-of-type(1) {
  border-radius: var(--np-radius) var(--np-radius) 0 0;
}

/* 数据行容器：白卡主体 */
#listing > div:nth-of-type(2) {
  background: var(--surfacePrimary);
  border: 1px solid var(--borderPrimary);
  border-top: 0;
  border-radius: 0 0 var(--np-radius) var(--np-radius);
  box-shadow: var(--np-shadow);
  overflow: hidden;
}

/* 表头行本身：白底 + 顶部圆角 + 细分隔线，与数据卡无缝相接 */
#listing .item.header {
  background: var(--surfacePrimary) !important;
  border: 1px solid var(--borderPrimary) !important;
  border-bottom: 1px solid var(--divider) !important;
  border-radius: var(--np-radius) var(--np-radius) 0 0 !important;
  box-shadow: none !important;
}

#listing .item.header .name,
#listing .item.header .size,
#listing .item.header .modified {
  color: var(--textPrimary) !important;
  font-size: 0.78em;
  font-weight: 600;
  letter-spacing: 0.03em;
}

#listing .item.header .material-icons {
  font-size: 1.05em;
  opacity: 0.55;
}

/* 数据行：背景交给容器卡，行本身透明，只留细线 */
.item:not(.header) {
  background: transparent;
  transition: background 0.12s ease;
}

.item:not(.header):hover {
  background: var(--surfaceSecondary);
}

.item.active,
.item[aria-selected="true"] {
  background: var(--item-selected);
}

.name {
  color: var(--textSecondary);
  font-weight: 500;
}

.size,
.modified {
  color: var(--textPrimary);
}

/* 图标列固定宽度：没有缩略图的文件也不会让整行文字左移 */
@media (min-width: 737px) {
  #listing .item:not(.header) > div:first-child {
    flex: 0 0 auto;
    min-width: 2.6em;
    display: flex;
    align-items: center;
  }
}

/* 网格 / 卡片视图 */
.card {
  background: var(--surfacePrimary);
  border: 1px solid var(--borderPrimary);
  border-radius: var(--np-radius);
  box-shadow: var(--np-shadow);
  transition: box-shadow 0.16s ease, transform 0.16s ease;
}

.card:hover {
  box-shadow: var(--np-shadow-lg);
}

/* ---------- 7. 按钮 ---------- */
.button {
  border-radius: var(--np-radius-sm);
  border: 1px solid var(--borderPrimary);
  box-shadow: none;
  font-weight: 600;
  letter-spacing: 0.02em;
  transition: background 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease,
    transform 0.06s ease;
}

.button:hover {
  box-shadow: var(--np-shadow);
}

.button:active {
  transform: translateY(1px);
}

.button--flat {
  border-color: transparent;
  border-radius: var(--np-radius-sm);
}

.button--flat:hover {
  background: var(--hover);
  box-shadow: none;
}

.button--blue {
  background: var(--blue);
  border-color: var(--blue);
  color: #fff;
}

.button--blue:hover {
  background: var(--dark-blue);
  border-color: var(--dark-blue);
}

.button--red {
  background: var(--red);
  border-color: var(--red);
  color: #fff;
}

.button--grey {
  background: var(--surfaceSecondary);
  border-color: transparent;
  color: var(--textSecondary);
}

/* ---------- 8. 输入框 ---------- */
.input {
  background: var(--surfacePrimary);
  border: 1px solid var(--borderPrimary);
  border-radius: var(--np-radius-sm);
  padding: 0.55em 0.7em;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.input:focus {
  border-color: var(--blue);
  box-shadow: var(--np-ring);
  outline: 0;
}

/* ---------- 9. 登录页：居中一张白卡 ---------- */
#login {
  background: var(--background);
}

#login form {
  max-width: 340px;
  padding: 34px 30px 30px;
  background: var(--surfacePrimary);
  border: 1px solid var(--borderPrimary);
  border-radius: 18px;
  box-shadow: var(--np-shadow-lg);
}

#login form img {
  width: 56px;
  height: 56px;
  margin-bottom: 0.45em;
}

#login form h1 {
  font-size: 1.32em;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--textSecondary);
  margin: 0 0 1.1em;
}

#login form .input {
  background: var(--surfaceSecondary);
  border-color: transparent;
}

#login form .input:focus {
  background: var(--surfacePrimary);
  border-color: var(--blue);
}

#login form .button {
  margin-top: 0.3em;
}

/* ---------- 10. 侧边栏 ---------- */
nav .action,
nav .button {
  border-radius: 10px;
  transition: background 0.14s ease, color 0.14s ease;
}

nav .action:hover,
nav .button:hover {
  background: var(--hover);
}

/* 底部容量条：默认是硬的蓝条，改成细的圆角条 */
.vue-simple-progress {
  background: var(--surfaceSecondary) !important;
  border-radius: 99px;
  overflow: hidden;
}

.vue-simple-progress-bar {
  background: var(--blue) !important;
  border-radius: 99px;
}

/* 底部版本号与帮助：弱化，并去掉第三方品牌字样 */
p.credits {
  color: var(--textPrimary) !important;
  opacity: 0.85;
  font-size: 0.78em;
}

p.credits > span:first-child {
  display: none;
}

p.credits a {
  color: inherit;
}

/* ---------- 11. 弹层、菜单、提示 ---------- */
.context-menu {
  background: var(--surfacePrimary);
  border: 1px solid var(--borderPrimary);
  border-radius: 12px;
  box-shadow: var(--np-shadow-lg);
  overflow: hidden;
}

.context-menu .button--flat {
  border-radius: 0;
}

.overlay .card,
.preview .card {
  border-radius: 16px;
  box-shadow: var(--np-shadow-lg);
}

.Vue-Toastification__toast {
  border-radius: 12px;
  box-shadow: var(--np-shadow-lg);
  font-family: inherit;
}

/* ---------- 12. 滚动条 ---------- */
* {
  scrollbar-width: thin;
  scrollbar-color: rgba(17, 24, 39, 0.18) transparent;
}

:root.dark * {
  scrollbar-color: rgba(255, 255, 255, 0.16) transparent;
}

::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: rgba(17, 24, 39, 0.18);
  border: 3px solid transparent;
  border-radius: 8px;
  background-clip: content-box;
}

::-webkit-scrollbar-thumb:hover {
  background: rgba(17, 24, 39, 0.3);
  background-clip: content-box;
}

:root.dark ::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.16);
  background-clip: content-box;
}

/* ---------- 13. 可访问性 ---------- */
:focus-visible {
  outline: 2px solid var(--blue);
  outline-offset: 2px;
  border-radius: 6px;
}

/* ---------- 14. 图标配色：把默认高饱和蓝收敛到主色系 ---------- */
:root {
  --icon-blue: #4a7bf7;
  --icon-green: #35a86b;
  --icon-orange: #e08b4c;
  --icon-yellow: #d9a03a;
  --icon-red: #d9555c;
  --icon-violet: #8a6fd4;
}

:root.dark {
  --icon-blue: #7ea2ff;
  --icon-green: #5cc08a;
  --icon-orange: #f0a76b;
  --icon-yellow: #e5b95c;
  --icon-red: #ef7b81;
  --icon-violet: #a894e8;
}

/* ---------- 15. 手机端：单行紧凑列表 ---------- */
@media (max-width: 736px) {
  /* 表头压缩成一条轻量排序栏，仍与卡片连成一体 */
  #listing .item.header {
    min-height: 40px;
    padding: 9px 14px !important;
  }

  #listing .item.header > div {
    display: flex !important;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    gap: 0 0.6em;
  }

  #listing .item.header .name,
  #listing .item.header .modified {
    font-size: 0.76em;
    margin: 0 !important;
    width: auto !important;
  }

  #listing .item.header .name {
    flex: 1 1 auto;
  }

  #listing .item.header .modified {
    flex: 0 0 auto;
    text-align: right;
  }

  /* 手机端行内不再有大小列 */
  #listing .item.header .size {
    display: none !important;
  }

  #listing .item:not(.header) {
    display: flex !important;
    align-items: center;
    flex-wrap: nowrap;
    width: 100% !important;
    min-height: 0;
    padding: 12px 14px !important;
    border-radius: 0;
  }

  /* 第 1 个子元素 = 图标容器 */
  #listing .item:not(.header) > div:first-child {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 1.7em !important;
    min-width: 1.7em !important;
    max-width: 1.7em;
    margin-right: 0.7em;
  }

  #listing .item:not(.header) > div:first-child i {
    font-size: 1.45em !important;
    line-height: 1;
  }

  #listing .item:not(.header) > div:first-child img {
    width: 1.7em;
    height: 1.7em;
    object-fit: cover;
    border-radius: 5px;
  }

  /* 第 2 个子元素 = 文字容器，原本竖排三行，压成一行 */
  #listing .item:not(.header) > div:last-child {
    flex: 1 1 auto;
    min-width: 0;
    display: flex !important;
    align-items: center;
    flex-wrap: nowrap;
    gap: 0 0.6em;
    text-align: left !important;
  }

  #listing .item:not(.header) .name {
    flex: 1 1 auto;
    min-width: 0;
    margin: 0;
    font-size: 0.94em;
    line-height: 1.3;
    text-align: left !important;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  /* 文件夹没有大小，原来的 “—” 是纯噪音 */
  #listing .item:not(.header) .size {
    display: none !important;
  }

  /* 移动端默认把时间藏了，这里放回右侧 */
  #listing .item:not(.header) .modified {
    display: block !important;
    flex: 0 0 auto;
    margin: 0;
    font-size: 0.72em;
    line-height: 1.2;
    color: var(--textPrimary);
    white-space: nowrap;
  }

  #listing .item:not(.header) .modified time {
    white-space: nowrap;
  }

  #login form {
    max-width: 86vw;
    padding: 28px 22px 24px;
  }
}
