@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');

:root {
    /* Brand Colors (derived from Logo #2563EB) */
    --primary: #2563EB;
    --primary-hover: #1D4ED8;
    --primary-light: #EFF6FF;
    /* Very light blue for backgrounds */

    /* Neutral / UI Colors */
    --bs-body-bg: #F8FAFC;
    --surface: #FFFFFF;
    --surface-glass: rgba(255, 255, 255, 0.85);

    --text-main: #0F172A;
    --text-sub: #334155;
    --text-muted: #64748B;

    --border: #E2E8F0;
    --border-hover: #CBD5E1;

    --success: #10B981;
    --danger: #EF4444;
    --warning: #F59E0B;

    /* Spacing & Layout */
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 20px;
    --radius-xl: 32px;

    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
    --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.1);
    --shadow-glow: 0 0 20px rgba(37, 99, 235, 0.15);
}

/* Intro Overlay (High Priority) */
#intro-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background-color: #FFFFFF;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    transition: transform 0.8s cubic-bezier(0.77, 0, 0.175, 1), opacity 0.8s;
    transform: translateY(0);
}

#intro-overlay.fade-out {
    transform: translateY(-100%);
    opacity: 1;
    /* Keep it visible while sliding */
}

.intro-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    position: relative;
    overflow: hidden;
    /* Ensure mask effects stay contained if needed */
}

/* Reusable Animation Class */
.logo-reveal {
    /* Reveal Animation using Mask */
    -webkit-mask-image: linear-gradient(to right, black 50%, transparent 50%);
    -webkit-mask-size: 200% 100%;
    -webkit-mask-position: 100% 0;
    mask-image: linear-gradient(to right, black 50%, transparent 50%);
    mask-size: 200% 100%;
    mask-position: 100% 0;

    animation: maskWipe 1.5s cubic-bezier(0.22, 1, 0.36, 1) forwards;
}

@keyframes maskWipe {
    0% {
        -webkit-mask-position: 100% 0;
        mask-position: 100% 0;
    }

    100% {
        -webkit-mask-position: 0% 0;
        mask-position: 0% 0;
    }
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: 'Inter', sans-serif;
    -webkit-font-smoothing: antialiased;
}

body {
    background-color: var(--bs-body-bg);
    /* Subtle Premium Gradient */
    background: radial-gradient(circle at 10% 20%, rgb(241, 245, 249) 0%, rgb(248, 250, 252) 90%);
    color: var(--text-main);
    display: flex;
    justify-content: center;
    min-height: 100vh;
    overflow-x: hidden;
}

/* Background blob for extra flair */
body::before {
    content: '';
    position: fixed;
    top: -10vw;
    right: -10vw;
    width: 60vw;
    height: 60vw;
    background: radial-gradient(circle, rgba(37, 99, 235, 0.15) 0%, rgba(255, 255, 255, 0) 70%);
    z-index: -1;
    pointer-events: none;
    animation: float 10s ease-in-out infinite alternate;
}

body::after {
    content: '';
    position: fixed;
    bottom: -10vw;
    left: -10vw;
    width: 60vw;
    height: 60vw;
    background: radial-gradient(circle, rgba(96, 165, 250, 0.15) 0%, rgba(255, 255, 255, 0) 70%);
    z-index: -1;
    pointer-events: none;
    animation: float 15s ease-in-out infinite alternate-reverse;
}

@keyframes float {
    0% {
        transform: translate(0, 0);
    }

    100% {
        transform: translate(30px, 30px);
    }
}

/* Enhanced Input Fields */
.input-field {
    background: #F8FAFC;
    /* Light gray bg */
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 14px 16px;
    font-size: 0.95rem;
    outline: none;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    color: var(--text-main);
    font-weight: 500;
}

.input-field:focus {
    background: #FFFFFF;
    border-color: var(--primary);
    box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.1);
    transform: translateY(-1px);
}

.input-field::placeholder {
    color: #94A3B8;
}

/* Polished History Widget */
.history-widget {
    width: 100%;
    margin-top: 10px;
    background: rgba(255, 255, 255, 0.6);
    /* More visible glass */
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-radius: var(--radius-lg);
    padding: 24px;
    border: 1px solid rgba(255, 255, 255, 0.8);
    box-shadow: var(--shadow-lg);
}

/* Upload Card Hover */
.upload-card:hover {
    box-shadow: var(--shadow-xl), 0 0 30px rgba(37, 99, 235, 0.1);
    border-color: rgba(255, 255, 255, 0.9);
}

/* Main App Container */
.app-container {
    width: 100%;
    min-height: 100vh;
    background-color: transparent;
    display: flex;
    flex-direction: column;
    align-items: center;
    position: relative;
    z-index: 1;
    /* Compact layout adjustments */
    padding: 0 16px;
    justify-content: center;
    /* Center vertically */
}

