/**
 * Portfolio Creation Modal Styles
 * Theme-aware modal for creating portfolios via upload, templates, or code
 * Base modal styles migrated to modal-system.css
 */

/* Create Modal Specific Styles */
#createPortfolioModal {
    width: 100vw;
    box-sizing: border-box;
}

.title-status {
    min-height: 1.25rem;
    margin: var(--theme-space-2) 0 0;
    font-size: var(--theme-text-xs);
}

.title-status--checking {
    color: var(--theme-warning);
}

.title-status--available {
    color: var(--theme-success);
}

.title-status--taken,
.title-status--invalid {
    color: var(--theme-error);
}

#modalNextBtn:disabled {
    cursor: not-allowed;
    opacity: 0.5;
}

/* Code Editor Styles */
.code-editor-tabs {
    display: flex;
    gap: 0;
    margin-bottom: var(--theme-space-4);
    border-bottom: 1px solid var(--theme-border-primary);
    padding: 0 0.25rem;
}

#createPortfolioModal .code-editor-tabs .code-tab[data-lang="preview"] {
    margin-left: auto;
}

.code-tab {
    padding: var(--theme-space-2) var(--theme-space-4);
    background: transparent;
    border: 1px solid transparent;
    border-bottom: 3px solid transparent;
    border-radius: 0.65rem 0.65rem 0 0;
    color: var(--theme-text-secondary);
    cursor: pointer;
    font-size: var(--theme-text-sm);
    font-weight: var(--theme-font-medium);
    transition: border-color var(--theme-transition-base), box-shadow var(--theme-transition-base), background-color var(--theme-transition-base), color var(--theme-transition-base);
}

.code-tab:hover {
    background: transparent;
    border-bottom-color: transparent;
    color: var(--theme-text-secondary);
}

.code-tab.active {
    position: relative;
    z-index: 1;
    background: var(--theme-bg-card);
    color: var(--theme-text-primary);
    border-color: var(--theme-border-primary);
    border-bottom-color: var(--theme-primary);
    box-shadow: 0 -2px 8px rgba(0, 0, 0, 0.08);
}

.code-editor-container {
    flex: 1;
    min-height: 420px;
    overflow: auto;
    position: relative;
    border: 1px solid var(--theme-border-primary);
    border-radius: var(--theme-radius-md);
    background: var(--theme-bg-tertiary);
}

.code-editor-expand-btn {
    position: absolute;
    top: 0.75rem;
    right: 0.75rem;
    z-index: 2002; /* Higher than fullscreen preview */
    width: 34px;
    height: 34px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    border: 1px solid var(--theme-border-primary);
    border-radius: var(--theme-radius-md);
    background: var(--theme-bg-card);
    color: var(--theme-text-secondary);
    cursor: pointer;
    box-shadow: var(--theme-shadow-sm);
}

.code-editor-expand-btn:hover,
.code-editor-expand-btn:focus-visible {
    color: var(--theme-text-primary);
    background: var(--theme-bg-hover);
}

.code-editor-expand-btn svg {
    width: 18px;
    height: 18px;
}

.code-editor-container.is-expanded {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    left: 0;
    z-index: 2000;
    width: 100vw;
    height: 100vh;
    min-height: 100vh;
    max-height: none;
    border: 0;
    border-radius: 0;
}

.code-editor-container.is-expanded .CodeMirror {
    height: 100% !important;
    min-height: 100% !important;
}

.modal-overlay.code-editor-fullscreen {
    display: block !important;
    width: 100vw !important;
    height: 100vh !important;
    padding: 0;
    z-index: 2001;
    background: rgba(0, 0, 0, 0.8);
}

.modal-overlay.code-editor-fullscreen .modal-container {
    position: fixed;
    inset: 0;
    width: 100vw;
    height: 100vh !important;
    min-height: 100vh;
    max-width: none;
    max-height: none;
    border-radius: 0;
    transform: none;
    display: flex;
    flex-direction: column;
}

.modal-overlay.code-editor-fullscreen .modal-header,
.modal-overlay.code-editor-fullscreen .modal-footer {
    display: none !important;
}

