/* Buttons */
button {
    background: #0f172a;
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.3s, transform 0.1s;
    margin-top: 10px;
}

button:hover {
    background: #1e293b;
}

button:active {
    transform: scale(0.98);
}

button:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.edit-btn {
    background: transparent;
    border: 1px solid #e2e8f0;
    padding: 8px;
    border-radius: 6px;
    cursor: pointer;
    color: #64748b;
    transition: all 0.2s;
    margin: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.edit-btn:hover {
    background: #fff;
    border-color: #cbd5e1;
    color: #0f172a;
}

.cancel-btn {
    background: #e2e8f0;
    color: #475569;
}

.cancel-btn:hover {
    background: #cbd5e1;
}

.danger-btn {
    background: #ef4444;
    color: #ffffff;
    padding: 8px;
    border-radius: 6px;
    min-width: 0;
    height: 36px;
    width: 36px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin: 0;
}

.danger-btn:hover {
    background: #dc2626;
}

.danger-btn:disabled {
    background: #fca5a5;
    cursor: not-allowed;
    transform: none;
}

.danger-btn-wide {
    height: 48px;
    width: 150px;
    padding: 0 24px;
    margin: 0;
}

.save-btn {
    background: #10b981;
    margin: 0;
}

.save-btn:hover {
    background: #059669;
}

.fetch-button {
    background: #10b981;
    margin: 0;
    display: flex;
    align-items: center;
    gap: 8px;
}

.fetch-button:hover {
    background: #059669;
}

.fetch-button svg {
    width: 16px;
    height: 16px;
}

.button-group {
    display: flex;
    gap: 10px;
    margin-top: 10px;
}

.btn-small {
    display: inline-block;
    padding: 6px 12px;
    background: #0f172a;
    color: white;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 600;
    text-decoration: none;
    transition: background 0.2s;
}

.btn-small:hover {
    background: #1e293b;
    text-decoration: none;
    color: white;
}

/* Forms and Inputs */
label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
    color: #555;
}

input[type="text"] {
    width: 100%;
    padding: 12px;
    border: 2px solid #e0e0e0;
    border-radius: 6px;
    font-size: 14px;
    transition: border-color 0.3s;
}

input[type="text"]:focus {
    outline: none;
    border-color: #0f172a;
}

#flashcard-note {
    width: 100%;
    resize: vertical;
    padding: 12px 14px;
    font-family: inherit;
    font-size: 14px;
    line-height: 1.5;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    transition: border-color 0.2s;
}

#flashcard-note:focus {
    outline: none;
    border-color: #7c3aed;
}

/* Messages */
.message {
    padding: 12px 16px;
    border-radius: 6px;
    margin-bottom: 20px;
    font-size: 14px;
}

.success {
    background: #d1fae5;
    color: #065f46;
    border-left: 4px solid #10b981;
}

.error {
    background: #fee2e2;
    color: #991b1b;
    border-left: 4px solid #ef4444;
}

.info {
    background: #e2e8f0;
    color: #0f172a;
    border-left: 4px solid #475569;
}

.learn-callout {
    display: flex;
    gap: 14px;
    align-items: flex-start;
}

.learn-callout .callout-badge {
    background: #0f172a;
    color: #ffffff;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.6px;
    padding: 4px 10px;
    border-radius: 999px;
    text-transform: uppercase;
    white-space: nowrap;
}

.learn-callout h3 {
    margin: 0 0 6px;
    font-size: 16px;
}

.learn-callout p {
    margin: 0 0 8px;
}

.learn-callout ul {
    margin: 0 0 0 16px;
    padding: 0;
}

.learn-callout li {
    margin: 2px 0;
}

.success-message {
    position: fixed;
    top: 20px;
    right: 20px;
    background: #10b981;
    color: white;
    padding: 16px 24px;
    border-radius: 6px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    z-index: 2000;
    animation: slideIn 0.3s ease-out;
}

.error-message {
    position: fixed;
    top: 20px;
    right: 20px;
    background: #ef4444;
    color: white;
    padding: 16px 24px;
    border-radius: 6px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    z-index: 2000;
    animation: slideIn 0.3s ease-out;
}

