/* Posimai Design System — base.css v1
 * 使い方: <link rel="stylesheet" href="https://posimai-ui.vercel.app/v1/base.css">
 * アプリ固有のスタイルはこの後に <style> で追記すること
 */

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

:root, [data-theme="dark"] {
    --bg:#0D0D0D; --surface:#1A1A1A; --surface2:#252525; --border:#2D2D2D;
    --text:#F3F4F6; --text2:#9CA3AF; --text3:#6B7280;
    --accent:#6EE7B7; --accent-dim:rgba(110,231,183,0.1); --accent-border:rgba(110,231,183,0.25);
    --header-bg:rgba(13,13,13,0.85);
    --overlay-bg:rgba(0,0,0,0.6); --shadow-lg:0 8px 32px rgba(0,0,0,0.5); --shadow-sm:0 2px 8px rgba(0,0,0,0.3);
    color-scheme: dark;
}
[data-theme="light"] {
    --bg:#F9FAFB; --surface:#FFFFFF; --surface2:#F3F4F6; --border:#E5E7EB;
    --text:#111827; --text2:#4B5563; --text3:#6B7280;
    --accent:#059669; --accent-dim:rgba(5,150,105,0.08); --accent-border:rgba(5,150,105,0.2);
    --header-bg:rgba(249,250,251,0.85);
    --overlay-bg:rgba(0,0,0,0.4); --shadow-lg:0 8px 32px rgba(0,0,0,0.15); --shadow-sm:0 2px 8px rgba(0,0,0,0.08);
    color-scheme: light;
}
:root {
    --radius:12px; --radius-sm:8px; --header-h:52px;
    --ease:cubic-bezier(.4,0,.2,1); --dur:0.2s;
}

body {
    font-family: 'Geist', system-ui, sans-serif;
    background: var(--bg); color: var(--text);
    font-size: 14px; line-height: 1.6;
    -webkit-font-smoothing: antialiased;
}
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
:focus:not(:focus-visible) { outline: none; }

/* Header */
.header {
    height: var(--header-h); display: flex; align-items: center; gap: 8px;
    padding: 0 16px; background: var(--header-bg);
    backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
    border-bottom: 1px solid var(--border);
    position: sticky; top: 0; z-index: 100;
}
.header-brand { display: flex; align-items: center; gap: 8px; flex: 1; }
.header-dot { width: 7px; height: 7px; background: var(--accent); border-radius: 50%; }
.header-title { font-size: 14px; font-weight: 600; letter-spacing: -0.01em; }
.icon-btn {
    background: none; border: none; cursor: pointer; color: var(--text2);
    min-width: 44px; min-height: 44px;
    display: flex; align-items: center; justify-content: center;
    border-radius: var(--radius-sm);
    transition: color var(--dur), background var(--dur);
    flex-shrink: 0; margin: 0 -8px;
}
.icon-btn:hover { color: var(--text); background: var(--surface2); }

/* Main */
main {
    padding: 24px 20px calc(40px + env(safe-area-inset-bottom));
    max-width: 860px; width: 100%; margin: 0 auto;
}