.modal-overlay.code-editor-fullscreen .modal-body {
    flex: 1 1 auto;
    height: 100vh !important;
    min-height: 100vh !important;
    max-height: 100vh !important;
    overflow: auto;
    padding: 0;
}

.modal-overlay.code-editor-fullscreen .modal-body > .code-editor-container,
.modal-overlay.code-editor-fullscreen .modal-body > .code-editor-container .CodeMirror,
.modal-overlay.code-editor-fullscreen .modal-body > .code-editor-preview {
    height: 100vh !important;
    min-height: 100vh !important;
}

.modal-overlay.code-editor-fullscreen .modal-body > .code-editor-expand-target {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    left: 0;
    width: 100vw;
    height: 100vh !important;
    min-height: 100vh !important;
    border: 0;
    border-radius: 0;
    background: white;
    z-index: 2001;
}

.modal-overlay.code-editor-fullscreen .modal-body > .code-editor-expand-target iframe {
    width: 100%;
    height: 100%;
    border: none;
}

.code-editor-expand-target.is-expanded {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: 2001;
    border: 0;
    border-radius: 0;
    background: white;
}

.code-editor-expand-target.is-expanded iframe {
    width: 100%;
    height: 100%;
    border: none;
}

body.code-editor-is-expanded {
    overflow: hidden;
}

.code-editor {
    width: 100%;
    height: 100%;
    min-height: 400px;
    font-family: 'Courier New', Courier, monospace;
    font-size: var(--theme-text-sm);
    padding: var(--theme-space-3);
    border: none;
    background: var(--theme-bg-tertiary);
    color: var(--theme-text-primary);
    resize: none;
}

.code-editor:focus {
    outline: none;
}

.code-editor-container .CodeMirror {
    min-height: 420px;
    height: 100%;
    font-size: var(--theme-text-sm);
}

/* Code Editor Preview Styles */
.code-editor-preview {
    width: 100%;
    height: 400px;
    border: 1px solid var(--theme-border-primary);
    border-radius: var(--theme-radius-md);
    overflow: hidden;
    background: var(--theme-bg-card);
}

.code-editor-preview iframe {
    width: 100%;
    height: 100%;
    border: none;
}

/* Preview tab positioning (only for Code IDE) */
#codeIdeModal .code-editor-tabs {
    display: flex;
    justify-content: space-between;
}

#codeIdeModal .code-editor-tabs .code-tab[data-lang="preview"] {
    margin-left: auto;
}

.code-hints {
    margin-top: var(--theme-space-3);
    padding: var(--theme-space-3);
    background: var(--theme-bg-tertiary);
    border-radius: var(--theme-radius-md);
    border-left: 3px solid var(--theme-primary);
}

.code-hints p {
    margin: 0;
    font-size: var(--theme-text-sm);
    color: var(--theme-text-secondary);
}

/* Modal Header */
.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--theme-space-6);
    border-bottom: 1px solid var(--theme-border-primary);
}

.modal-header h2 {
    margin: 0;
    font-size: var(--theme-text-2xl);
    font-weight: var(--theme-font-semibold);
    color: var(--theme-text-primary);
}

.modal-close {
    background: none;
    border: none;
    cursor: pointer;
    padding: var(--theme-space-2);
    border-radius: var(--theme-radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--theme-text-muted);
    transition: all var(--theme-transition-base);
}

.modal-close:hover {
    background-color: var(--theme-bg-hover);
    color: var(--theme-text-primary);
}

.modal-close svg {
    width: 20px;
    height: 20px;
}

/* Modal Body */
#createPortfolioModal .modal-body {
    padding: var(--theme-space-6);
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    display: flex;
    flex-direction: column;
}

.modal-description {
    margin: 0 0 var(--theme-space-6) 0;
    color: var(--theme-text-secondary);
    font-size: var(--theme-text-sm);
}

/* Modal Steps */
#createPortfolioModal .modal-step {
    display: none;
    flex: 0 0 auto;
    overflow: visible;
    flex-direction: column;
    min-height: 0;
}

