/* 基本設定 */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Hiragino Sans', 'Noto Sans CJK JP', sans-serif;
    line-height: 1.6;
    color: #333;
    background-color: #f5f5f5;
}

/* ログインページ */
.login-container {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.login-form {
    background: white;
    padding: 2rem;
    border-radius: 10px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.1);
    width: 100%;
    max-width: 400px;
}

.login-form h1 {
    text-align: center;
    margin-bottom: 2rem;
    color: #333;
    font-size: 1.8rem;
}

/* フォーム要素 */
.form-group {
    margin-bottom: 1rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
    color: #555;
}

.form-group input {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid #ddd;
    border-radius: 5px;
    font-size: 1rem;
    transition: border-color 0.3s ease;
}

.form-group input:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 2px rgba(102, 126, 234, 0.2);
}

/* ボタン */
button {
    cursor: pointer;
    border: none;
    border-radius: 5px;
    padding: 0.75rem 1.5rem;
    font-size: 1rem;
    font-weight: 500;
    transition: all 0.3s ease;
}

.btn-primary {
    background: #667eea;
    color: white;
}

.btn-primary:hover {
    background: #5a6fd8;
    transform: translateY(-1px);
}

.btn-secondary {
    background: #6c757d;
    color: white;
}

.btn-secondary:hover {
    background: #5a6268;
}

.btn-danger {
    background: #dc3545;
    color: white;
}

.btn-danger:hover {
    background: #c82333;
    transform: translateY(-1px);
}

.btn-logout {
    background: #dc3545;
    color: white;
    padding: 0.5rem 1rem;
    font-size: 0.9rem;
}

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

.btn-search {
    background: #28a745;
    color: white;
    padding: 0.5rem 1rem;
}

.btn-search:hover {
    background: #218838;
}

.btn-page {
    background: #f8f9fa;
    color: #333;
    border: 1px solid #dee2e6;
    padding: 0.5rem 1rem;
}

.btn-page:hover {
    background: #e9ecef;
}

.btn-page:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

/* メインコンテナ */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 1rem;
}

/* ヘッダー */
header {
    background: white;
    padding: 1rem 2rem;
    border-radius: 10px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    margin-bottom: 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

header h1 {
    color: #333;
    font-size: 1.8rem;
}

.header-info {
    display: flex;
    align-items: center;
    gap: 1rem;
}

#user-info {
    color: #666;
    font-size: 0.9rem;
}

/* セクション */
.user-form-section,
.user-list-section {
    background: white;
    padding: 2rem;
    border-radius: 10px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    margin-bottom: 2rem;
}

.user-form-section h2,
.user-list-section h2 {
    margin-bottom: 1.5rem;
    color: #333;
    font-size: 1.5rem;
    border-bottom: 2px solid #667eea;
    padding-bottom: 0.5rem;
}

/* フォームレイアウト */
.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
    margin-bottom: 1rem;
}

.form-actions {
    display: flex;
    gap: 1rem;
    justify-content: flex-end;
    margin-top: 1.5rem;
}

/* リストコントロール */
.list-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
    gap: 1rem;
}

.search-box {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.search-box input {
    padding: 0.5rem;
    border: 1px solid #ddd;
    border-radius: 5px;
    width: 250px;
}

.bulk-actions {
    display: flex;
    gap: 0.5rem;
}

/* テーブル */
.table-container {
    overflow-x: auto;
    margin-bottom: 1rem;
}

.user-table {
    width: 100%;
    border-collapse: collapse;
    background: white;
    table-layout: fixed;
}

/* Column widths */
.user-table th:nth-child(1),
.user-table td:nth-child(1) {
    width: 40px;
}

.user-table th:nth-child(2),
.user-table td:nth-child(2) {
    width: 15%;
}

.user-table th:nth-child(3),
.user-table td:nth-child(3) {
    width: 18%;
}

.user-table th:nth-child(4),
.user-table td:nth-child(4) {
    width: 12%;
}

.user-table th:nth-child(5),
.user-table td:nth-child(5) {
    width: 10%;
}

.user-table th:nth-child(6),
.user-table td:nth-child(6) {
    width: 15%;
}

.user-table th:nth-child(7),
.user-table td:nth-child(7) {
    width: 15%;
}

.user-table th:nth-child(8),
.user-table td:nth-child(8) {
    width: 15%;
    min-width: 180px;
}

.user-table th,
.user-table td {
    padding: 0.75rem;
    text-align: left;
    border-bottom: 1px solid #dee2e6;
    overflow: hidden;
    text-overflow: ellipsis;
}

.user-table th {
    background: #f8f9fa;
    font-weight: 600;
    color: #333;
    position: sticky;
    top: 0;
}

.user-table tr:hover {
    background: #f5f5f5;
}

.user-table .actions {
    display: flex;
    gap: 0.5rem;
    flex-wrap: nowrap;
    min-width: 150px;
}

.user-table .actions button {
    padding: 0.25rem 0.5rem;
    font-size: 0.8rem;
    white-space: nowrap;
}

/* ページネーション */
.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 1rem;
}

