@import url('https://fonts.googleapis.com/css2?family=Roboto:wght@300;400;500;700&display=swap');
@import url('https://fonts.googleapis.com/css2?family=Roboto+Mono:wght@400;500&display=swap');

:root {
    /* Pure Dark M3 Deep Purple Theme (Inspired by Example) */
    --md-sys-color-primary: #D0BCFF;
    --md-sys-color-on-primary: #381E72;
    --md-sys-color-primary-container: #4F378B;
    --md-sys-color-on-primary-container: #EADDFF;

    --md-sys-color-secondary: #CCC2DC;
    --md-sys-color-on-secondary: #332D41;
    --md-sys-color-secondary-container: #4A4458;
    --md-sys-color-on-secondary-container: #E8DEF8;

    --md-sys-color-background: #141218;
    --md-sys-color-on-background: #E6E1E5;

    --md-sys-color-surface: #1D1B20;
    --md-sys-color-on-surface: #E6E1E5;
    --md-sys-color-surface-variant: #49454F;
    --md-sys-color-on-surface-variant: #CAC4D0;

    --md-sys-color-outline: #938F99;
    --md-sys-color-error: #F2B8B5;
    --md-sys-color-on-error: #601410;

    /* Shape */
    --md-sys-shape-corner-medium: 12px;
    --md-sys-shape-corner-large: 14px;
    --md-sys-shape-corner-extra-large: 28px;

    /* Typography */
    --md-sys-typescale-headline-small: 400 24px/32px 'Roboto', sans-serif;
    --md-sys-typescale-body-large: 400 16px/24px 'Roboto', sans-serif;
    --md-sys-typescale-label-large: 500 14px/20px 'Roboto', sans-serif;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    min-height: 100vh;
    background-color: var(--md-sys-color-background);
    color: var(--md-sys-color-on-background);
    font-family: 'Roboto', sans-serif;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow-x: hidden;
    padding: 24px;
}

/* App Layout */
.app-layout {
    display: flex;
    gap: 24px;
    align-items: flex-start;
    width: 100%;
    max-width: 1000px;
    /* Increased for two columns */
    flex-wrap: wrap;
    transition: max-width 0.4s ease;
}

/* Main Card */
.container {
    flex: 1;
    min-width: 300px;
    padding: 24px;
    background-color: var(--md-sys-color-surface);
    border-radius: var(--md-sys-shape-corner-extra-large);
    box-shadow: 0px 1px 3px 1px rgba(0, 0, 0, 0.15), 0px 1px 2px 0px rgba(0, 0, 0, 0.3);
    background-image: linear-gradient(rgba(255, 255, 255, 0.05), rgba(255, 255, 255, 0.05));
    position: relative;
    text-align: center;
    transition: all 0.4s cubic-bezier(0.25, 0.8, 0.25, 1);
    will-change: width, flex;
    overflow: hidden;
    /* For height animation clean edges */
}

/* History Card overrides */
.history-card {
    flex: 1;
    /* Equal width to main container */
    min-width: 300px;
    height: 100%;
    max-height: 600px;
    /* Or fit content */
    display: flex;
    flex-direction: column;
    /* Animation props for hiding/showing */
    transition: all 0.4s cubic-bezier(0.25, 0.8, 0.25, 1);
    opacity: 1;
    transform: translateX(0);
    overflow: hidden;
}

.history-card.hidden-sidebar {
    flex: 0 0 0 !important;
    min-width: 0 !important;
    width: 0 !important;
    padding: 0;
    margin: 0;
    opacity: 0;
    transform: translateX(50px);
    border: none;
    pointer-events: none;
}

@media (max-width: 768px) {
    .app-layout {
        flex-direction: column;
        align-items: stretch;
    }

    .history-card {
        width: 100%;
        flex: none;
    }
}

/* Header */
header.header-content {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 24px;
}

.header-text {
    flex: 1;
    text-align: left;
}

h1 {
    font: var(--md-sys-typescale-headline-small);
    color: var(--md-sys-color-on-background);
    margin-bottom: 4px;
}

p.subtitle {
    font: var(--md-sys-typescale-body-large);
    color: var(--md-sys-color-on-surface-variant);
    font-size: 0.9rem;
}