#createPortfolioModal .modal-step.active {
    display: flex;
}

/* Form Group */
.form-group {
    margin-bottom: var(--theme-space-4);
}

.form-group label {
    display: block;
    margin-bottom: var(--theme-space-2);
    font-size: var(--theme-text-sm);
    font-weight: var(--theme-font-medium);
    color: var(--theme-text-primary);
}

.form-group .checkbox-label {
    display: flex;
    align-items: center;
    gap: var(--theme-space-2);
    margin-bottom: 0;
    cursor: pointer;
}

.form-group .checkbox-label input[type="checkbox"] {
    flex: 0 0 auto;
    width: 18px;
    height: 18px;
    margin: 0;
    accent-color: var(--theme-primary);
}

.form-group .checkbox-label + .form-help {
    margin-top: var(--theme-space-1) !important;
    font-size: var(--theme-text-xs) !important;
    font-style: italic;
    color: var(--theme-warning) !important;
}

.form-group input[type="text"] {
    width: 100%;
    padding: var(--theme-space-3);
    border: 1px solid var(--theme-border-primary);
    border-radius: var(--theme-radius-md);
    background: var(--theme-bg-input);
    color: var(--theme-text-primary);
    font-size: var(--theme-text-base);
}

.form-group input[type="text"]:focus {
    outline: none;
    border-color: var(--theme-primary);
    box-shadow: 0 0 0 2px var(--theme-primary-light);
}

/* Gallery Files Container */
.gallery-files-container {
    flex: 1;
    overflow-y: auto;
    margin-bottom: var(--theme-space-4);
    min-height: 0;
}

.modal-file-card {
    display: flex;
    align-items: center;
    padding: var(--theme-space-3);
    border: 1px solid var(--theme-border-primary);
    border-radius: var(--theme-radius-md);
    margin-bottom: var(--theme-space-2);
    background: var(--theme-bg-card);
    cursor: pointer;
    transition: all var(--theme-transition-base);
    position: relative; /* Ensure positioned child stays within card */
}

.modal-file-card:hover {
    border-color: var(--theme-primary);
    background: var(--theme-bg-hover);
}

.modal-file-card .modal-file-checkbox {
    margin-right: var(--theme-space-3);
    order: -1;
    display: flex;
    align-items: center;
}

.modal-file-card .modal-file-checkbox input[type="checkbox"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
    accent-color: var(--theme-primary);
}

