/* テーマ変数 */
:root {
    /* ダークモード（デフォルト） */
    --bg-color: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
    --card-bg: rgba(30, 30, 47, 0.9);
    --text-color: #e0e0e0;
    --subtext-color: #a0a0a0;
    --stat-value-color: #00ff99;
    --border-color: #444;
    --input-bg: #222;
    --table-header-bg: linear-gradient(45deg, #2a2a3d, #1e1e2f);
    --table-border: rgba(255, 255, 255, 0.1);
    --buy-bg: rgba(0, 255, 153, 0.05);
    --sell-bg: rgba(255, 77, 77, 0.05);
    --hover-bg: rgba(255, 255, 255, 0.05);
    transition: none;
}

[data-theme="light"] {
    /* ホワイトモード */
    --bg-color: linear-gradient(135deg, #f0f2f5 0%, #e4e7eb 100%);
    --card-bg: rgba(255, 255, 255, 0.9);
    --text-color: #333;
    --subtext-color: #666;
    --stat-value-color: #00cc77;
    --border-color: #ccc;
    --input-bg: #f9f9f9;
    --table-header-bg: linear-gradient(45deg, #e0e0e0, #d0d0d0);
    --table-border: rgba(0, 0, 0, 0.1);
    --buy-bg: rgba(0, 255, 153, 0.1);
    --sell-bg: rgba(255, 77, 77, 0.1);
    --hover-bg: rgba(0, 0, 0, 0.05);
}

/* トランジションを適用するクラス */
.transition-enabled {
    transition: all 0.5s ease;
}

/* リセットと基本設定 */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Poppins', sans-serif;
    color: var(--text-color);
    background: var(--bg-color);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    margin: 0;
    transition: none;
}

body.transition-enabled {
    transition: background 0.5s ease, color 0.5s ease;
}

.container {
    width: 100%;
    max-width: 1200px;
    height: 95vh;
    display: flex;
    flex-direction: column;
    padding: 20px;
}

/* ヘッダー */
.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 20px;
    background: var(--card-bg);
    border-radius: 15px;
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.3);
    backdrop-filter: blur(10px);
    flex-shrink: 0;
    transition: none;
}

.header.transition-enabled {
    transition: background 0.5s ease;
}

.header h1 {
    font-size: 1.8rem;
    font-weight: 700;
    color: #00d4ff;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.auth-section {
    display: flex;
    align-items: center;
    gap: 15px;
}

.user-info {
    font-size: 0.9rem;
    color: var(--subtext-color);
    display: none;
    transition: none;
}

.user-info.transition-enabled {
    transition: color 0.5s ease;
}

.btn {
    padding: 10px 20px;
    border: none;
    border-radius: 25px;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
}

.btn:hover {
    transform: translateY(-3px);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.3);
}