/* Icon Buttons */
.icon-btn {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    /* Standard M3 icon button */
    border: none;
    background: transparent;
    color: var(--md-sys-color-on-surface-variant);
    cursor: pointer;
    transition: background-color 0.2s, color 0.2s;
}

.icon-btn:hover {
    background-color: rgba(230, 225, 229, 0.08);
    /* on-surface variant with opacity */
    color: var(--md-sys-color-on-surface);
}

/* Upload Area (Card-like) */
.upload-area {
    border: 1px dashed var(--md-sys-color-outline);
    border-radius: var(--md-sys-shape-corner-large);
    padding: 32px;
    cursor: pointer;
    transition: all 0.2s ease;
    background: transparent;
    margin-bottom: 24px;
}

.upload-area:hover,
.upload-area.dragover {
    border-color: var(--md-sys-color-primary);
    background-color: rgba(208, 188, 255, 0.05);
    /* primary with opacity */
}

.upload-icon {
    font-size: 48px;
    color: var(--md-sys-color-primary);
    margin-bottom: 16px;
    transition: transform 0.2s;
}

.upload-area:hover .upload-icon {
    transform: scale(1.1);
}

.upload-area h3 {
    font: var(--md-sys-typescale-body-large);
    font-weight: 500;
}

.upload-area p {
    color: var(--md-sys-color-on-surface-variant);
    font-size: 0.85rem;
    margin-top: 4px;
}

/* Buttons (Filled Tonal/Primary) */
.btn {
    width: 100%;
    height: 40px;
    border: none;
    border-radius: 20px;
    /* Fully rounded for buttons */
    background-color: var(--md-sys-color-primary);
    color: var(--md-sys-color-on-primary);
    font: var(--md-sys-typescale-label-large);
    cursor: pointer;
    transition: box-shadow 0.2s, background-color 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin-top: 16px;
}

.btn:hover {
    box-shadow: 0px 1px 3px 1px rgba(0, 0, 0, 0.15), 0px 1px 2px 0px rgba(0, 0, 0, 0.3);
    /* M3 elevation 1 */
    filter: brightness(1.05);
}

.btn:disabled {
    background-color: var(--md-sys-color-surface-variant);
    color: var(--md-sys-color-on-surface-variant);
    cursor: not-allowed;
    box-shadow: none;
}

/* Progress */
.progress-container {
    margin-top: 24px;
    text-align: left;
}

.progress-header {
    display: flex;
    justify-content: space-between;
    font: var(--md-sys-typescale-label-large);
    color: var(--md-sys-color-primary);
    margin-bottom: 8px;
}

.progress-bar-bg {
    width: 100%;
    height: 4px;
    background-color: var(--md-sys-color-surface-variant);
    border-radius: 2px;
    overflow: hidden;
}

.progress-bar-fill {
    height: 100%;
    width: 0%;
    background-color: var(--md-sys-color-primary);
    transition: width 0.1s linear;
}

/* Success / Link Card */
.file-info {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 16px;
    background-color: var(--md-sys-color-surface-variant);
    /* Surface Container Highest-ish */
    border-radius: var(--md-sys-shape-corner-medium);
    margin-bottom: 24px;
    text-align: left;
}

.file-icon {
    font-size: 32px;
    color: var(--md-sys-color-primary);
}

.file-details {
    flex: 1;
    overflow: hidden;
}

.filename {
    display: block;
    font: var(--md-sys-typescale-body-large);
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    color: var(--md-sys-color-on-surface);
}

.filesize {
    font-size: 0.8rem;
    color: var(--md-sys-color-on-surface-variant);
}

.link-box {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 16px;
    background-color: var(--md-sys-color-surface);
    /* Reset to base surface */
    border: 1px solid var(--md-sys-color-outline);
    border-radius: 4px;
    padding: 0 12px;
    height: 56px;
    /* Standard text field height */
}

.link-input {
    flex: 1;
    background: transparent;
    border: none;
    color: var(--md-sys-color-on-surface);
    font: var(--md-sys-typescale-body-large);
    outline: none;
}

.copy-mini-btn,
.copy-btn {
    background: transparent;
    border: none;
    color: var(--md-sys-color-primary);
    cursor: pointer;
    padding: 8px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.2s;
}

