/* ================================
   全体レイアウト
================================ */

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    padding: 0;
    font-family: "Helvetica", "Arial", sans-serif;
    background: #f5f7fa;
    color: #333;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.ts-main {
    max-width: 1200px;
    margin: 40px auto;
    padding: 0 20px;
    flex: 1;
    width: 100%;
}

/* ================================
   ヘッダー
================================ */

.ts-header {
    width: 100%;
    background: #2c3e50;
    padding: 0 20px;
    box-sizing: border-box;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    position: sticky;
    top: 0;
    z-index: 100;
}

.ts-header-inner {
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 0;
    flex-wrap: wrap;
    gap: 8px;
}

.ts-header-left {
    display: flex;
    align-items: center;
}

.brand-link {
    color: #fff;
    text-decoration: none;
    font-size: 20px;
    font-weight: bold;
}

.brand-link:hover {
    opacity: 0.8;
}

.brand-name {
    letter-spacing: 1px;
}

.ts-header-right {
    display: flex;
    align-items: center;
    gap: 16px;
    flex-wrap: wrap;
}

.user-name {
    color: #ecf0f1;
    font-size: 14px;
}

.admin-link {
    color: #f1c40f;
    text-decoration: none;
    font-size: 14px;
    padding: 6px 12px;
    border: 1px solid #f1c40f;
    border-radius: 4px;
    transition: all 0.3s;
}

.admin-link:hover {
    background: #f1c40f;
    color: #2c3e50;
}

.logout-btn {
    color: #fff;
    background: #e74c3c;
    padding: 6px 14px;
    border-radius: 4px;
    text-decoration: none;
    font-size: 14px;
    transition: background 0.3s;
}

.logout-btn:hover {
    background: #c0392b;
}

.login-btn {
    color: #fff;
    background: #3498db;
    padding: 6px 14px;
    border-radius: 4px;
    text-decoration: none;
    font-size: 14px;
    transition: background 0.3s;
}

.login-btn:hover {
    background: #2980b9;
}

/* ================================
   フラッシュメッセージ
================================ */

.flash-messages {
    max-width: 1200px;
    margin: 16px auto 0;
    padding: 0 20px;
    width: 100%;
}

.flash-message {
    padding: 12px 20px;
    border-radius: 6px;
    margin-bottom: 10px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 14px;
    animation: slideDown 0.3s ease;
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.flash-success {
    background: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}

.flash-error {
    background: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}

.flash-warning {
    background: #fff3cd;
    color: #856404;
    border: 1px solid #ffeeba;
}

.flash-info {
    background: #d1ecf1;
    color: #0c5460;
    border: 1px solid #bee5eb;
}

.flash-close {
    background: none;
    border: none;
    font-size: 20px;
    cursor: pointer;
    color: inherit;
    opacity: 0.6;
    padding: 0 0 0 12px;
}

.flash-close:hover {
    opacity: 1;
}

/* ================================
   ポータル画面
================================ */

.portal-container {
    background: #fff;
    padding: 25px;
    border-radius: 8px;
    box-shadow: 0 2px 6px rgba(0,0,0,0.1);
}

.user-info h2 {
    margin-top: 0;
}

.ticket-count strong {
    font-size: 20px;
    color: #2980b9;
    transition: color 0.3s ease;
}

/* チケット購入セクション */
.ticket-purchase {
    margin-top: 25px;
}

.btn-primary {
    display: inline-block;
    background: #3498db;
    color: #fff;
    padding: 10px 18px;
    border-radius: 6px;
    text-decoration: none;
    font-weight: bold;
    border: none;
    cursor: pointer;
    transition: background 0.3s, opacity 0.3s;
}

.btn-primary:hover {
    background: #2980b9;
}

.btn-primary:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}


/* アプリ一覧 - アイテム全体 */
.app-item {
    background: #f9f9f9;
    padding: 15px 20px;
    margin-bottom: 12px;
    border-radius: 6px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 15px;
    flex-wrap: wrap;
}

/* アプリ名 - 幅を広げる */
.app-name {
    font-size: 18px;
    font-weight: bold;
    flex: 3;  /* 他の要素より広く */
    min-width: 160px;
}