/* Settings panel */
.settings-panel {
    position: fixed; top: 0; right: 0; bottom: 0; width: 280px;
    background: var(--surface); border-left: 1px solid var(--border);
    display: flex; flex-direction: column; z-index: 300;
    transform: translateX(100%); transition: transform .25s var(--ease);
}
.settings-panel.open { transform: translateX(0); box-shadow: var(--shadow-lg); }
.settings-panel-header {
    height: var(--header-h); display: flex; align-items: center;
    justify-content: space-between; padding: 0 12px 0 16px;
    flex-shrink: 0; border-bottom: 1px solid var(--border);
}
.settings-panel-title { font-size: 14px; font-weight: 600; }
.settings-panel-body { flex: 1; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 24px; }
.settings-group-label { font-size: 10px; font-weight: 600; color: var(--text3); text-transform: uppercase; letter-spacing: 0.08em; margin-bottom: 10px; }
.settings-item { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--border); }
.settings-item:last-child { border-bottom: none; }
.settings-item-label { font-size: 13px; color: var(--text); }
.theme-selector { display: flex; gap: 4px; background: var(--surface2); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 3px; }
.theme-btn {
    flex: 1; display: flex; align-items: center; justify-content: center;
    gap: 5px; padding: 6px 8px; border-radius: 6px; border: none;
    cursor: pointer; font-family: inherit; font-size: 11px; font-weight: 500;
    color: var(--text3); background: none; transition: all var(--dur) var(--ease); white-space: nowrap;
}
.theme-btn:hover { color: var(--text2); }
.theme-btn.active { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); }
.overlay { display: none; position: fixed; inset: 0; background: var(--overlay-bg); backdrop-filter: blur(2px); z-index: 150; }
.overlay.open { display: block; }

/* Buttons */
.btn { display: inline-flex; align-items: center; gap: 6px; padding: 8px 14px; border-radius: var(--radius-sm); border: none; cursor: pointer; font-family: inherit; font-size: 13px; font-weight: 500; transition: all var(--dur) var(--ease); }
.btn-primary { background: var(--accent); color: #0D0D0D; }
.btn-primary:hover { opacity: .88; }
.btn-ghost { background: var(--surface2); color: var(--text2); border: 1px solid var(--border); }
.btn-ghost:hover { color: var(--text); background: var(--surface); }

/* Card */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; }

/* Section label */
.section-label { font-size: 11px; font-weight: 600; color: var(--text3); text-transform: uppercase; letter-spacing: 0.08em; margin-bottom: 12px; }

/* Toast */
#toast {
    position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius-sm); padding: 10px 16px;
    font-size: 13px; font-weight: 500; z-index: 9999;
    box-shadow: var(--shadow-lg); transition: opacity .2s, transform .2s;
    opacity: 0; pointer-events: none; white-space: nowrap;
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(-4px); }

/* ═══════════════════════════════════════════════════
   Sidebar layout — サイドバーを持つアプリ向け
   .app + .sidebar + .main + .content パターン
   ═══════════════════════════════════════════════════ */
:root { --sidebar-w: 240px; }

/* Skip link (アクセシビリティ) */
.skip-link { position: absolute; top: -100%; left: 8px; background: var(--accent); color: #0D0D0D; padding: 8px 16px; border-radius: 8px; font-weight: 600; font-size: 13px; z-index: 10000; text-decoration: none; }
.skip-link:focus { top: 8px; }

/* App shell */
.app { display: flex; min-height: 100dvh; }

/* Sidebar */
.sidebar {
    position: fixed; top: 0; left: 0; bottom: 0; width: var(--sidebar-w);
    background: rgba(13,13,13,0.88); backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px);
    border-right: 1px solid var(--border);
    display: flex; flex-direction: column; z-index: 200;
    transform: translateX(-100%); transition: transform .25s var(--ease);
}
[data-theme="light"] .sidebar { background: rgba(249,250,251,0.92); }
.sidebar.open { transform: translateX(0); box-shadow: var(--shadow-lg); }

.sidebar-header { height: var(--header-h); display: flex; align-items: center; justify-content: space-between; padding: 0 12px 0 16px; flex-shrink: 0; border-bottom: 1px solid var(--border); }
.sidebar-nav { flex: 1; overflow-y: auto; padding: 4px 8px 0; scrollbar-width: none; }
.sidebar-nav::-webkit-scrollbar { width: 0; }
.sidebar-footer { flex-shrink: 0; padding: 8px; border-top: 1px solid var(--border); }