@keyframes slideIn {
    from {
        transform: translateX(400px);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

/* Tables */
.table-wrapper {
    overflow: visible;
}

table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 20px;
    background: white;
    border-radius: 8px;
    overflow: visible;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

thead {
    background: #0f172a;
    color: white;
}

th {
    padding: 14px;
    text-align: left;
    font-weight: 600;
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

th.sortable {
    cursor: pointer;
    user-select: none;
    transition: background 0.2s;
}

th.sortable:hover {
    background: #1e293b;
}

.sort-arrow {
    display: inline-block;
    margin-left: 4px;
    font-size: 12px;
    opacity: 0.7;
}

td {
    padding: 14px;
    border-bottom: 1px solid #f0f0f0;
}

tbody,
tbody tr,
tbody td,
tbody td *,
tbody a,
tbody button {
    cursor: pointer !important;
}

tbody tr {
    position: relative;
}

tbody tr:hover {
    background: #f8f9fa;
}

tbody tr:last-child td {
    border-bottom: none;
}

td:last-child {
    position: relative;
}

.flashcard-table {
    width: 100%;
    table-layout: fixed;
}

.flashcard-table th,
.flashcard-table td {
    padding: 10px 12px;
    white-space: normal;
}

.flashcard-table td {
    word-break: break-word;
}

.flashcard-select-col {
    width: 32px;
}

.flashcard-select {
    width: 16px;
    height: 16px;
}

.flashcard-position-col {
    width: 90px;
}

.flashcard-row {
    cursor: pointer;
    transition: background-color 0.2s;
}

.flashcard-row:hover {
    background-color: #f8fafc;
}

/* Date Cells */
.date-cell {
    position: relative;
}

.date-cell::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    background: #0f172a;
    color: white;
    padding: 6px 10px;
    border-radius: 4px;
    font-size: 12px;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s;
    margin-bottom: 5px;
    z-index: 10;
}

.date-cell:hover::after {
    opacity: 1;
}

/* Color Badges and Squares */
.color-badge {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.white-badge {
    background: #f1f5f9;
    color: #475569;
    border: 1px solid #cbd5e1;
}

.black-badge {
    background: #0f172a;
    color: #ffffff;
}

.color-square {
    width: 24px;
    height: 24px;
    border-radius: 4px;
    display: inline-block;
}

.white-square {
    background: #f1f5f9;
    border: 2px solid #cbd5e1;
}

.black-square {
    background: #0f172a;
    border: 2px solid #0f172a;
}

/* Result Badges */
.result-box {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    border-radius: 4px;
    font-weight: 600;
    font-size: 13px;
    position: relative;
}

.result-win {
    background: #10b981;
    color: white;
}

.result-draw {
    background: #94a3b8;
    color: white;
}

.result-loss {
    background: #ef4444;
    color: white;
}

.result-box::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    background: #0f172a;
    color: white;
    padding: 6px 10px;
    border-radius: 4px;
    font-size: 12px;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s;
    margin-bottom: 5px;
    z-index: 10;
}

.result-box:hover::after {
    opacity: 1;
}

/* Opponent and Time Control Tooltips */
.opponent-cell,
.time-control-cell {
    position: relative;
}

.opponent-cell::after,
.time-control-cell::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    background: #0f172a;
    color: white;
    padding: 6px 10px;
    border-radius: 4px;
    font-size: 12px;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s;
    margin-bottom: 5px;
    z-index: 10;
}

.opponent-cell:hover::after,
.time-control-cell:hover::after {
    opacity: 1;
}

/* Board Preview */
.board-preview {
    display: none;
    position: absolute;
    left: 100%;
    top: 50%;
    transform: translateY(-50%);
    margin-left: 10px;
    z-index: 1000;
    background: white;
    border: 2px solid #0f172a;
    border-radius: 4px;
    padding: 4px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    pointer-events: none;
}

.board-preview img {
    display: block;
    width: 200px;
    height: 200px;
}

.game-row:hover .board-preview,
.flashcard-row:hover .board-preview {
    display: block;
}

/* Flashcard Badge */
.flashcard-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: #7c3aed;
    font-size: 13px;
    font-weight: 600;
}

.flashcard-badge svg {
    flex-shrink: 0;
    width: 24px;
    height: 24px;
}

.flashcard-move-cell {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
}

.flashcard-eval .evaluation-square {
    margin-left: 0;
}

.flashcard-move-quality .move-quality-badge {
    margin-right: 0;
}

/* Move Quality and Evaluation Badges */
.move-quality-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    color: #ffffff;
    font-size: 11px;
    font-weight: 700;
    line-height: 18px;
    text-align: center;
    margin-right: 6px;
    vertical-align: middle;
}

.evaluation-square {
    width: auto;
    min-width: 28px;
    height: 24px;
    padding: 0 6px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    font-weight: 700;
    line-height: 1;
    vertical-align: middle;
    margin-left: 6px;
}

.evaluation-square.white-square {
    color: #475569;
}

.evaluation-square.black-square {
    color: #ffffff;
}

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

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

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px;
}

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

.modal-close {
    background: transparent;
    border: none;
    font-size: 28px;
    cursor: pointer;
    color: #64748b;
    padding: 0;
    margin: 0;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-close:hover {
    color: #0f172a;
    background: #f1f5f9;
    border-radius: 4px;
}

.modal-body {
    padding: 20px;
}

.modal-footer {
    display: flex;
    gap: 10px;
    padding: 20px;
    justify-content: flex-end;
}

.modal-footer button {
    flex: 1;
    min-width: 0;
    height: 48px;
    padding: 0 24px;
    margin: 0;
}

.flashcard-preview {
    background: #f8f9fa;
    padding: 16px;
    border-radius: 6px;
    margin-bottom: 16px;
}

.flashcard-info {
    line-height: 1.6;
}

.flashcard-info strong {
    display: inline-block;
    min-width: 120px;
}

/* Animations */
@keyframes spin {
    from {
        transform: rotate(0deg);
    }
    to {
        transform: rotate(360deg);
    }
}

/* Board Icon */
.board-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 4px;
    border-radius: 4px;
    transition: background 0.2s;
}

.board-icon:hover {
    background: #f1f5f9;
    text-decoration: none;
}

.board-icon svg {
    display: block;
}

/* Mobile Responsive Components */
@media (max-width: 768px) {
    .table-wrapper {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .board-preview {
        display: none !important;
    }

    table {
        width: auto;
        min-width: 100%;
    }

    th, td {
        padding: 10px 12px;
        font-size: 13px;
        white-space: nowrap;
        vertical-align: middle;
    }

    th:nth-child(1), td:nth-child(1) { min-width: 120px; }
    th:nth-child(2), td:nth-child(2) { min-width: 50px; }
    th:nth-child(3), td:nth-child(3) { min-width: 100px; }
    th:nth-child(4), td:nth-child(4) { min-width: 90px; }
    th:nth-child(5), td:nth-child(5) { min-width: 60px; }
    th:nth-child(6), td:nth-child(6) { min-width: 50px; }
}
