/* assets/css/style.css */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

:root {
    /* Light Theme Palette */
    --bg-color: #f8fafc;
    --surface-color: #ffffff;
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --border-color: #e2e8f0;

    --primary-color: #3b82f6;
    --primary-hover: #2563eb;

    --danger-color: #ef4444;
    --success-color: #22c55e;

    --sidebar-width: 250px;
    --header-height: 64px;

    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);

    --radius-md: 0.5rem;
    --radius-lg: 0.75rem;

    --transition-speed: 0.3s;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-primary);
    line-height: 1.5;
    transition: background-color var(--transition-speed), color var(--transition-speed);
}

/* Typography & Utils */
h1,
h2,
h3 {
    color: var(--text-primary);
    font-weight: 600;
}

.text-right {
    text-align: right;
}

.text-plus {
    color: var(--success-color);
    font-weight: 600;
}

.text-minus {
    color: var(--danger-color);
    font-weight: 600;
}

.badge {
    display: inline-block;
    padding: 0.25em 0.5em;
    font-size: 0.75rem;
    font-weight: 700;
    line-height: 1;
    text-align: center;
    white-space: nowrap;
    vertical-align: baseline;
    border-radius: 0.25rem;
    background-color: var(--primary-color);
    color: #fff;
    margin-bottom: 4px;
}

/* Forms & Buttons */
.form-group {
    margin-bottom: 1.5rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
    color: var(--text-secondary);
}

input[type="text"],
input[type="password"],
input[type="number"],
select {
    width: 100%;
    padding: 0.75rem 1rem;
    font-size: 1rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    background-color: var(--surface-color);
    color: var(--text-primary);
    transition: border-color 0.15s ease-in-out, box-shadow 0.15s ease-in-out;
}

input:focus,
select:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.25);
}

.btn {
    display: inline-block;
    font-weight: 500;
    text-align: center;
    text-decoration: none;
    padding: 0.75rem 1.5rem;
    font-size: 1rem;
    border-radius: var(--radius-md);
    border: 1px solid transparent;
    cursor: pointer;
    transition: all 0.2s ease-in-out;
}

.btn-primary {
    color: #fff;
    background-color: var(--primary-color);
}

.btn-primary:hover {
    background-color: var(--primary-hover);
    transform: translateY(-1px);
    box-shadow: var(--shadow-sm);
}

.btn-secondary {
    color: var(--text-primary);
    background-color: var(--surface-color);
    border-color: var(--border-color);
}

.btn-secondary:hover {
    background-color: var(--bg-color);
}

.btn-icon {
    background: transparent;
    border: none;
    font-size: 1.25rem;
    padding: 0.5rem;
    color: var(--text-secondary);
}

.btn-icon:hover {
    color: var(--primary-color);
}

/* Layout */
.app-header {
    height: var(--header-height);
    background-color: var(--surface-color);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 2rem;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 1000;
    box-shadow: var(--shadow-sm);
}

.header-logo {
    display: flex;
    align-items: center;
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--primary-color);
}

.sidebar-toggle-btn {
    display: inline-block;
    /* PCでも表示 */
    background: transparent;
    border: none;
    font-size: 1.5rem;
    color: var(--text-primary);
    cursor: pointer;
    margin-right: 15px;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.app-container {
    display: flex;
    min-height: 100vh;
    padding-top: var(--header-height);
}

.sidebar {
    width: var(--sidebar-width);
    background-color: var(--surface-color);
    border-right: 1px solid var(--border-color);
    padding: 1.5rem 0;
    position: fixed;
    top: var(--header-height);
    bottom: 0;
    left: 0;
    overflow-y: auto;
    transition: left 0.3s ease;
    z-index: 900;
}

.sidebar.closed {
    left: calc(var(--sidebar-width) * -1);
}

.sidebar-nav ul {
    list-style: none;
}

.sidebar-nav a {
    display: block;
    padding: 0.75rem 2rem;
    color: var(--text-secondary);
    text-decoration: none;
    font-weight: 500;
    transition: background-color 0.2s, color 0.2s;
    border-left: 3px solid transparent;
}

.sidebar-nav a:hover {
    background-color: var(--bg-color);
    color: var(--text-primary);
}

.sidebar-nav a.active {
    color: var(--primary-color);
    background-color: rgba(59, 130, 246, 0.1);
    border-left-color: var(--primary-color);
}

.main-content {
    flex: 1;
    margin-left: var(--sidebar-width);
    padding: 2rem;
    max-width: 1400px;
    min-width: 0;
    transition: margin-left 0.3s ease, max-width 0.3s ease;
}

.sidebar.closed~.main-content {
    margin-left: 0;
    max-width: 100vw;
}

/* Cards & Dashboard */
.view-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    margin-bottom: 2rem;
}

.card {
    background-color: var(--surface-color);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-sm);
    padding: 1.5rem;
    margin-bottom: 1.5rem;
    transition: box-shadow 0.3s;
}