/* Brand (sidebar header) */
.brand { display: flex; align-items: center; gap: 10px; }
.brand-logo { width: 28px; height: 28px; border-radius: 8px; flex-shrink: 0; display: flex; align-items: center; justify-content: center; background: linear-gradient(135deg, var(--accent), #047857); }
[data-theme="light"] .brand-logo { background: linear-gradient(135deg, #34D399, #059669); }
.brand-text { display: flex; flex-direction: column; }
.brand-name { font-size: 13px; font-weight: 600; letter-spacing: -0.01em; line-height: 1.3; }
.brand-org { font-size: 10px; font-weight: 500; color: var(--text3); text-transform: uppercase; letter-spacing: 0.1em; }

/* Nav items */
.nav-section-label { font-size: 10px; font-weight: 600; color: var(--text3); text-transform: uppercase; letter-spacing: 0.1em; padding: 12px 10px 4px; }
.nav-item { display: flex; align-items: center; gap: 9px; padding: 9px 10px; min-height: 40px; border-radius: var(--radius-sm); border: 1px solid transparent; cursor: pointer; color: var(--text2); font-size: 13px; font-weight: 500; transition: background var(--dur) var(--ease), color var(--dur) var(--ease), border-color var(--dur) var(--ease); text-decoration: none; user-select: none; }
.nav-item:hover { background: var(--surface2); color: var(--text); }
.nav-item.active { background: var(--accent-dim); color: var(--accent); border-color: var(--accent-border); }
.nav-item svg, .nav-item i { flex-shrink: 0; opacity: .8; }
.nav-item.active svg, .nav-item.active i { opacity: 1; }
.nav-item-label { flex: 1; }
.nav-count { font-size: 11px; font-weight: 600; background: var(--surface2); border: 1px solid var(--border); border-radius: 999px; padding: 1px 7px; color: var(--text3); }

/* Sidebar footer: user row */
.user-row { display: flex; align-items: center; gap: 9px; padding: 8px 10px; border-radius: var(--radius-sm); cursor: pointer; transition: background var(--dur); }
.user-row:hover { background: var(--surface2); }
.user-avatar { width: 28px; height: 28px; border-radius: 50%; background: var(--accent-dim); border: 1px solid var(--accent-border); display: flex; align-items: center; justify-content: center; font-size: 11px; font-weight: 600; color: var(--accent); flex-shrink: 0; }
.user-info { flex: 1; min-width: 0; }
.user-name { font-size: 12px; font-weight: 500; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-role { font-size: 11px; color: var(--text3); }
.settings-trigger { background: none; border: none; cursor: pointer; color: var(--text3); display: flex; align-items: center; padding: 6px; border-radius: var(--radius-sm); transition: color var(--dur), background var(--dur); flex-shrink: 0; }
.settings-trigger:hover { color: var(--text2); background: var(--surface2); }

/* Main area (sidebar layout) */
.main { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.content { flex: 1; padding: 24px 20px calc(40px + env(safe-area-inset-bottom)); max-width: 1100px; width: 100%; margin: 0 auto; }

/* Header (sidebar apps) */
.mobile-brand { display: flex; align-items: center; gap: 7px; flex: 1; }
.mobile-brand-dot { width: 7px; height: 7px; background: var(--accent); border-radius: 50%; }
.mobile-brand-name { font-size: 14px; font-weight: 600; }
.page-title { font-size: 14px; font-weight: 600; letter-spacing: -0.01em; flex: 1; }

/* Responsive: PC でサイドバー常時表示 */
@media (min-width: 1024px) {
    .sidebar { transform: translateX(0) !important; box-shadow: none !important; }
    .main { margin-left: var(--sidebar-w); }
    .mobile-brand { display: none; }
    .page-title { display: block; }
    #menuBtn { display: none; }
    .overlay { display: none !important; }
    body.sidebar-collapsed .sidebar { transform: translateX(-100%) !important; }
    body.sidebar-collapsed .main { margin-left: 0; }
    body.sidebar-collapsed #menuBtn { display: flex !important; }
    body.sidebar-collapsed .mobile-brand { display: flex !important; }
    body.sidebar-collapsed .page-title { display: none; }
}
@media (max-width: 1023px) { .page-title { display: none; } .mobile-brand { display: flex; } }
