/**
 * Graded Card Modal Styles
 *
 * Includes modal layout, form styles, and slab visualization
 */

/* ============================================
   Modal Overlay & Container
   ============================================ */

.graded-card-modal-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.8);
    z-index: 10000;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    overflow-y: auto;
}

.graded-card-modal-overlay.modal-open {
    display: flex;
}

.graded-card-modal {
    background: var(--surface-primary);
    border-radius: var(--radius-lg, 12px);
    width: 100%;
    max-width: 600px;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.4);
    animation: gradedModalSlideIn 0.3s ease-out;
}

@keyframes gradedModalSlideIn {
    from {
        opacity: 0;
        transform: translateY(-20px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* ============================================
   Modal Header
   ============================================ */

.graded-card-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--border-primary);
    flex-shrink: 0;
}

.graded-card-modal-title {
    margin: 0;
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text-primary);
}

.graded-card-modal-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.graded-modal-edit-btn,
.graded-modal-close-btn {
    background: transparent;
    border: none;
    padding: 0.5rem;
    border-radius: var(--radius-sm, 6px);
    cursor: pointer;
    color: var(--text-secondary);
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.graded-modal-edit-btn:hover,
.graded-modal-close-btn:hover {
    background: var(--surface-secondary);
    color: var(--text-primary);
}

/* ============================================
   Modal Body
   ============================================ */

.graded-card-modal-body {
    flex: 1;
    overflow-y: auto;
    padding: 1.5rem;
}

/* Card Info Section */
.graded-card-info {
    display: flex;
    gap: 1rem;
    padding-bottom: 1.5rem;
    border-bottom: 1px solid var(--border-secondary);
    margin-bottom: 1.5rem;
}

.graded-card-image {
    width: 100px;
    flex-shrink: 0;
}

.graded-card-image img {
    width: 100%;
    height: auto;
    border-radius: var(--radius-sm, 6px);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.graded-card-details {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.graded-card-number {
    font-size: 0.875rem;
    color: var(--text-secondary);
    font-family: monospace;
}

.graded-card-name {
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--text-primary);
}

.graded-card-set {
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.graded-card-rarity {
    font-size: 0.75rem;
    color: var(--text-tertiary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* ============================================
   Form Styles
   ============================================ */

.graded-card-form {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.graded-form-section h4 {
    margin: 0 0 1rem 0;
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.graded-form-section h5 {
    margin: 0 0 0.75rem 0;
    font-size: 0.8125rem;
    font-weight: 500;
    color: var(--text-tertiary);
}

.graded-form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

.graded-form-group {
    display: flex;
    flex-direction: column;
    gap: 0.375rem;
}

.graded-form-group.full-width {
    grid-column: 1 / -1;
}

.graded-form-group label {
    font-size: 0.8125rem;
    font-weight: 500;
    color: var(--text-secondary);
}

.graded-form-group input,
.graded-form-group select,
.graded-form-group textarea {
    padding: 0.625rem 0.75rem;
    background: var(--input-bg, var(--surface-secondary));
    border: 1px solid var(--input-border, var(--border-primary));
    border-radius: var(--radius-sm, 6px);
    color: var(--text-primary);
    font-size: 0.9375rem;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.graded-form-group input:focus,
.graded-form-group select:focus,
.graded-form-group textarea:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}

.graded-form-group input::placeholder,
.graded-form-group textarea::placeholder {
    color: var(--text-tertiary);
}

.graded-form-group textarea {
    resize: vertical;
    min-height: 80px;
}

.input-with-prefix {
    position: relative;
    display: flex;
    align-items: center;
}

.input-prefix {
    position: absolute;
    left: 0.75rem;
    color: var(--text-tertiary);
    pointer-events: none;
}

.input-with-prefix input {
    padding-left: 1.75rem;
    width: 100%;
}

.grade-label {
    font-size: 0.75rem;
    color: var(--color-primary);
    font-weight: 500;
    min-height: 1rem;
}

/* Subgrades Section */
.graded-subgrades {
    background: var(--surface-secondary);
    border-radius: var(--radius-md, 8px);
    padding: 1rem;
    margin-top: 0.5rem;
}

.subgrades-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 0.75rem;
}

.subgrades-grid .graded-form-group {
    gap: 0.25rem;
}

.subgrades-grid label {
    font-size: 0.75rem;
}

.subgrades-grid input {
    padding: 0.5rem;
    font-size: 0.875rem;
    text-align: center;
}

/* ============================================
   View Details Section
   ============================================ */

.graded-view-details {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
    padding: 1rem;
    background: var(--surface-secondary);
    border-radius: var(--radius-md, 8px);
    margin-top: 1rem;
}

.graded-detail-row {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.graded-detail-row.full-width {
    grid-column: 1 / -1;
}

.detail-label {
    font-size: 0.75rem;
    color: var(--text-tertiary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.detail-value {
    font-size: 0.9375rem;
    color: var(--text-primary);
}

/* ============================================
   Slab Visualization
   ============================================ */

.graded-slab-container {
    display: flex;
    justify-content: center;
    padding: 2rem 0;
}

.slab {
    --slab-color: #616161;
    width: 200px;
    background: linear-gradient(145deg, #f5f5f5, #e0e0e0);
    border-radius: 8px;
    padding: 8px;
    box-shadow:
        0 10px 40px rgba(0, 0, 0, 0.3),
        inset 0 1px 0 rgba(255, 255, 255, 0.5);
    position: relative;
    overflow: hidden;
}

/* Slab shine effect */
.slab::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(
        135deg,
        rgba(255, 255, 255, 0.4) 0%,
        transparent 40%,
        transparent 60%,
        rgba(255, 255, 255, 0.1) 100%
    );
    pointer-events: none;
    border-radius: 8px;
}

.slab-header {
    background: var(--slab-color);
    color: white;
    padding: 0.5rem 0.75rem;
    border-radius: 4px 4px 0 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.slab-company {
    font-size: 0.875rem;
    font-weight: 700;
    letter-spacing: 1px;
}

.slab-grade-info {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
}

.slab-grade-label {
    font-size: 0.5rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    opacity: 0.9;
}

.slab-grade-number {
    font-size: 1.5rem;
    font-weight: 700;
    line-height: 1;
}

.slab-subgrades {
    display: flex;
    justify-content: center;
    gap: 0.375rem;
    padding: 0.25rem 0.5rem;
    background: var(--slab-color);
    color: white;
    font-size: 0.5625rem;
    opacity: 0.9;
}

.slab-subgrades span {
    padding: 0.125rem 0.25rem;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 2px;
}

.slab-card-window {
    background: white;
    padding: 6px;
    margin: 4px 0;
}

.slab-card-window img {
    width: 100%;
    height: auto;
    display: block;
    border-radius: 2px;
}

.slab-footer {
    background: var(--slab-color);
    color: white;
    padding: 0.5rem;
    border-radius: 0 0 4px 4px;
    text-align: center;
}

.slab-card-number {
    font-size: 0.6875rem;
    font-family: monospace;
    opacity: 0.9;
}

.slab-card-name {
    font-size: 0.75rem;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.slab-game {
    font-size: 0.5625rem;
    opacity: 0.8;
    margin-top: 0.125rem;
}

/* Company-specific slab styles */
.slab-psa {
    --slab-color: #d32f2f;
}

.slab-bgs {
    --slab-color: #1976d2;
}

.slab-cgc {
    --slab-color: #7b1fa2;
}

.slab-sgc {
    --slab-color: #2e7d32;
}

.slab-other {
    --slab-color: #616161;
}

/* ============================================
   Modal Footer
   ============================================ */

.graded-card-modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 0.75rem;
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--border-primary);
    flex-shrink: 0;
}

.graded-modal-btn {
    padding: 0.625rem 1.25rem;
    font-size: 0.9375rem;
    font-weight: 500;
    border-radius: var(--radius-md, 8px);
    border: none;
    cursor: pointer;
    transition: all 0.2s;
}

.graded-modal-btn-primary {
    background: var(--color-primary);
    color: white;
}

.graded-modal-btn-primary:hover {
    background: var(--color-primary-hover, #2563eb);
}

.graded-modal-btn-secondary {
    background: var(--surface-secondary);
    color: var(--text-primary);
    border: 1px solid var(--border-primary);
}

.graded-modal-btn-secondary:hover {
    background: var(--surface-tertiary);
}

.graded-modal-btn-danger {
    background: var(--color-error, #dc2626);
    color: white;
}

.graded-modal-btn-danger:hover {
    background: #b91c1c;
}

/* ============================================
   Responsive Styles
   ============================================ */

@media (max-width: 640px) {
    .graded-card-modal-overlay {
        padding: 0;
        align-items: flex-end;
    }

    .graded-card-modal {
        max-width: 100%;
        max-height: 95vh;
        border-radius: var(--radius-lg, 12px) var(--radius-lg, 12px) 0 0;
        animation: gradedModalSlideUp 0.3s ease-out;
    }

    @keyframes gradedModalSlideUp {
        from {
            opacity: 0;
            transform: translateY(100%);
        }
        to {
            opacity: 1;
            transform: translateY(0);
        }
    }

    .graded-form-row {
        grid-template-columns: 1fr;
    }

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

    .graded-view-details {
        grid-template-columns: 1fr;
    }

    .slab {
        width: 160px;
    }

    .graded-card-modal-footer {
        flex-direction: column;
    }

    .graded-modal-btn {
        width: 100%;
    }
}

/* ============================================
   Utility Classes
   ============================================ */

.hidden {
    display: none !important;
}

body.graded-modal-open {
    overflow: hidden;
}
