/* ========================================
   PlayStation 1 Memory Card Editor
   Retro PS1 Themed Stylesheet
   ======================================== */

/* Google Fonts - Pixel Font */
@import url('https://fonts.googleapis.com/css2?family=Press+Start+2P&display=swap');

:root {
    /* PS1 Authentic Color Palette */
    --bg-color: #0a1628;
    --bg-gradient: linear-gradient(180deg, #0d1f3c 0%, #0a1628 50%, #050d1a 100%);
    --card-bg: #1a2744;
    --card-bg-gradient: linear-gradient(135deg, #1e3050 0%, #152238 100%);
    --text-main: #e8e8e8;
    --text-muted: #7a8ba8;
    --accent: #3d7eff;
    --accent-glow: rgba(61, 126, 255, 0.4);
    --danger: #ff4757;
    --success: #2ed573;
    --border: #2a3f5f;
    --btn-text: #ffffff;
    --ps1-gray: #8c8c8c;
    --ps1-blue: #1e3a5f;
}

[data-theme="light"] {
    --bg-color: #b8b8b8;
    --bg-gradient: linear-gradient(180deg, #d0d0d0 0%, #b0b0b0 50%, #909090 100%);
    --card-bg: #d8d8d8;
    --card-bg-gradient: linear-gradient(135deg, #e8e8e8 0%, #c8c8c8 100%);
    --text-main: #1a1a1a;
    --text-muted: #404040;
    --accent: #0055aa;
    --accent-glow: rgba(0, 85, 170, 0.4);
    --danger: #cc2233;
    --success: #228833;
    --border: #808080;
    --btn-text: #ffffff;
    --ps1-gray: #606060;
    --ps1-blue: #3a5a8a;
}

/* CRT Scanlines Overlay */
body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 9999;
    background: repeating-linear-gradient(0deg,
    rgba(0, 0, 0, 0.03) 0px,
    rgba(0, 0, 0, 0.03) 1px,
    transparent 1px,
    transparent 2px);
}

body {
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    background: var(--bg-gradient);
    background-attachment: fixed;
    color: var(--text-main);
    margin: 0;
    padding: 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
    min-height: 100vh;
    transition: background-color 0.3s, color 0.3s;
}

/* Pixel Font for Headers */
h1 {
    font-family: 'Press Start 2P', cursive;
    margin: 0;
    color: var(--text-main);
    font-weight: 400;
    letter-spacing: 0;
    font-size: 1em;
    text-shadow: 2px 2px 0 rgba(0, 0, 0, 0.5);
}

.subtitle {
    font-family: 'Press Start 2P', cursive;
    font-size: 0.5em;
    opacity: 0.7;
    margin: 8px 0 0 0;
    letter-spacing: 0;
}

.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    max-width: 1400px;
    margin-bottom: 25px;
    padding: 20px 25px;
    background: var(--card-bg-gradient);
    border-radius: 4px;
    border: 3px solid var(--border);
    box-shadow: inset 2px 2px 0 rgba(255, 255, 255, 0.1),
    inset -2px -2px 0 rgba(0, 0, 0, 0.3),
    0 4px 20px rgba(0, 0, 0, 0.4);
}

.header-left {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 10px;
}

/* Retro 3D Bevel Button Style */
.theme-btn {
    padding: 10px 14px;
    border-radius: 4px;
    background: linear-gradient(180deg, #4a4a4a 0%, #2a2a2a 100%);
    border: 3px solid;
    border-color: #6a6a6a #1a1a1a #1a1a1a #6a6a6a;
    color: var(--text-main);
    cursor: pointer;
    font-size: 1.2em;
    transition: all 0.1s;
    box-shadow: 2px 2px 0 rgba(0, 0, 0, 0.5);
}

.theme-btn:hover {
    background: linear-gradient(180deg, #5a5a5a 0%, #3a3a3a 100%);
}

.theme-btn:active {
    border-color: #1a1a1a #6a6a6a #6a6a6a #1a1a1a;
    box-shadow: inset 2px 2px 4px rgba(0, 0, 0, 0.5);
    transform: translate(1px, 1px);
}

/* PS1 Style Buttons */
button,
.file-btn {
    font-family: 'Press Start 2P', cursive;
    padding: 10px 16px;
    border-radius: 4px;
    border: 3px solid;
    border-color: #5a6a8a #1a2a4a #1a2a4a #5a6a8a;
    cursor: pointer;
    font-weight: 400;
    font-size: 0.6rem;
    background: linear-gradient(180deg, var(--ps1-blue) 0%, #0f2540 100%);
    color: var(--text-main);
    display: flex;
    align-items: center;
    gap: 6px;
    box-shadow: 2px 2px 0 rgba(0, 0, 0, 0.4);
    transition: all 0.1s;
    text-shadow: 1px 1px 0 rgba(0, 0, 0, 0.5);
}

button:hover,
.file-btn:hover {
    background: linear-gradient(180deg, #2a4a70 0%, #1a3a5a 100%);
    box-shadow: 0 0 10px var(--accent-glow);
}

button:active {
    border-color: #1a2a4a #5a6a8a #5a6a8a #1a2a4a;
    box-shadow: inset 2px 2px 4px rgba(0, 0, 0, 0.5);
    transform: translate(1px, 1px);
}

.btn-outline {
    background: transparent;
    border: 3px solid var(--accent);
    color: var(--accent);
}

.btn-outline:hover {
    background: var(--accent);
    color: var(--btn-text);
}

.btn-danger {
    color: #ff6b6b;
    border-color: #8a4a4a #4a2a2a #4a2a2a #8a4a4a;
    background: linear-gradient(180deg, #5a3030 0%, #3a2020 100%);
}

.btn-danger:hover {
    background: linear-gradient(180deg, #7a4040 0%, #5a3030 100%);
    box-shadow: 0 0 10px rgba(255, 107, 107, 0.5);
    color: #fff;
}

/* Header control buttons with uniform styling */
.sm-btn {
    font-family: 'Press Start 2P', cursive;
    font-size: 0.55rem;
    padding: 8px 12px;
    border-radius: 4px;
    border: 3px solid;
    border-color: #5a6a8a #1a2a4a #1a2a4a #5a6a8a;
    background: linear-gradient(180deg, var(--ps1-blue) 0%, #0f2540 100%);
    color: #fff;
    cursor: pointer;
    box-shadow: 2px 2px 0 rgba(0, 0, 0, 0.4);
    transition: all 0.1s;
    text-shadow: 1px 1px 0 rgba(0, 0, 0, 0.5);
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.sm-btn:hover {
    background: linear-gradient(180deg, #2a4a70 0%, #1a3a5a 100%);
    box-shadow: 2px 2px 0 rgba(0, 0, 0, 0.4), 0 0 10px var(--accent-glow);
}

.sm-btn:active {
    border-color: #1a2a4a #5a6a8a #5a6a8a #1a2a4a;
    box-shadow: inset 2px 2px 4px rgba(0, 0, 0, 0.5);
    transform: translate(1px, 1px);
}

/* Red danger button for Format */
.sm-btn.btn-danger {
    background: linear-gradient(180deg, #8a2020 0%, #5a1515 100%);
    border-color: #aa4040 #4a1010 #4a1010 #aa4040;
    color: #fff;
}

.sm-btn.btn-danger:hover {
    background: linear-gradient(180deg, #aa3030 0%, #7a2020 100%);
    box-shadow: 2px 2px 0 rgba(0, 0, 0, 0.4), 0 0 15px rgba(255, 80, 80, 0.6);
}

/* Light theme button overrides */
[data-theme="light"] .sm-btn {
    background: linear-gradient(180deg, #4a6a9a 0%, #2a4a6a 100%);
    border-color: #6a8aba #3a5a8a #3a5a8a #6a8aba;
}

[data-theme="light"] .sm-btn:hover {
    background: linear-gradient(180deg, #5a7aba 0%, #3a5a8a 100%);
}

[data-theme="light"] .btn-danger {
    background: linear-gradient(180deg, #aa4444 0%, #883333 100%);
    border-color: #cc6666 #662222 #662222 #cc6666;
    color: #fff;
}

[data-theme="light"] .btn-outline {
    background: rgba(0, 85, 170, 0.1);
    border-color: var(--accent);
    color: var(--accent);
}

input[type="file"] {
    display: none;
}

/* Dual-Pane Layout */
.workspace {
    display: flex;
    gap: 30px;
    width: 100%;
    max-width: 1400px;
    flex-wrap: wrap;
    justify-content: center;
}

.card-pane {
    flex: 1;
    min-width: 450px;
    background: var(--card-bg-gradient);
    border-radius: 4px;
    padding: 20px;
    display: flex;
    flex-direction: column;
    border: 3px solid var(--border);
    box-shadow: inset 2px 2px 0 rgba(255, 255, 255, 0.05),
    inset -2px -2px 0 rgba(0, 0, 0, 0.2),
    0 8px 32px rgba(0, 0, 0, 0.4);
    overflow: hidden;
}

.pane-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    border-bottom: 3px solid var(--border);
    padding-bottom: 12px;
}

.pane-title {
    font-family: 'Press Start 2P', cursive;
    font-size: 0.7em;
    font-weight: 400;
    color: var(--accent);
    text-shadow: 0 0 10px var(--accent-glow);
}

.pane-controls {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.file-status {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.75em;
    color: var(--text-muted);
    margin-bottom: 15px;
    padding: 8px 12px;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 4px;
    border: 1px solid var(--border);
}

/* Block Counter */
.block-counter {
    font-family: 'Press Start 2P', cursive;
    font-size: 0.5em;
    color: var(--success);
    text-align: right;
    margin-bottom: 10px;
}

.grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 10px;
    width: 100%;
}

/* Slot Cards with PS1 Style */
.slot-card {
    background: linear-gradient(180deg, #2a3a5a 0%, #1a2a4a 100%);
    border: 2px solid var(--border);
    border-radius: 4px;
    padding: 10px;
    display: flex;
    align-items: center;
    gap: 12px;
    transition: all 0.15s;
    position: relative;
    box-shadow: inset 1px 1px 0 rgba(255, 255, 255, 0.1),
    inset -1px -1px 0 rgba(0, 0, 0, 0.2);

    /* Force dark theme text colors inside the card since the card background is always dark */
    --text-main: #e8e8e8;
    --text-muted: #7a8ba8;
    --accent: #3d7eff;
    --accent-glow: rgba(61, 126, 255, 0.4);
}

.slot-card:hover {
    transform: translateY(-2px) scale(1.01);
    border-color: var(--accent);
    box-shadow: 0 0 15px var(--accent-glow),
    inset 1px 1px 0 rgba(255, 255, 255, 0.1);
}

.slot-card.empty {
    opacity: 0.4;
    border-style: dashed;
    background: linear-gradient(180deg, #1a2a3a 0%, #0a1a2a 100%);
}

/* Pulsing Selection Effect */
.slot-card.selected {
    border-color: var(--accent);
    animation: pulse-glow 1.5s ease-in-out infinite;
}

@keyframes pulse-glow {

    0%,
    100% {
        box-shadow: 0 0 10px var(--accent-glow), 0 0 20px rgba(61, 126, 255, 0.2);
    }

    50% {
        box-shadow: 0 0 20px var(--accent-glow), 0 0 40px rgba(61, 126, 255, 0.4);
    }
}

/* Icon Wobble Animation */
.icon-canvas {
    width: 48px;
    height: 48px;
    image-rendering: pixelated;
    background: #000;
    border-radius: 4px;
    border: 2px solid var(--border);
    flex-shrink: 0;
    animation: icon-wobble 3s ease-in-out infinite;
}

@keyframes icon-wobble {

    0%,
    100% {
        transform: rotate(-1deg);
    }

    50% {
        transform: rotate(1deg);
    }
}

.slot-card:hover .icon-canvas {
    animation: icon-wobble-fast 0.5s ease-in-out infinite;
}

@keyframes icon-wobble-fast {

    0%,
    100% {
        transform: rotate(-2deg) scale(1.05);
    }

    50% {
        transform: rotate(2deg) scale(1.05);
    }
}

/* PSX Style Action Buttons */
.psx-btn {
    width: 32px;
    height: 32px;
    padding: 0;
    border: none;
    background: transparent;
    cursor: pointer;
    transition: transform 0.1s, filter 0.1s;
    filter: drop-shadow(2px 2px 2px rgba(0, 0, 0, 0.5));
}

.psx-btn img {
    width: 100%;
    height: 100%;
    display: block;
}

.psx-btn:hover {
    transform: scale(1.2);
    filter: brightness(1.3) drop-shadow(0 0 8px var(--accent-glow));
}

.psx-btn:active {
    transform: scale(0.9);
}

.slot-info {
    flex: 1;
    min-width: 0;
}

.slot-id {
    font-family: 'Press Start 2P', cursive;
    font-size: 0.45em;
    color: var(--accent);
    text-transform: uppercase;
    margin-bottom: 4px;
    text-shadow: 0 0 5px var(--accent-glow);
}

.game-title {
    font-size: 0.9em;
    font-weight: 700;
    color: var(--text-main);
    margin: 0 0 4px 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.game-code {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.65em;
    background: rgba(0, 0, 0, 0.3);
    color: var(--text-muted);
    padding: 2px 6px;
    border-radius: 2px;
    display: inline-block;
}

/* Drop Overlay */
.drop-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(10, 22, 40, 0.9);
    backdrop-filter: blur(4px);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 4px dashed var(--accent);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s;
}

.drop-overlay.active {
    opacity: 1;
    pointer-events: all;
}

.drop-msg {
    font-family: 'Press Start 2P', cursive;
    font-size: 1em;
    color: var(--accent);
    background: var(--card-bg);
    padding: 30px 50px;
    border-radius: 4px;
    border: 3px solid var(--accent);
    box-shadow: 0 0 30px var(--accent-glow);
    text-shadow: 0 0 10px var(--accent-glow);
    animation: pulse-glow 1.5s ease-in-out infinite;
}

/* Small action buttons for slots */
.slot-actions {
    display: flex;
    gap: 6px;
    align-items: center;
}

.action-btn {
    width: 28px;
    height: 28px;
    padding: 4px;
    border: 2px solid var(--border);
    background: linear-gradient(180deg, #3a4a6a 0%, #2a3a5a 100%);
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.8em;
    color: var(--text-main);
    transition: all 0.1s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.action-btn:hover {
    background: linear-gradient(180deg, var(--accent) 0%, #2a5acc 100%);
    border-color: var(--accent);
    box-shadow: 0 0 10px var(--accent-glow);
    transform: scale(1.1);
}

/* Recover button for empty slots */
.recover-btn {
    font-family: 'Press Start 2P', cursive;
    font-size: 0.4em;
    padding: 6px 10px;
    background: transparent;
    border: 2px dashed var(--success);
    color: var(--success);
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.15s;
}

.recover-btn:hover {
    background: var(--success);
    color: #000;
    border-style: solid;
    box-shadow: 0 0 10px rgba(46, 213, 115, 0.5);
}

/* Import input */
.import-input {
    display: none;
}

/* Modal Styles */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(4px);
    z-index: 2000;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s;
}

.modal-overlay.active {
    opacity: 1;
    pointer-events: all;
}

.modal-content {
    background: var(--card-bg-gradient);
    width: 600px;
    max-width: 90%;
    border: 3px solid var(--border);
    border-radius: 4px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.6);
    display: flex;
    flex-direction: column;
    animation: modal-pop 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes modal-pop {
    from {
        transform: scale(0.8);
        opacity: 0;
    }
    to {
        transform: scale(1);
        opacity: 1;
    }
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 20px;
    border-bottom: 3px solid var(--border);
    background: rgba(0, 0, 0, 0.2);
}

.modal-header h2 {
    font-family: 'Press Start 2P', cursive;
    font-size: 0.8em;
    margin: 0;
    color: var(--accent);
    text-shadow: 0 0 10px var(--accent-glow);
}

.close-btn {
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 1.5em;
    cursor: pointer;
    line-height: 1;
    transition: color 0.1s;
}

.close-btn:hover {
    color: var(--danger);
}

.modal-body {
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.help-section h3 {
    font-family: 'Press Start 2P', cursive;
    font-size: 0.6em;
    color: var(--text-main);
    margin: 0 0 10px 0;
    border-bottom: 2px solid var(--border);
    padding-bottom: 5px;
    display: inline-block;
}

.help-section p, .help-section ul {
    font-size: 0.9em;
    line-height: 1.5;
    color: var(--text-main);
    margin: 0;
}

.help-section ul {
    padding-left: 20px;
    margin-top: 5px;
}

.help-section li {
    margin-bottom: 5px;
}

.modal-footer {
    padding: 15px 20px;
    border-top: 2px solid var(--border);
    background: rgba(0, 0, 0, 0.2);
    text-align: center;
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.7em;
    color: var(--text-muted);
}