/* タグ - 右に寄せる */
.app-tag {
    padding: 4px 14px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: bold;
    white-space: nowrap;
    flex-shrink: 0;
    margin-left: auto;  /* 右寄せ */
}

/* ボタン - 右端に固定 */
.btn-secondary {
    background: #7f8c8d;
    color: #fff;
    padding: 8px 16px;
    border-radius: 4px;
    text-decoration: none;
    font-size: 14px;
    white-space: nowrap;
    flex-shrink: 0;
    transition: background 0.2s;
}

.btn-secondary:hover {
    background: #636e72;
}

.btn-secondary.disabled {
    opacity: 0.4;
    cursor: not-allowed;
    pointer-events: none;
}

.need-ticket {
    background: #ffe700;
    color: #4a2f00;
}

.free {
    background: #2ecc71;
    color: #fff;
}

/* レスポンシブ（スマホ） */
@media (max-width: 600px) {
    .app-item {
        flex-direction: column;
        align-items: stretch;
        gap: 10px;
        padding: 12px 16px;
    }

    .app-name {
        flex: none;
        min-width: auto;
    }

    .app-tag {
        margin-left: 0;
        align-self: flex-start;
    }

    .btn-secondary {
        align-self: flex-end;
    }
}


/* ================================
   チケット購入画面
================================ */

.purchase-container {
    background: #fff;
    padding: 25px;
    border-radius: 8px;
    box-shadow: 0 2px 6px rgba(0,0,0,0.1);
    max-width: 600px;
    margin: 0 auto;
}

.product-info {
    margin-top: 20px;
    padding: 15px;
    background: #f8f9fa;
    border-radius: 6px;
    border: 1px solid #e1e8ed;
}

.product-info h3 {
    margin-top: 0;
}

.stripe-section {
    margin-top: 30px;
    text-align: center;
}

.stripe-btn {
    background: #6772e5;
    color: #fff;
    padding: 12px 30px;
    border: none;
    border-radius: 6px;
    font-size: 16px;
    font-weight: bold;
    cursor: pointer;
    transition: background 0.3s, opacity 0.3s;
}

.stripe-btn:hover {
    background: #5469d4;
}

.stripe-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

#loading-message {
    color: #7f8c8d;
    font-size: 14px;
}

#error-message {
    color: #e74c3c;
    font-size: 14px;
    background: #fdf2f2;
    padding: 10px;
    border-radius: 4px;
    border: 1px solid #f5c6cb;
}

/* ================================
   管理ダッシュボード
================================ */

.admin-container {
    background: #fff;
    padding: 25px;
    border-radius: 8px;
    box-shadow: 0 2px 6px rgba(0,0,0,0.1);
}

.admin-links {
    list-style: none;
    padding: 0;
}

.admin-link-item {
    margin-bottom: 15px;
}

.admin-link-item a {
    display: inline-block;
    padding: 10px 20px;
    background: #3498db;
    color: #fff;
    text-decoration: none;
    border-radius: 4px;
    transition: background 0.2s;
}

.admin-link-item a:hover {
    background: #2980b9;
}

/* ================================
   管理画面 - テーブル
================================ */

.table-responsive {
    overflow-x: auto;
    margin: 20px 0;
}

.admin-table {
    width: 100%;
    border-collapse: collapse;
    background: #fff;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.admin-table thead {
    background: #2c3e50;
    color: #fff;
}

.admin-table th {
    padding: 12px 15px;
    text-align: left;
    font-weight: 600;
    font-size: 14px;
}

.admin-table td {
    padding: 10px 15px;
    border-bottom: 1px solid #ecf0f1;
    font-size: 13px;
}

.admin-table tbody tr:hover {
    background: #f8f9fa;
}

.admin-table tbody tr:last-child td {
    border-bottom: none;
}

.no-data {
    text-align: center;
    padding: 30px;
    color: #95a5a6;
    font-style: italic;
}

.payment-id {
    font-size: 12px;
    background: #f1f2f6;
    padding: 2px 6px;
    border-radius: 3px;
    font-family: 'Courier New', monospace;
    word-break: break-all;
}