#pageInfo {
    font-weight: 500;
    color: #666;
}

/* モーダル */
.modal {
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    display: flex;
    justify-content: center;
    align-items: center;
}

.modal-content {
    background: white;
    border-radius: 10px;
    width: 90%;
    max-width: 500px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 2rem;
    border-bottom: 1px solid #dee2e6;
}

.modal-header h3 {
    margin: 0;
    color: #333;
}

.close {
    font-size: 2rem;
    font-weight: bold;
    cursor: pointer;
    color: #999;
}

.close:hover {
    color: #333;
}

.modal form {
    padding: 2rem;
}

.modal .form-group {
    margin-bottom: 1.5rem;
}

.modal .form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
    color: #333;
}

.modal .form-group input {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid #ddd;
    border-radius: 5px;
    font-size: 1rem;
    color: #333;
}

.modal-actions {
    display: flex;
    gap: 1rem;
    justify-content: flex-end;
    margin-top: 1.5rem;
}

/* 証明書管理 */
.cert-actions {
    display: flex;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

#certList {
    background: #f8f9fa;
    padding: 1rem;
    border-radius: 5px;
    min-height: 200px;
}

/* ローディング */
.loading {
    position: fixed;
    z-index: 2000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    display: flex;
    justify-content: center;
    align-items: center;
}

.loading-content {
    background: white;
    padding: 2rem;
    border-radius: 10px;
    text-align: center;
}

.spinner {
    border: 4px solid #f3f3f3;
    border-top: 4px solid #667eea;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    animation: spin 1s linear infinite;
    margin: 0 auto 1rem;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* メッセージ */
.message {
    position: fixed;
    top: 20px;
    right: 20px;
    padding: 1rem 1.5rem;
    border-radius: 5px;
    color: white;
    font-weight: 500;
    z-index: 1500;
    max-width: 400px;
    min-height: 50px;
    word-wrap: break-word;
    word-break: break-word;
    line-height: 1.5;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.message.success {
    background: #28a745;
}

.message.error {
    background: #dc3545;
    color: white;
}

.message.info {
    background: #17a2b8;
}

.message.warning {
    background: #ffc107;
    color: #333;
}

/* エラー表示 */
.error {
    color: #dc3545;
    font-size: 0.9rem;
    margin-top: 0.5rem;
    padding: 0.5rem;
    background: #f8d7da;
    border: 1px solid #f5c6cb;
    border-radius: 5px;
}

/* レスポンシブ対応 */
@media (max-width: 768px) {
    .container {
        padding: 0.5rem;
    }
    
    header {
        flex-direction: column;
        gap: 1rem;
        text-align: center;
    }
    
    .form-row {
        grid-template-columns: 1fr;
    }
    
    .list-controls {
        flex-direction: column;
        align-items: stretch;
    }
    
    .search-box {
        justify-content: center;
    }
    
    .search-box input {
        width: 100%;
        max-width: 250px;
    }
    
    .bulk-actions {
        justify-content: center;
    }
    
    .form-actions,
    .modal-actions {
        flex-direction: column;
    }
    
    .user-table {
        font-size: 0.9rem;
    }

    .user-table .actions {
        /* Keep horizontal layout even on mobile */
        flex-direction: row;
    }

    .user-table .actions button {
        font-size: 0.75rem;
        padding: 0.2rem 0.4rem;
    }
}