.btn-login {
    background: linear-gradient(45deg, #7289da, #5865f2);
    color: #fff;
}

.btn-login:hover {
    background: linear-gradient(45deg, #5865f2, #7289da);
}

.btn-logout {
    background: #ff4d4d;
    color: #fff;
    display: none;
}

.btn-logout:hover {
    background: #e63939;
}

.btn-theme {
    background: linear-gradient(45deg, #ffd700, #ffaa00);
    color: #fff;
}

.btn-theme:hover {
    background: linear-gradient(45deg, #ffaa00, #ffd700);
}

.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.dashboard {
    display: flex;
    flex-direction: column;
    gap: 20px;
    height: 100%;
}

.stats-container {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 15px;
    flex-shrink: 0;
    margin-top: 5px;
}

.stat-card {
    background: var(--card-bg);
    padding: 15px;
    border-radius: 15px;
    text-align: center;
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.2);
    backdrop-filter: blur(10px);
    transition: transform 0.3s ease;
}

.stat-card.transition-enabled {
    transition: transform 0.3s ease, background 0.5s ease;
}

.stat-card:hover {
    transform: translateY(-5px);
}

.stat-card h3 {
    font-size: 1rem;
    color: var(--subtext-color);
    margin-bottom: 8px;
    transition: none;
}

.stat-card h3.transition-enabled {
    transition: color 0.5s ease;
}

.stat-value {
    font-size: 1.6rem;
    font-weight: 700;
    color: var(--stat-value-color);
    transition: none;
}

.stat-value.transition-enabled {
    transition: color 0.5s ease;
}

.chart-card {
    background: var(--card-bg);
    padding: 20px;
    border-radius: 15px;
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.2);
    backdrop-filter: blur(10px);
    flex: 1;
    max-height: 50%;
    overflow: hidden;
    transition: none;
}

.chart-card.transition-enabled {
    transition: background 0.5s ease;
}

.trade-card {
    display: flex;
    flex-direction: row;
    gap: 15px;
    background: var(--card-bg);
    padding: 15px;
    border-radius: 15px;
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.2);
    backdrop-filter: blur(10px);
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    display: none;
    transition: none;
}

.trade-card.transition-enabled {
    transition: background 0.5s ease;
}

.trade-input {
    padding: 10px;
    width: 120px;
    border: 2px solid var(--border-color);
    border-radius: 10px;
    background: var(--input-bg);
    color: var(--text-color);
    font-size: 0.9rem;
    text-align: center;
    transition: border-color 0.3s ease;
}

.trade-input.transition-enabled {
    transition: border-color 0.3s ease, background 0.5s ease, color 0.5s ease;
}

.trade-input:focus {
    border-color: #00d4ff;
    outline: none;
}

.trade-buttons {
    display: flex;
    gap: 10px;
}

.btn-buy {
    background: linear-gradient(45deg, #00ff99, #00cc77);
    color: #121212;
}

.btn-buy:hover {
    background: linear-gradient(45deg, #00cc77, #00ff99);
}

.btn-sell {
    background: linear-gradient(45deg, #ff4d4d, #cc3a3a);
    color: #fff;
}

.btn-sell:hover {
    background: linear-gradient(45deg, #cc3a3a, #ff4d4d);
}

.history-link {
    text-align: center;
    flex-shrink: 0;
}

.btn-history {
    background: linear-gradient(45deg, #00d4ff, #00b3cc);
    color: #fff;
}

.btn-history:hover {
    background: linear-gradient(45deg, #00b3cc, #00d4ff);
}

.footer {
    text-align: center;
    padding: 10px;
    background: var(--card-bg);
    border-radius: 15px;
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.2);
    backdrop-filter: blur(10px);
    flex-shrink: 0;
    transition: none;
}

.footer.transition-enabled {
    transition: background 0.5s ease;
}

.footer p {
    color: var(--subtext-color);
    font-size: 0.8rem;
    transition: none;
}

.footer p.transition-enabled {
    transition: color 0.5s ease;
}

.history-section {
    margin: 30px 0;
    flex: 1;
    overflow-y: auto;
}

.history-card {
    background: var(--card-bg);
    padding: 25px;
    border-radius: 15px;
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.2);
    backdrop-filter: blur(10px);
    overflow-x: auto;
    transition: none;
    flex: 1;
    overflow-y: auto;
}

.history-card.transition-enabled {
    transition: background 0.5s ease;
}

#history-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 1rem;
}

#history-table th,
#history-table td {
    padding: 15px;
    text-align: center;
    border-bottom: 1px solid var(--table-border);
    transition: none;
}

#history-table th.transition-enabled,
#history-table td.transition-enabled {
    transition: color 0.5s ease, background 0.5s ease;
}

#history-table th {
    background: var(--table-header-bg);
    color: #00d4ff;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1px;
}

#history-table td {
    background: transparent;
    color: var(--text-color);
}

#history-table tbody tr.buy {
    color: var(--stat-value-color);
    background: var(--buy-bg);
}

#history-table tbody tr.sell {
    color: #ff4d4d;
    background: var(--sell-bg);
}

#history-table tbody tr:hover {
    background: var(--hover-bg);
    transition: background 0.3s ease;
}

.btn-back {
    background: linear-gradient(45deg, #00d4ff, #00b3cc);
    color: #fff;
}

.btn-back:hover {
    background: linear-gradient(45deg, #00b3cc, #00d4ff);
}

::-webkit-scrollbar {
    width: 2px; 
}
  
  
::-webkit-scrollbar-track {
    background: #f1f1f1; 
}
  
  
::-webkit-scrollbar-thumb {
    background: #888; 
    border-radius: 8px; 
}
  
  
::-webkit-scrollbar-thumb:hover {
    background: #555;
}

@media (max-width: 768px) {
    * {
        font-size: 0.9em;
    }

    .container {
        padding: 5px;
    }

    .header {
        padding: 8px 10px;
    }

    .header h1 {
        font-size: 1.2rem;
    }

    .auth-section {
        flex-direction: column;
        gap: 5px;
    }

    .user-info {
        text-align: center;
        margin-bottom: 5px;
    }

    .stats-container {
        grid-template-columns: repeat(2, 1fr);
    }

    .stat-card {
        padding: 10px;
    }

    .stat-card h3 {
        font-size: 0.8rem;
    }

    .stat-value {
        font-size: 1.1rem;
    }

    .trade-card {
        padding: 10px;
    }

    .trade-buttons {
        flex-direction: row;
        justify-content: space-between;
    }

    .btn {
        padding: 6px 12px;
        font-size: 0.8rem;
    }
}

@media (max-width: 480px) {
    .stats-container {
        grid-template-columns: 1fr;
    }

    .stat-card {
        padding: 8px;
    }
    

    .trade-input {
        max-width: 120px;
    }

    .trade-buttons {
        gap: 5px;
    }

    #history-table th,
    #history-table td {
        padding: 6px;
        font-size: 0.75rem;
    }

    .history-card {
        padding: 10px;
    }
}

@media (max-width: 320px) {
    .header h1 {
        font-size: 1rem;
    }

    .btn {
        padding: 5px 10px;
        font-size: 0.7rem;
    }

    #history-table th,
    #history-table td {
        padding: 4px;
        font-size: 0.65rem;
    }
}