.card:hover {
    box-shadow: var(--shadow-md);
}

.summary-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.summary-card h3 {
    font-size: 0.875rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
}

.summary-card .amount {
    font-size: 2rem;
    font-weight: 700;
}

.charts-container {
    width: 100%;
    margin-bottom: 2rem;
}

.chart-card {
    height: 400px;
    position: relative;
    width: 100%;
}

.table-responsive {
    overflow-x: auto;
}

/* Table */
.data-table {
    width: 100%;
    border-collapse: collapse;
    white-space: nowrap;
}

.data-table th,
.data-table td {
    padding: 1rem;
    border-bottom: 1px solid var(--border-color);
    text-align: left;
}

.data-table th {
    font-weight: 600;
    color: var(--text-secondary);
    background-color: var(--bg-color);
    position: sticky;
    top: 0;
}

.data-table tbody tr {
    transition: background-color 0.15s;
}

.data-table tbody tr:hover {
    background-color: rgba(0, 0, 0, 0.02);
}

/* Responsive (スマホ・タブレット) */
@media (max-width: 1024px) {
    .app-container {
        flex-direction: column;
        overflow-x: hidden;
    }

    .sidebar {
        position: fixed;
        left: -100%;
        top: var(--header-height);
        width: 250px;
        height: calc(100vh - var(--header-height));
        z-index: 1000;
        transition: left 0.3s ease;
        border-right: 1px solid var(--border-color);
        padding: 1rem 0;
        box-shadow: var(--shadow-md);
        background: var(--surface-color);
    }

    .sidebar.open {
        left: 0;
    }

    .sidebar.closed {
        left: -100%;
    }

    .sidebar-nav ul {
        display: block;
        overflow-y: auto;
    }

    .sidebar-nav a {
        border-left: 3px solid transparent;
        border-bottom: none;
        white-space: normal;
    }

    .main-content {
        margin-left: 0 !important;
        padding: 0.5rem;
        width: 100%;
        max-width: 100vw;
    }

    .header-actions {
        gap: 0.5rem;
    }

    .logout-text {
        display: none;
    }

    .btn {
        padding: 0.5rem 0.8rem;
        font-size: 0.85rem;
    }

    .view-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.8rem;
        margin-bottom: 1rem;
        padding: 0 0.5rem;
    }
}

/* 追加機能 (タグ・コメント・内訳) */
.tag-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    background-color: var(--border-color);
    color: var(--text-primary);
    padding: 0.15rem 0.5rem;
    border-radius: 9999px;
    font-size: 0.75rem;
    margin: 2px;
}

.tag-remove {
    cursor: pointer;
    font-weight: bold;
    color: var(--text-secondary);
}

.tag-remove:hover {
    color: var(--danger-color);
}

.add-tag-btn {
    background: transparent;
    border: 1px solid var(--primary-color);
    border-radius: 9999px;
    padding: 0.2rem 0.8rem;
    font-size: 0.75rem;
    font-weight: 600;
    cursor: pointer;
    color: var(--primary-color);
    margin: 2px;
    transition: all 0.2s;
}

.add-tag-btn:hover {
    background: var(--primary-color);
    color: #fff;
}

.comment-input {
    width: 200px;
    height: 48px;
    resize: vertical;
    padding: 0.5rem;
    font-size: 0.85rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    background-color: var(--bg-color);
    color: var(--text-primary);
    transition: box-shadow 0.2s;
}

.comment-input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.25);
}

.broker-breakdown {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.broker-breakdown span {
    display: block;
}

/* ソート機能用 */
.sortable {
    cursor: pointer;
    user-select: none;
    position: relative;
    padding-right: 20px !important;
}

.sortable:hover {
    background-color: rgba(0, 0, 0, 0.05);
}

.dark-mode .sortable:hover {
    background-color: rgba(255, 255, 255, 0.05);
}

.sort-asc::after {
    content: '\f0de';
    font-family: "Font Awesome 6 Free";
    font-weight: 900;
    position: absolute;
    right: 5px;
    font-size: 0.8em;
}

.sort-desc::after {
    content: '\f0dd';
    font-family: "Font Awesome 6 Free";
    font-weight: 900;
    position: absolute;
    right: 5px;
    font-size: 0.8em;
}

/* カラム表示切替メニュー */
.column-menu label {
    display: block;
    padding: 10px 8px;
    cursor: pointer;
    font-size: 0.9rem;
    color: var(--text-primary);
    border-bottom: 1px solid var(--border-color);
}

.column-menu label:last-child {
    border-bottom: none;
}

.column-menu label input {
    margin-right: 8px;
}

/* スマホ用テーブル（カードレイアウト廃止・横スクロール維持） */
@media (max-width: 1024px) {
    .tags-cell .comment-input {
        width: 100%;
        margin-top: 5px;
    }
}