.copy-mini-btn:hover,
.copy-btn:hover {
    background-color: rgba(208, 188, 255, 0.08);
}

.timer-badge {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    border-radius: 8px;
    background-color: rgba(242, 184, 181, 0.1);
    color: var(--md-sys-color-error);
    margin-bottom: 24px;
    font: var(--md-sys-typescale-label-large);
}

.hidden {
    display: none !important;
}

/* History Overlay - REMOVED (now sidebar) */
/* #history-view { ... } */

.history-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--md-sys-color-outline);
}

.history-header h2 {
    font: var(--md-sys-typescale-headline-small);
    color: var(--md-sys-color-on-surface);
    margin: 0;
}

.history-list {
    flex: 1;
    overflow-y: auto;
}

.history-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px;
    margin-bottom: 8px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.item-info {
    text-align: left;
    overflow: hidden;
}

.item-name {
    display: block;
    color: var(--md-sys-color-on-surface);
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.item-date {
    font-size: 0.75rem;
    color: var(--md-sys-color-on-surface-variant);
}

.empty-history {
    margin-top: 32px;
    color: var(--md-sys-color-on-surface-variant);
}

/* Select System */
.md-select-container {
    display: flex;
    flex-direction: column;
    gap: 24px;
    text-align: left;
    position: relative;
    z-index: 50;
    /* Ensure it floats above other elements */
}

.md-select {
    position: relative;
    width: 100%;
    cursor: pointer;
}

.md-select-field {
    width: 100%;
    padding: 12px 16px;
    background: transparent;
    border: 1px solid var(--md-sys-color-outline);
    border-radius: var(--md-sys-shape-corner-medium);
    /* Match card radius roughly */
    font: var(--md-sys-typescale-body-large);
    color: var(--md-sys-color-on-surface);
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: border-color 0.2s, background-color 0.2s;
}

.md-select:hover .md-select-field {
    background-color: rgba(230, 225, 229, 0.04);
}

.md-select.active .md-select-field {
    border-color: var(--md-sys-color-primary);
    background-color: rgba(208, 188, 255, 0.08);
}

.dropdown-icon {
    font-size: 14px;
    color: var(--md-sys-color-on-surface-variant);
    transition: transform 0.3s ease;
}

.md-select.active .dropdown-icon {
    transform: rotate(180deg);
    color: var(--md-sys-color-primary);
}

.md-select-menu {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    width: 100%;
    background-color: #2b2930;
    /* Elevated surface */
    border-radius: var(--md-sys-shape-corner-medium);
    box-shadow: 0px 4px 16px rgba(0, 0, 0, 0.5);
    list-style: none;
    padding: 4px;
    z-index: 100;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    transition: opacity 0.2s ease, transform 0.2s ease, visibility 0.2s;
}

.md-select.active .md-select-menu {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.md-select-option {
    padding: 12px 16px;
    color: var(--md-sys-color-on-surface);
    display: flex;
    align-items: center;
    border-radius: 8px;
    /* Inner options rounded */
    cursor: pointer;
    transition: background-color 0.2s;
    margin-bottom: 2px;
}

.md-select-option:hover {
    background-color: rgba(208, 188, 255, 0.08);
    /* primary with opacity */
}

.md-select-option.selected {
    background-color: var(--md-sys-color-primary-container);
    color: var(--md-sys-color-on-primary-container);
}

/* Toast (Snack bar) */
.toast {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    background-color: var(--md-sys-color-on-surface);
    /* Inverse Surface */
    color: var(--md-sys-color-surface);
    /* Inverse On Surface */
    padding: 14px 24px;
    border-radius: 4px;
    box-shadow: 0 3px 5px -1px rgba(0, 0, 0, 0.2), 0 6px 10px 0 rgba(0, 0, 0, 0.14), 0 1px 18px 0 rgba(0, 0, 0, 0.12);
    display: flex;
    align-items: center;
    gap: 12px;
    opacity: 0;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 1000;
    min-width: 300px;
}

.toast.show {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
}

/* Scrollbar */
::-webkit-scrollbar {
    width: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--md-sys-color-surface-variant);
    border-radius: 3px;
}