/* Clean, Minimal Reset */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary-color: #2563eb;
    --primary-hover: #1d4ed8;

    --success-color: #059669;
    --secondary-color: #64748b;
    --background: #ffffff;
    --surface: #f8fafc;
    --surface-elevated: #ffffff;
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --text-muted: #94a3b8;
    --border: #e2e8f0;
    --border-focus: #2563eb;
    --radius: 8px;
    --shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px 0 rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    line-height: 1.5;
    color: var(--text-primary);
    background: var(--background);
    min-height: 80vh;
}

/* Main page specific - single page layout */
body.main-page {
    min-height: 80vh;
}

.container {
    max-width: 1000px;
    margin: 0 auto;
    padding: 1rem;
    min-height: 80vh;
}

/* Main page specific container */
body.main-page .container {
    min-height: 80vh;
    /* Changed from height to min-height */
    display: flex;
    flex-direction: column;
}

/* Header */
header {
    text-align: center;
    margin-bottom: 1.5rem;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
}

header h1 {
    font-size: 1rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 0.25rem;
    letter-spacing: -0.025em;
}

header p {
    color: var(--text-secondary);
    font-size: 1rem;
}

/* Main Content */
/*
main {
    margin-bottom: 1rem;
}
*/

/* Main page specific main element */
body.main-page main {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    overflow: hidden;
}