/* History Widget */
.history-widget {
    width: 100%;
    margin-top: 10px;
    background: rgba(255, 255, 255, 0.4);
    border-radius: var(--radius);
    padding: 16px;
    border: 1px solid rgba(255, 255, 255, 0.5);
}

.history-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 14px;
    background: #FFFFFF;
    border-radius: 12px;
    /* Smoother corner */
    margin-bottom: 8px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.03);
    border: 1px solid var(--border);
    transition: all 0.2s;
}

.history-item:active {
    transform: scale(0.98);
}

/* Header */
.header {
    width: 100%;
    max-width: 1200px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 0;
    /* Reduced padding */
    position: absolute;
    /* Fixed at top */
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    animation: fadeInDown 0.8s ease-out;
    z-index: 10;
}

.brand {
    display: flex;
    align-items: center;
    gap: 12px;
}

/* Protected Logo */
.brand-logo-protected {
    background-image: url('/static/logo_v5.png');
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
    position: relative;
    /* Security: Disable interaction */
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    -khtml-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
    pointer-events: none;
    /* Disables right click effectively */
}

/* Overlay trick: Place invisible element on top */
.brand-logo-protected::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: transparent;
    z-index: 10;
}

.header-logo-size {
    width: 120px;
    height: 120px;
}

.intro-logo-size {
    width: 280px;
    height: 280px;
}

/* Deprecated img styles */
.brand-logo {
    display: none;
}

.brand-name {
    font-size: 1.4rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    color: var(--text-main);
    background: linear-gradient(135deg, var(--text-main) 0%, var(--primary) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.nav-link {
    color: var(--text-sub);
    text-decoration: none;
    font-weight: 500;
    font-size: 0.95rem;
    transition: color 0.2s;
}

.nav-link:hover {
    color: var(--primary);
}


/* Main Content */
.main-content {
    width: 100%;
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: center;
    gap: 60px;
    /* Restored gap for separation */
    flex: 1;
    padding: 60px 0 20px;
    /* Reduced top/bottom padding */
    max-width: 1200px;
    /* Increased max width */
    height: 100%;
    /* Take available height */
}

/* Left Panel (Hero + History) */
.left-panel {
    display: flex;
    flex-direction: column;
    width: 100%;
    max-width: 440px;
    gap: 32px;
    animation: fadeInLeft 0.8s ease-out;
}

/* Hero Section */
.hero-section {
    text-align: left;
    margin-bottom: 0;
}

.hero-title {
    font-size: 3rem;
    /* Slightly smaller for better fit */
    font-weight: 800;
    margin-bottom: 12px;
    line-height: 1.1;
    letter-spacing: -0.03em;
}

.upload-card-wrapper {
    flex: 1;
    max-width: 420px;
    /* Matching hero width logic */
    width: 100%;
}

/* Upload Card - The Star */
.upload-card {
    width: 100%;
    background: var(--surface-glass);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.6);
    border-radius: var(--radius-xl);
    padding: 32px;
    /* Reduced padding */
    box-shadow: var(--shadow-xl);
    transition: transform 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275), opacity 0.3s;
    animation: fadeInUp 0.8s ease-out;
    position: relative;
    overflow: hidden;
}

.card-header {
    text-align: center;
    margin-bottom: 20px;
    /* Reduced from 32px */
}

.card-title {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    font-size: 1.5rem;
    /* Reduced */
    font-weight: 700;
    color: var(--text-main);
    margin-bottom: 4px;
    letter-spacing: -0.01em;
}

.dropzone {
    background: var(--primary-light);
    border: 2px dashed #BFDBFE;
    border-radius: var(--radius-lg);
    padding: 24px 20px;
    /* Significantly reduced */
    text-align: center;
    cursor: pointer;
    transition: all 0.3s ease;
    margin-bottom: 20px;
    position: relative;
}

.drop-icon {
    font-size: 42px;
    /* Reduced */
    color: var(--primary);
    margin-bottom: 10px;
    transition: transform 0.3s;
}

/* Time Selector */
.time-selector {
    background: #F8FAFC;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 14px 16px;
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    transition: all 0.2s;
    color: var(--text-main);
    font-weight: 500;
}

.time-selector:hover {
    border-color: var(--primary);
    background: #FFFFFF;
    box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.1);
}

.time-selector i {
    color: var(--primary);
    font-size: 1.2rem;
}

/* Premium Button Upgrade */
.btn-primary {
    background: linear-gradient(135deg, #3B82F6 0%, #2563EB 100%);
    color: white;
    width: 100%;
    margin-top: 24px;
    padding: 16px;
    border: none;
    border-radius: var(--radius-md);
    font-size: 1.1rem;
    font-weight: 600;
    cursor: pointer;
    position: relative;
    overflow: hidden;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 4px 6px -1px rgba(37, 99, 235, 0.3), 0 10px 15px -3px rgba(37, 99, 235, 0.2);
}

.btn-primary::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
    transition: 0.5s;
}