.modal-file-card .file-preview {
    width: 48px;
    height: 48px;
    border-radius: var(--theme-radius-md);
    overflow: hidden;
    margin-right: var(--theme-space-3);
    background: var(--theme-bg-tertiary);
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-file-card .file-preview img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.modal-file-card .file-preview .video-placeholder,
.modal-file-card .file-preview .document-placeholder {
    font-size: 24px;
}

.modal-file-card .file-info {
    flex: 1;
}

.modal-file-card .file-name {
    font-size: var(--theme-text-sm);
    font-weight: var(--theme-font-medium);
    color: var(--theme-text-primary);
    margin-bottom: var(--theme-space-1);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.modal-file-card .file-meta {
    font-size: var(--theme-text-xs);
    color: var(--theme-text-secondary);
}

.modal-file-card .file-category {
    background: var(--theme-primary-light);
    color: var(--theme-primary);
    padding: 2px 8px;
    border-radius: var(--theme-radius-sm);
    font-size: var(--theme-text-xs);
}

.selected-count {
    font-size: var(--theme-text-sm);
    color: var(--theme-text-secondary);
    text-align: center;
}

.loading {
    text-align: center;
    padding: var(--theme-space-6);
    color: var(--theme-text-secondary);
}

.empty-state {
    text-align: center;
    padding: var(--theme-space-6);
    color: var(--theme-text-secondary);
}

.empty-state a {
    color: var(--theme-primary);
    text-decoration: none;
}

.empty-state a:hover {
    text-decoration: underline;
}

.error {
    text-align: center;
    padding: var(--theme-space-6);
    color: var(--theme-error);
}

/* File Viewer Styles */
.file-viewer-content {
    display: flex;
    align-items: center;
    justify-content: center;
    flex: 1;
    background: var(--theme-bg-tertiary);
    border-radius: var(--theme-radius-md);
    overflow: hidden;
    min-height: 0;
}

.file-viewer-content img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

.file-viewer-content video {
    max-width: 100%;
    max-height: 100%;
}

.file-viewer-content iframe {
    width: 100%;
    height: 100%;
    border: none;
}

.file-viewer-content .document-preview {
    text-align: center;
    padding: var(--theme-space-8);
}

.file-viewer-content .document-preview svg {
    width: 64px;
    height: 64px;
    margin-bottom: var(--theme-space-4);
    color: var(--theme-text-muted);
}

.file-viewer-content .document-preview p {
    color: var(--theme-text-secondary);
    margin-bottom: var(--theme-space-4);
}

/* Create Options Grid */
.create-options-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: var(--theme-space-4);
}

/* Create Option Card */
.create-option-card {
    border: 2px solid var(--theme-border-primary);
    border-radius: var(--theme-radius-xl);
    padding: var(--theme-space-6) var(--theme-space-4);
    text-align: center;
    cursor: pointer;
    transition: all var(--theme-transition-base);
    position: relative;
    background: var(--theme-bg-card);
}

.create-option-card:hover {
    border-color: var(--theme-primary);
    background-color: var(--theme-bg-hover);
    transform: translateY(-2px);
    box-shadow: var(--theme-shadow-lg);
}

.create-option-card:active {
    transform: translateY(0);
}

.option-icon {
    width: 48px;
    height: 48px;
    margin: 0 auto var(--theme-space-4) auto;
    background-color: var(--theme-bg-tertiary);
    border-radius: var(--theme-radius-xl);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--theme-text-muted);
    transition: all var(--theme-transition-base);
}

.create-option-card:hover .option-icon {
    background-color: var(--theme-primary-light);
    color: var(--theme-primary);
}

.option-icon svg {
    width: 24px;
    height: 24px;
}

.create-option-card h3 {
    margin: 0 0 var(--theme-space-2) 0;
    font-size: var(--theme-text-base);
    font-weight: var(--theme-font-semibold);
    color: var(--theme-text-primary);
}

.create-option-card p {
    margin: 0;
    font-size: var(--theme-text-xs);
    color: var(--theme-text-secondary);
    line-height: 1.5;
}

/* Option Badge */
.option-badge {
    display: inline-block;
    margin-top: var(--theme-space-3);
    padding: var(--theme-space-1) var(--theme-space-2);
    background-color: var(--theme-primary-light);
    color: var(--theme-primary-dark);
    font-size: var(--theme-text-xs);
    font-weight: var(--theme-font-semibold);
    border-radius: var(--theme-radius-sm);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.option-badge--disabled {
    background-color: var(--theme-bg-tertiary);
    color: var(--theme-text-muted);
}

/* Modal Footer */
#createPortfolioModal #createModalFooter {
    flex-direction: row;
    justify-content: space-between;
}

#createPortfolioModal #createModalFooter .btn {
    width: auto;
}

.modal-footer {
    padding: var(--modal-footer-padding-y, var(--theme-space-2)) var(--theme-space-6);
    border-top: 1px solid var(--theme-border-primary);
    display: flex;
    justify-content: flex-end;
    gap: var(--theme-space-3);
}

/* Responsive */
@media (max-width: 640px) {
    .create-options-grid {
        grid-template-columns: 1fr;
    }
    
    #createPortfolioModal .modal-container {
        width: calc(100% - var(--theme-space-4) - var(--theme-space-4));
        max-width: calc(100% - var(--theme-space-4) - var(--theme-space-4));
        margin: var(--theme-space-4);
    }
    
    #codeIdeModal .modal-footer {
        flex-direction: column;
        gap: var(--theme-space-3);
    }
    
    #codeIdeModal .modal-footer .btn {
        width: 100%;
    }
}