/* Cards */
.card {
    background: var(--surface-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1rem;
    box-shadow: var(--shadow-lg);
}


/* Upload Section Layout */
.upload-section {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 2rem;
    align-items: start;
}

.upload-section h2 {
    grid-column: 1 / -1;
    margin-bottom: 0.5rem;
}

/* Collapse truly empty direct children to prevent stray blank rows */
.upload-section>*:empty {
    display: none;
    margin: 0;
    padding: 0;
}

/* API key row styling - spans full width in grid layout */
.upload-section .api-key-row {
    margin-bottom: 0.5rem;
}

/* Form Elements */
.form-group {

    margin-bottom: 1rem;
    display: flex;
    flex-direction: column;
    /* do not stretch to 100% of the grid row: let content size naturally */
    height: auto;
}

.form-group .form-controls {
    margin-top: auto;
    padding: 0.5rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
    color: var(--text-primary);
    font-size: 0.875rem;
}

textarea,
input[type="file"],
input[type="text"] {
    width: 100%;
    padding: 0.5rem;
    background: var(--background);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 0.875rem;
    color: var(--text-primary);
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
    font-family: ui-monospace, 'Cascadia Code', 'Source Code Pro', Menlo, Monaco, monospace;
}

textarea {
    height: 80px;
    resize: vertical;
    line-height: 1.4;
}

textarea:focus,
input:focus {
    outline: none;
    border-color: var(--border-focus);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

textarea::placeholder,
input::placeholder {
    color: var(--text-muted);
}

/* File input */
input[type="file"] {
    padding: 0.75rem;
    background: var(--surface);
    border: 1px dashed var(--border);
    cursor: pointer;
    height: 80px;
    box-sizing: border-box;
}

input[type="file"]:hover {
    border-color: var(--border-focus);
}

/* Form Controls */
.form-controls {
    display: flex;
    gap: 1rem;
    align-items: center;
    margin-top: 1rem;
    flex-wrap: wrap;
}

.checkbox-wrapper {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
}

.checkbox-wrapper input[type="checkbox"] {
    width: auto;
    margin: 0;
    accent-color: var(--primary-color);
}

.checkbox-wrapper label {
    margin: 0;
    font-weight: 400;
    color: var(--text-secondary);
    font-size: 0.875rem;
    cursor: pointer;
}

/* Buttons */
.btn {
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: var(--radius);
    cursor: pointer;
    font-size: 0.875rem;
    font-weight: 500;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    transition: all 0.2s ease;
    min-width: 120px;
}

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

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

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

.btn-secondary:hover {
    background: var(--surface-elevated);
    border-color: var(--text-secondary);
}

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

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

.btn-success {
    background: var(--success-color);
    color: white;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none !important;
}

/* Icons */
.icon {
    width: 1rem;
    height: 1rem;
    flex-shrink: 0;
}

/* Result Section */
.result-section {
    display: none;
}

.success-message {
    background: rgba(5, 150, 105, 0.1);
    border: 1px solid rgba(5, 150, 105, 0.2);
    color: var(--success-color);
    padding: 1rem;
    border-radius: var(--radius);
    text-align: center;
    margin-bottom: 1.5rem;
    font-weight: 500;
}

.result-content h3 {
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 1rem;
    text-align: center;
}

.url-display {
    display: flex;
    gap: 0.5rem;
    margin: 1rem 0;
}

.url-display input {
    flex: 1;
    background: var(--surface);
    border: 1px solid var(--border);
}

.action-buttons {
    display: flex;
    gap: 0.5rem;
    justify-content: center;
    margin-top: 1rem;
    flex-wrap: wrap;
}

/* Usage Section - Compact display */
.usage-section {
    display: block;
    /* Keep bottom padding consistent with the card gap above */
    padding: 1rem;
}

.usage-section h2 {
    font-size: 1rem;
    margin-bottom: 0.75rem;
}

/* Show usage section when needed */
.show-usage .usage-section {
    display: block;
}

/* Usage Examples */
.code-examples {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.example {
    background: var(--surface);
    border-radius: var(--radius);
    padding: 0.5rem 0.75rem;
    border-left: 2px solid var(--primary-color);
    width: 100%;
}

.example p {
    font-weight: 500;
    color: var(--text-primary);
    margin-bottom: 0.25rem;
    font-size: 0.75rem;
}

.example code {
    display: block;
    background: var(--background);
    padding: 0.75rem;
    border-radius: calc(var(--radius) - 2px);
    font-family: ui-monospace, 'Cascadia Code', 'Source Code Pro', Menlo, Monaco, monospace;
    font-size: 0.8rem;
    color: var(--text-primary);
    border: 1px solid var(--border);
    word-break: break-all;
    overflow-x: auto;
}

/* Responsive Design */
@media (max-width: 768px) {
    .container {
        padding: 0.75rem;
        padding-bottom: 2rem;
        /* Extra bottom padding for mobile */
    }

    /* Ensure mobile scrolling works properly */
    body.main-page {
        height: auto;
        min-height: 80vh;
        overflow: auto;
    }

    body.main-page .container {
        height: auto;
        min-height: 80vh;
        flex-direction: column;
        padding-bottom: 3rem;
        /* More bottom space on mobile */
    }

    .upload-section {
        grid-template-columns: 1fr;
        gap: 1rem;
    }

    header h1 {
        font-size: 1.75rem;
    }

    .card {
        padding: 1rem;
    }

    .form-controls {
        flex-direction: column;
        align-items: stretch;
    }

    .url-display {
        flex-direction: column;
    }

    .action-buttons {
        flex-direction: column;
    }

    .btn {
        min-width: unset;
    }
}

/* Loading and animation states */
.loading {
    opacity: 0.7;
}

/* View page specific styles */
.paste-info {
    margin-bottom: 1.5rem;
}

.info-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    margin-top: 0.75rem;
    align-items: center;
}

.info-item {
    display: flex;
    flex-direction: row;
    align-items: baseline;
    gap: 0.5rem;
    min-width: 0;
}

.info-item label {
    font-weight: 600;
    color: var(--text-secondary);
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.025em;
    white-space: nowrap;
}

.info-item span {
    color: var(--text-primary);
    font-family: ui-monospace, 'Cascadia Code', 'Source Code Pro', Menlo, Monaco, monospace;
    font-size: 0.8rem;
    line-height: 1.3;
    word-break: break-all;
}

.burn-notice {
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.2);
    border-radius: var(--radius);
    padding: 0.75rem;
    grid-column: 1 / -1;
    margin-top: 0.5rem;
}

.burn-notice label {
    color: #dc2626 !important;
    font-weight: 600;
    font-size: 0.75rem !important;
}

.burn-notice span {
    color: #dc2626 !important;
    font-size: 0.8rem !important;
}

/* Prominent banner styles for the view page */
.alert {
    border-radius: calc(var(--radius));
    padding: 0.75rem 1rem;
    box-shadow: var(--shadow);
}

.alert.large {
    padding: 1.25rem 1.5rem;
}

.alert-title {
    font-weight: 700;
    font-size: 1.25rem;
    color: var(--text-primary);
    margin-bottom: 0.25rem;
}

.alert-message {
    color: var(--text-secondary);
    font-size: 1rem;
}

.alert-body {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.binary-notice.centered {
    text-align: center;
    padding: 2rem;
    max-width: 800px;
    margin: 0 auto;
}

.binary-notice.large {
    padding: 2.25rem;
}

/* When viewing a missing paste, simplify page and hide details */
.container.no-paste .paste-info,
.container.no-paste .action-buttons,
.container.no-paste .upload-section {
    display: none !important;
}

/* Hide other content and center the banner when no paste is present */
.container.no-paste .paste-info,
.container.no-paste .action-buttons,
.container.no-paste .upload-section,
.container.no-paste .content-section,
.container.no-paste .binary-notice {
    display: none !important;
}

.container.no-paste .alert {
    /* subtler left accent, visual lift removed for cleaner look */
    border-left: 4px solid rgba(239, 68, 68, 0.5);
    background: linear-gradient(90deg, rgba(255, 255, 255, 1), rgba(250, 250, 251, 1));
    margin-left: auto;
    margin-right: auto;
    max-width: 760px;
    padding: 1rem 1.25rem;
    box-shadow: 0 2px 6px rgba(16, 24, 40, 0.04);
}

/* If an alert is present, hide the paste details and secondary action buttons
   to focus the user on the message. This helps when templates don't inject
   the 'no-paste' class for any reason. */
#paste-view-section .alert~.paste-info,
#paste-view-section .alert~.content-section .action-buttons,
#paste-view-section .alert~.upload-section {
    display: none !important;
}

/* Make the alert banner more prominent */
.alert {
    width: 100%;
    box-shadow: none;
}

.alert.large {
    padding: 1.15rem 1.25rem;
}

.alert-title {
    font-size: 1.15rem;
}

.alert-message {
    font-size: 0.98rem;
}

/* Large, bold, colored heading for missing-paste banner */
.banner-heading {
    font-size: 1.5rem;
    font-weight: 700;
    color: #0b2545;
    /* deep navy for prominent heading (similar to screenshot) */
    margin-bottom: 0.35rem;
}

.content-section {
    margin-bottom: 1rem;
}

.content-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.content-header h3 {
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--text-primary);
}

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

