/* ==========================================================
   IMPERIO STUDIO — layout.css
   Estructura general: sidebar, topbar, main
   ========================================================== */

body {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  grid-template-rows: var(--topbar-h) 1fr;
  grid-template-areas:
    'sidebar topbar'
    'sidebar main';
  min-height: 100vh;
}

/* ============ SIDEBAR ============ */
.sidebar {
  grid-area: sidebar;
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: var(--sp-4) var(--sp-3) var(--sp-5);
  background: var(--bg);
  border-right: 1px solid var(--border);
  gap: var(--sp-4);
  z-index: 50;
}

.sidebar__create {
  width: 44px;
  height: 44px;
  border-radius: var(--r-full);
  background: var(--ink);
  color: var(--ink-contrast);
  display: grid;
  place-items: center;
  transition: transform var(--t-fast), background var(--t-fast), box-shadow var(--t-fast);
  box-shadow: var(--shadow-sm);
  margin-bottom: var(--sp-2);
}

.sidebar__create svg {
  width: 20px;
  height: 20px;
  stroke-width: 2.4;
}

.sidebar__create:hover {
  transform: rotate(90deg) scale(1.05);
  background: var(--accent);
  color: var(--accent-contrast);
  box-shadow: var(--shadow-md);
}

.sidebar__nav {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--sp-1);
  width: 100%;
}

.nav-item {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: var(--sp-3) var(--sp-1);
  border-radius: var(--r-sm);
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.01em;
  transition: color var(--t-fast), background var(--t-fast);
  position: relative;
}

.nav-item svg {
  width: 22px;
  height: 22px;
}

.nav-item:hover {
  color: var(--text);
  background: var(--surface-hover);
}

.nav-item.is-active {
  color: var(--text);
}

.nav-item.is-active::before {
  content: '';
  position: absolute;
  left: -12px;
  top: 50%;
  transform: translateY(-50%);
  width: 3px;
  height: 24px;
  background: var(--accent);
  border-radius: 0 3px 3px 0;
}

/* Storage en la parte inferior */
.sidebar__storage {
  margin-top: auto;
  width: 100%;
  padding: var(--sp-3);
  border-radius: var(--r-md);
  background: var(--bg-sunk);
  border: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
  font-size: 10px;
}

.storage__header {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  color: var(--text-muted);
}

.storage__header svg {
  width: 18px;
  height: 18px;
}

.storage__label {
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  font-size: 9px;
}

.storage__bar {
  width: 100%;
  height: 4px;
  background: var(--border);
  border-radius: var(--r-full);
  overflow: hidden;
}

.storage__fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent) 0%, var(--accent-hover) 100%);
  border-radius: var(--r-full);
  transition: width var(--t-slow);
}

.storage__info {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 4px;
  color: var(--text-soft);
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 500;
}

.storage__divider {
  color: var(--text-ghost);
}

/* ============ TOPBAR ============ */
.topbar {
  grid-area: topbar;
  position: sticky;
  top: 0;
  height: var(--topbar-h);
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: var(--sp-6);
  padding: 0 var(--sp-7);
  background: color-mix(in srgb, var(--bg) 85%, transparent);
  backdrop-filter: saturate(1.6) blur(16px);
  -webkit-backdrop-filter: saturate(1.6) blur(16px);
  border-bottom: 1px solid var(--border);
  z-index: 40;
}

.brand {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  transition: opacity var(--t-fast);
}

.brand:hover { opacity: 0.75; }

.brand__mark {
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  color: var(--ink);
  background: var(--bg-sunk);
  border-radius: var(--r-sm);
  border: 1px solid var(--border);
}

.brand__mark svg {
  width: 20px;
  height: 20px;
}

.brand__name {
  display: flex;
  flex-direction: column;
  line-height: 1;
}

.brand__imperio {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 18px;
  font-style: italic;
  letter-spacing: -0.01em;
  color: var(--text);
}

.brand__studio {
  font-family: var(--font-body);
  font-weight: 500;
  font-size: 10px;
  letter-spacing: 0.28em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-top: 3px;
}

/* Searchbar */
.searchbar {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  max-width: 560px;
  width: 100%;
  height: 44px;
  padding: 0 var(--sp-4);
  background: var(--bg-sunk);
  border: 1px solid transparent;
  border-radius: var(--r-full);
  transition: border-color var(--t-fast), background var(--t-fast);
  justify-self: center;
}

.searchbar:focus-within {
  border-color: var(--accent);
  background: var(--surface);
}

.searchbar svg {
  width: 18px;
  height: 18px;
  color: var(--text-muted);
}

.searchbar input {
  flex: 1;
  height: 100%;
  border: none;
  outline: none;
  background: transparent;
  font-size: var(--fs-sm);
  color: var(--text);
}

.searchbar input::placeholder {
  color: var(--text-muted);
}

.searchbar__kbd {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-muted);
  padding: 2px 8px;
  border: 1px solid var(--border);
  border-radius: var(--r-xs);
  background: var(--bg);
}

/* Acciones derecha */
.topbar__actions {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
}

.icon-btn {
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  border-radius: var(--r-full);
  color: var(--text-soft);
  transition: background var(--t-fast), color var(--t-fast), transform var(--t-fast);
}

.icon-btn:hover {
  background: var(--surface-hover);
  color: var(--text);
  transform: scale(1.05);
}

.icon-btn svg {
  width: 18px;
  height: 18px;
}

/* Toggle de tema: mostrar icono según tema activo */
.icon-sun { display: none; }
.icon-moon { display: block; }
[data-theme='dark'] .icon-sun { display: block; }
[data-theme='dark'] .icon-moon { display: none; }

.avatar {
  width: 40px;
  height: 40px;
  border-radius: var(--r-full);
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-hover) 100%);
  color: var(--accent-contrast);
  display: grid;
  place-items: center;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 13px;
  letter-spacing: 0.02em;
  transition: transform var(--t-fast), box-shadow var(--t-fast);
  box-shadow: var(--shadow-sm);
}

.avatar:hover {
  transform: scale(1.05);
  box-shadow: var(--shadow-md);
}

/* ============ MAIN ============ */
.main {
  grid-area: main;
  padding: var(--sp-7) var(--sp-7) var(--sp-9);
  max-width: 1680px;
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: var(--sp-8);
}

/* ============ RESPONSIVE ============ */
@media (max-width: 900px) {
  body {
    grid-template-columns: 72px 1fr;
  }
  :root {
    --sidebar-w: 72px;
  }
  .topbar {
    padding: 0 var(--sp-4);
    gap: var(--sp-3);
  }
  .brand__name { display: none; }
  .searchbar__kbd { display: none; }
  .main {
    padding: var(--sp-5) var(--sp-4) var(--sp-8);
    gap: var(--sp-7);
  }
}

@media (max-width: 560px) {
  .searchbar {
    height: 40px;
    padding: 0 var(--sp-3);
  }
  .searchbar input::placeholder {
    font-size: 13px;
  }
}