.btn-primary:hover::before {
    left: 100%;
}

.btn-primary:not(:disabled):hover {
    transform: translateY(-2px);
    box-shadow: 0 20px 25px -5px rgba(37, 99, 235, 0.4), 0 10px 10px -5px rgba(37, 99, 235, 0.3);
    background: linear-gradient(135deg, #2563EB 0%, #1D4ED8 100%);
}

.btn-primary:active {
    transform: translateY(1px);
    box-shadow: 0 2px 4px -1px rgba(37, 99, 235, 0.2);
}

.btn-primary:disabled {
    background: #94A3B8;
    cursor: not-allowed;
    box-shadow: none;
    transform: none;
}

/* Modal & Clock UI */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(15, 23, 42, 0.4);
    backdrop-filter: blur(8px);
    z-index: 1000;
    display: flex;
    justify-content: center;
    align-items: center;
    animation: fadeIn 0.2s ease-out;
}

.clock-modal {
    background: white;
    padding: 32px;
    border-radius: var(--radius-xl);
    width: 90%;
    max-width: 360px;
    box-shadow: var(--shadow-xl);
    text-align: center;
    animation: scaleIn 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.modal-title {
    font-size: 1.25rem;
    font-weight: 700;
    margin-bottom: 8px;
    color: var(--text-main);
}

.modal-subtitle {
    font-size: 0.9rem;
    color: var(--text-muted);
    margin-bottom: 24px;
}

.clock-display {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
    margin-bottom: 24px;
}

.clock-face {
    width: 200px;
    height: 200px;
    background: #F1F5F9;
    border-radius: 50%;
    position: relative;
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.05);
    cursor: pointer;
    touch-action: none;
    /* Prevent scroll on mobile */
}

.clock-center {
    width: 12px;
    height: 12px;
    background: var(--primary);
    border-radius: 50%;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 2;
}

.clock-hand {
    width: 4px;
    height: 80px;
    background: var(--primary);
    position: absolute;
    bottom: 50%;
    left: 50%;
    transform-origin: bottom center;
    transform: translateX(-50%) rotate(0deg);
    border-radius: 4px;
    transition: transform 0.1s cubic-bezier(0.4, 2.08, 0.55, 0.44);
    /* Bouncy */
}

.clock-marker {
    position: absolute;
    font-weight: 600;
    color: var(--text-muted);
    font-size: 1rem;
}

.clock-marker.twelve {
    top: 10px;
    left: 50%;
    transform: translateX(-50%);
}

.clock-marker.three {
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
}

.clock-marker.six {
    bottom: 10px;
    left: 50%;
    transform: translateX(-50%);
}

.clock-marker.nine {
    left: 10px;
    top: 50%;
    transform: translateY(-50%);
}

.digital-time {
    font-size: 2rem;
    font-weight: 800;
    color: var(--primary);
    font-variant-numeric: tabular-nums;
    display: flex;
    align-items: center;
    gap: 12px;
}

.am-pm-toggle {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.am-pm-toggle span {
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--text-muted);
    padding: 2px 6px;
    border-radius: 4px;
    cursor: pointer;
    border: 1px solid transparent;
}

.am-pm-toggle span.active {
    background: var(--primary);
    color: white;
}

.modal-actions {
    display: flex;
    gap: 12px;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

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

.btn-secondary:hover {
    background: var(--bs-body-bg);
    border-color: var(--border-hover);
    color: var(--text-main);
}

.btn-remove {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 0.9rem;
    padding: 4px 8px;
    border-radius: var(--radius-sm);
    transition: all 0.2s;
}

.btn-remove:hover {
    background-color: #FEE2E2;
    color: var(--danger);
}

/* Progress */
.progress-container {
    margin-top: 24px;
    display: none;
    animation: fadeIn 0.3s;
}

.progress-bar-bg {
    height: 8px;
    background: #E2E8F0;
    border-radius: 10px;
    overflow: hidden;
}

.progress-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--primary), #60A5FA);
    width: 0%;
    transition: width 0.3s ease-out;
    border-radius: 10px;
}

/* Result Section */
.qr-container {
    background: white;
    padding: 24px;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    display: flex;
    flex-direction: column;
    align-items: center;
    margin-bottom: 24px;
    border: 1px solid var(--border);
}

.qr-text {
    margin-top: 12px;
    font-size: 0.9rem;
    color: var(--text-sub);
    font-weight: 500;
    margin-bottom: 16px;
}