.amount {
    font-weight: 600;
    color: #27ae60;
}

.tickets {
    font-weight: 600;
    color: #2980b9;
}

/* ================================
   集計情報
================================ */

.payment-summary {
    background: #f8f9fa;
    padding: 20px;
    border-radius: 8px;
    margin-top: 30px;
    border: 1px solid #e1e8ed;
}

.payment-summary h3 {
    margin-top: 0;
    color: #2c3e50;
    font-size: 16px;
}

.summary-list {
    list-style: none;
    padding: 0;
    margin: 10px 0 0 0;
    display: flex;
    flex-wrap: wrap;
    gap: 20px;
}

.summary-list li {
    padding: 8px 16px;
    background: #fff;
    border-radius: 4px;
    border: 1px solid #e1e8ed;
    font-size: 14px;
}

.summary-list li strong {
    color: #2c3e50;
}

/* ================================
   フッター
================================ */

.ts-footer {
    text-align: center;
    padding: 20px;
    color: #95a5a6;
    font-size: 13px;
    border-top: 1px solid #ecf0f1;
    margin-top: 40px;
    background: #fff;
}

/* ================================
   404 ページ
================================ */

.text-danger {
    color: #e74c3c;
}

.btn {
    display: inline-block;
    padding: 10px 18px;
    border-radius: 6px;
    text-decoration: none;
    background: #3498db;
    color: #fff;
    border: none;
    cursor: pointer;
    transition: background 0.2s;
}

.btn:hover {
    background: #2980b9;
}

/* ================================
   コピーボタン
================================ */

.copy-btn {
    background: #7f8c8d;
    color: #fff;
    border: none;
    padding: 4px 10px;
    border-radius: 3px;
    font-size: 12px;
    cursor: pointer;
    transition: background 0.2s;
}

.copy-btn:hover {
    background: #636e72;
}

/* ================================
   レスポンシブ対応
================================ */

/* タブレット */
@media (max-width: 768px) {
    .ts-header-inner {
        flex-direction: column;
        gap: 8px;
        padding: 10px 0;
    }

    .ts-header-right {
        flex-wrap: wrap;
        justify-content: center;
        gap: 10px;
    }

    .brand-name {
        font-size: 17px;
    }

    .user-name {
        font-size: 12px;
    }

    .logout-btn,
    .login-btn,
    .admin-link {
        font-size: 12px;
        padding: 4px 10px;
    }

    .flash-messages {
        margin-top: 10px;
        padding: 0 12px;
    }

    .flash-message {
        font-size: 13px;
        padding: 10px 14px;
    }

    .app-item {
        grid-template-columns: 1fr;
        gap: 8px;
    }

    .app-tag {
        justify-self: start;
    }

    .btn-secondary {
        justify-self: start;
    }

    .admin-table th,
    .admin-table td {
        padding: 8px 10px;
        font-size: 12px;
    }

    .summary-list {
        flex-direction: column;
        gap: 10px;
    }

    .summary-list li {
        padding: 6px 12px;
    }

    .purchase-container {
        padding: 15px;
    }

    .ts-main {
        margin: 20px auto;
    }
}

/* スマートフォン */
@media (max-width: 480px) {
    .brand-name {
        font-size: 15px;
    }

    .ts-header {
        padding: 0 12px;
    }

    .ts-header-right {
        gap: 6px;
    }

    .user-name {
        font-size: 11px;
    }

    .logout-btn,
    .login-btn,
    .admin-link {
        font-size: 11px;
        padding: 3px 8px;
    }

    .app-name {
        font-size: 15px;
    }

    .app-tag {
        font-size: 10px;
        padding: 2px 8px;
    }

    .btn-secondary {
        font-size: 12px;
        padding: 5px 12px;
    }

    .admin-table {
        font-size: 11px;
    }

    .admin-table th,
    .admin-table td {
        padding: 6px 8px;
    }

    .payment-id {
        font-size: 10px;
    }

    .stripe-btn {
        padding: 10px 20px;
        font-size: 14px;
        width: 100%;
    }
}