.content-display {
    background: transparent;
    border: none;
    border-radius: 0;
    padding: 0;
    max-height: none;
    min-height: auto;
    overflow: visible;
    margin-top: 1rem;
    width: 100%;
}

.content-display pre {
    margin: 0;
    white-space: pre-wrap;
    word-wrap: break-word;
    font-family: ui-monospace, 'Cascadia Code', 'Source Code Pro', Menlo, Monaco, monospace;
    font-size: 0.875rem;
    line-height: 1.6;
    background: transparent;
    border: none;
    padding: 0;
    width: 100%;
    overflow: visible;
}

.content-display pre code {
    display: block;
    width: 100%;
    overflow: visible;
}

.binary-notice {
    text-align: center;
    padding: 2rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text-secondary);
}

footer {
    text-align: center;
    padding: 1rem 0;
    color: var(--text-muted);
    font-size: 0.875rem;
    border-top: 1px solid var(--border);
    /* margin-top: 2rem; */
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.result-section {
    animation: slideIn 0.3s ease-out;
}

/* Responsive Design - Desktop (min-width: 768px) */
@media (min-width: 768px) {
    .upload-section {
        gap: 0 1rem;
        /* row-gap column-gap */
    }

    .upload-section .api-key-row {
        grid-column: 1 / -1;
        padding: 0;
        margin: 0;
    }

    .card.upload-section .api-key-row label {
        display: block;
        margin: 0 0 0.5rem 0;
        padding: 0;
        box-sizing: border-box;
    }

    .card.upload-section .api-key-row input[type="text"] {
        display: block;
        margin: 0;
        width: 100%;
        box-sizing: border-box;
        padding: 0.5rem;
    }

    .upload-section .form-group {
        margin-bottom: 0.25rem;
    }
}