.url-copy-box {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: #F1F5F9;
    padding: 10px 14px;
    border-radius: 12px;
    border: 1px solid var(--border);
    max-width: 320px;
    margin: 0 auto;
    font-family: monospace;
    font-size: 0.95rem;
    color: var(--text-main);
    gap: 10px;
}

#mainUrlText {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.btn-copy-main {
    background: white;
    border: 1px solid var(--border);
    border-radius: 8px;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: var(--primary);
    transition: all 0.2s;
    flex-shrink: 0;
}

.btn-copy-main:hover {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

/* History Widget */
.history-widget {
    width: 100%;
    background: var(--surface-glass);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.5);
    border-radius: var(--radius-lg);
    padding: 24px;
    box-shadow: var(--shadow-md);
    animation: fadeInUp 0.8s ease-out 0.2s backwards;
}

.history-item {
    background: white;
    border: 1px solid transparent;
    border-radius: 10px;
    padding: 10px 14px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.9rem;
    transition: all 0.2s;
    box-shadow: var(--shadow-sm);
    margin-bottom: 8px;
}

.history-item:hover {
    border-color: var(--primary-light);
    transform: translateX(2px);
    box-shadow: var(--shadow-md);
}

.history-name {
    font-weight: 600;
    color: var(--text-main);
    max-width: 160px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* History Actions */
.history-actions {
    display: flex;
    align-items: center;
    gap: 4px;
}

.history-action-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
    color: var(--text-muted);
}

.history-action-btn:hover {
    background: #F1F5F9;
    color: var(--primary);
}

.history-action-btn.delete:hover {
    background: #FEF2F2;
    color: var(--danger);
}

/* Toast */
.toast {
    background: white;
    border-radius: var(--radius-md);
    padding: 14px 20px;
    margin-bottom: 12px;
    box-shadow: var(--shadow-xl);
    display: flex;
    align-items: center;
    gap: 12px;
    font-weight: 500;
    font-size: 0.95rem;
    animation: slideInRight 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    border-left: 4px solid var(--primary);
    min-width: 300px;
    opacity: 0;
    transition: opacity 0.3s;
}

.toast-success {
    border-left-color: var(--success);
    color: #065F46;
}

.toast-error {
    border-left-color: var(--danger);
    color: #991B1B;
}

.toast-info {
    border-left-color: var(--primary);
    color: var(--text-main);
}

/* Animations */
@keyframes fadeInDown {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }

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

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

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

@keyframes scaleIn {
    from {
        opacity: 0;
        transform: scale(0.9);
    }

    to {
        opacity: 1;
        transform: scale(1);
    }
}

@keyframes slideInRight {
    from {
        opacity: 0;
        transform: translateX(50px);
    }

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

@keyframes fadeInSlide {
    from {
        opacity: 0;
        transform: translateX(-10px);
    }

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

@keyframes pulse-border {
    0% {
        box-shadow: 0 0 0 0 rgba(37, 99, 235, 0.4);
        border-color: var(--primary);
    }

    70% {
        box-shadow: 0 0 0 14px rgba(37, 99, 235, 0);
        border-color: var(--primary-hover);
    }

    100% {
        box-shadow: 0 0 0 0 rgba(37, 99, 235, 0);
        border-color: var(--primary);
    }
}

.dropzone.drag-over {
    border-color: var(--primary);
    background: var(--primary-light);
    animation: pulse-border 1.5s infinite;
    transform: scale(1.02);
}

/* Confetti */
.confetti-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    pointer-events: none;
    z-index: 9999;
    overflow: hidden;
}

.confetti-particle {
    position: absolute;
    width: 8px;
    height: 8px;
    background-color: var(--primary);
    opacity: 0;
}

/* Footer */
.footer {
    text-align: center;
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-top: auto;
    width: 100%;
    padding: 20px;
}

/* Utilities */
.hidden {
    display: none !important;
}

.w-full {
    width: 100%;
}

/* Responsive */
@media (max-width: 600px) {
    .app-container {
        padding: 10px;
    }

    .upload-card {
        padding: 24px;
        border-radius: var(--radius-lg);
    }

    .header {
        flex-direction: column;
        gap: 16px;
        margin-bottom: 20px;
    }

    .grid-inputs {
        grid-template-columns: 1fr;
    }

    .card-title {
        font-size: 1.4rem;
    }
}

/* Responsive Layout Adjustment */
@media (max-width: 850px) {
    .main-content {
        flex-direction: column;
        text-align: center;
        gap: 40px;
        padding-top: 40px;
        height: auto;
        /* Allow auto height on mobile */
    }

    .left-panel {
        max-width: 100%;
        align-items: center;
    }

    .hero-section {
        text-align: center;
        max-width: 100%;
        margin-bottom: 0;
    }

    .upload-card-wrapper {
        max-width: 100%;
    }

    .header {
        position: relative;
        margin-bottom: 20px;
        padding: 20px;
        width: 100%;
    }
}