/* ===== CSS Reset & Variables ===== */
*,
*::before,
*::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --bg-primary: #0a0e1a;
    --bg-secondary: #111827;
    --bg-card: rgba(17, 24, 39, 0.7);
    --bg-card-hover: rgba(30, 41, 59, 0.8);
    --bg-glass: rgba(255, 255, 255, 0.03);
    --bg-input: rgba(15, 23, 42, 0.8);

    --text-primary: #f1f5f9;
    --text-secondary: #94a3b8;
    --text-tertiary: #64748b;
    --text-muted: #475569;

    --accent-primary: #6366f1;
    --accent-primary-light: #818cf8;
    --accent-primary-glow: rgba(99, 102, 241, 0.3);
    --accent-success: #10b981;
    --accent-success-light: #34d399;
    --accent-success-glow: rgba(16, 185, 129, 0.3);
    --accent-warning: #f59e0b;
    --accent-danger: #ef4444;

    --border-color: rgba(148, 163, 184, 0.08);
    --border-hover: rgba(148, 163, 184, 0.15);
    --border-focus: rgba(99, 102, 241, 0.5);

    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 20px;

    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.5);
    --shadow-glow: 0 0 20px var(--accent-primary-glow);

    --transition-fast: 150ms cubic-bezier(0.4, 0, 0.2, 1);
    --transition-normal: 250ms cubic-bezier(0.4, 0, 0.2, 1);
    --transition-slow: 400ms cubic-bezier(0.4, 0, 0.2, 1);

    --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    --font-mono: 'JetBrains Mono', 'Fira Code', monospace;
}

html {
    font-size: 16px;
    scroll-behavior: smooth;
}

body {
    font-family: var(--font-sans);
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* ===== Animated Background ===== */
.bg-orb {
    position: fixed;
    border-radius: 50%;
    filter: blur(120px);
    opacity: 0.4;
    pointer-events: none;
    z-index: 0;
    animation: float 20s ease-in-out infinite;
}

.bg-orb-1 {
    width: 500px;
    height: 500px;
    background: radial-gradient(circle, rgba(99, 102, 241, 0.15), transparent 70%);
    top: -150px;
    right: -100px;
    animation-delay: 0s;
}

.bg-orb-2 {
    width: 400px;
    height: 400px;
    background: radial-gradient(circle, rgba(16, 185, 129, 0.1), transparent 70%);
    bottom: -100px;
    left: -100px;
    animation-delay: -7s;
}

.bg-orb-3 {
    width: 350px;
    height: 350px;
    background: radial-gradient(circle, rgba(139, 92, 246, 0.1), transparent 70%);
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    animation-delay: -14s;
}

@keyframes float {
    0%, 100% { transform: translate(0, 0) scale(1); }
    25% { transform: translate(30px, -40px) scale(1.05); }
    50% { transform: translate(-20px, 20px) scale(0.95); }
    75% { transform: translate(15px, 30px) scale(1.02); }
}

/* ===== App Container ===== */
.app-container {
    position: relative;
    z-index: 1;
    max-width: 720px;
    margin: 0 auto;
    padding: 24px 20px 80px;
}

/* ===== Header ===== */
.app-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 0;
    margin-bottom: 24px;
}

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

.logo-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    background: linear-gradient(135deg, var(--accent-primary), #8b5cf6);
    border-radius: var(--radius-md);
    color: white;
    box-shadow: 0 4px 16px rgba(99, 102, 241, 0.35);
}

.app-header h1 {
    font-size: 1.5rem;
    font-weight: 800;
    letter-spacing: -0.02em;
    background: linear-gradient(135deg, var(--text-primary), var(--accent-primary-light));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.badge {
    font-size: 0.65rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 4px 8px;
    background: rgba(99, 102, 241, 0.15);
    color: var(--accent-primary-light);
    border-radius: 6px;
    border: 1px solid rgba(99, 102, 241, 0.2);
}

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

.btn-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    background: var(--bg-glass);
    color: var(--text-secondary);
    cursor: pointer;
    transition: all var(--transition-fast);
    backdrop-filter: blur(8px);
}

.btn-icon:hover {
    background: rgba(239, 68, 68, 0.1);
    border-color: rgba(239, 68, 68, 0.3);
    color: var(--accent-danger);
    transform: translateY(-1px);
}

.serial-count {
    display: flex;
    align-items: baseline;
    gap: 4px;
    padding: 8px 14px;
    background: var(--bg-glass);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    backdrop-filter: blur(8px);
}

.count-number {
    font-size: 1.2rem;
    font-weight: 700;
    font-family: var(--font-mono);
    color: var(--accent-primary-light);
}

.count-label {
    font-size: 0.75rem;
    color: var(--text-tertiary);
    font-weight: 500;
}

/* ===== Input Section ===== */
.input-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 20px;
    backdrop-filter: blur(16px);
    transition: border-color var(--transition-normal);
}

.input-card:focus-within {
    border-color: var(--border-focus);
    box-shadow: var(--shadow-glow);
}

.input-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
}

.input-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-primary);
}

.input-title svg {
    color: var(--accent-primary-light);
}

.input-hint {
    font-size: 0.72rem;
    color: var(--text-muted);
    font-weight: 400;
}

textarea {
    width: 100%;
    min-height: 140px;
    max-height: 300px;
    padding: 14px 16px;
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-family: var(--font-mono);
    font-size: 0.85rem;
    line-height: 1.7;
    resize: vertical;
    outline: none;
    transition: border-color var(--transition-fast);
}

textarea::placeholder {
    color: var(--text-muted);
    font-family: var(--font-sans);
    font-size: 0.82rem;
}

textarea:focus {
    border-color: var(--accent-primary);
}

.input-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 14px;
}

/* ===== Buttons ===== */
.btn-primary {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 10px 22px;
    background: linear-gradient(135deg, var(--accent-primary), #7c3aed);
    color: white;
    border: none;
    border-radius: var(--radius-sm);
    font-family: var(--font-sans);
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition-fast);
    box-shadow: 0 2px 12px rgba(99, 102, 241, 0.3);
}

.btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 20px rgba(99, 102, 241, 0.45);
    filter: brightness(1.1);
}

.btn-primary:active {
    transform: translateY(0);
}

.btn-secondary {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 10px 18px;
    background: transparent;
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    font-family: var(--font-sans);
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.04);
    border-color: var(--border-hover);
    color: var(--text-primary);
}

/* ===== Search & Filter ===== */
.filter-section {
    display: flex;
    align-items: center;
    gap: 12px;
    margin: 24px 0 16px;
}

.search-box {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    backdrop-filter: blur(8px);
    transition: border-color var(--transition-fast);
}

.search-box:focus-within {
    border-color: var(--border-focus);
}

.search-box svg {
    color: var(--text-muted);
    flex-shrink: 0;
}

.search-box input {
    flex: 1;
    background: none;
    border: none;
    outline: none;
    color: var(--text-primary);
    font-family: var(--font-sans);
    font-size: 0.85rem;
}

.search-box input::placeholder {
    color: var(--text-muted);
}

.filter-tabs {
    display: flex;
    gap: 2px;
    padding: 3px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    backdrop-filter: blur(8px);
}

.filter-tab {
    padding: 8px 14px;
    background: none;
    border: none;
    border-radius: 6px;
    color: var(--text-tertiary);
    font-family: var(--font-sans);
    font-size: 0.78rem;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition-fast);
    white-space: nowrap;
}

.filter-tab:hover {
    color: var(--text-secondary);
}

.filter-tab.active {
    background: var(--accent-primary);
    color: white;
    box-shadow: 0 2px 8px rgba(99, 102, 241, 0.3);
}

/* ===== Serial Number List ===== */
.serial-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.load-more {
    display: block;
    margin: 16px auto 0;
}

.load-more.hidden {
    display: none;
}

.serial-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    backdrop-filter: blur(8px);
    transition: all var(--transition-normal);
    animation: slideIn 0.3s ease-out;
}

.serial-item:hover {
    background: var(--bg-card-hover);
    border-color: var(--border-hover);
    transform: translateX(4px);
}

.serial-item.copied {
    border-left: 3px solid var(--accent-success);
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(8px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.serial-index {
    font-size: 0.72rem;
    font-weight: 600;
    color: var(--text-muted);
    font-family: var(--font-mono);
    min-width: 28px;
    text-align: center;
    padding: 4px 0;
    background: rgba(255, 255, 255, 0.03);
    border-radius: 4px;
}

.serial-text {
    flex: 1;
    font-family: var(--font-mono);
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text-primary);
    letter-spacing: 0.03em;
    user-select: all;
    word-break: break-all;
}

.serial-item.copied .serial-text {
    color: var(--text-secondary);
}

.serial-time {
    font-size: 0.68rem;
    color: var(--text-muted);
    white-space: nowrap;
}

.btn-copy {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 7px 16px;
    background: rgba(99, 102, 241, 0.1);
    border: 1px solid rgba(99, 102, 241, 0.2);
    border-radius: 8px;
    color: var(--accent-primary-light);
    font-family: var(--font-sans);
    font-size: 0.78rem;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition-fast);
    white-space: nowrap;
    flex-shrink: 0;
}

.btn-copy:hover {
    background: rgba(99, 102, 241, 0.2);
    border-color: rgba(99, 102, 241, 0.4);
    transform: scale(1.03);
}

.btn-copy:active {
    transform: scale(0.97);
}

.btn-copy.copied {
    background: rgba(16, 185, 129, 0.12);
    border-color: rgba(16, 185, 129, 0.3);
    color: var(--accent-success-light);
    pointer-events: none;
}

.btn-copy svg {
    width: 14px;
    height: 14px;
}

.btn-delete {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    background: none;
    border: none;
    border-radius: 6px;
    color: var(--text-muted);
    cursor: pointer;
    transition: all var(--transition-fast);
    flex-shrink: 0;
    opacity: 0;
}

.serial-item:hover .btn-delete {
    opacity: 1;
}

.btn-delete:hover {
    background: rgba(239, 68, 68, 0.1);
    color: var(--accent-danger);
}

/* ===== Restore Button ===== */
.btn-restore {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    background: none;
    border: none;
    border-radius: 6px;
    color: var(--text-muted);
    cursor: pointer;
    transition: all var(--transition-fast);
    flex-shrink: 0;
    opacity: 0;
}

.serial-item:hover .btn-restore {
    opacity: 1;
}

.btn-restore:hover {
    background: rgba(245, 158, 11, 0.12);
    color: var(--accent-warning);
    transform: rotate(-45deg);
}

.btn-icon-restore:hover {
    background: rgba(245, 158, 11, 0.1);
    border-color: rgba(245, 158, 11, 0.3);
    color: var(--accent-warning);
    transform: translateY(-1px);
}

/* ===== Empty State ===== */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px 20px;
    text-align: center;
}

.empty-state.hidden {
    display: none;
}

.empty-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100px;
    height: 100px;
    background: rgba(99, 102, 241, 0.06);
    border-radius: 50%;
    margin-bottom: 20px;
    color: var(--text-muted);
    animation: pulse 3s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% { transform: scale(1); opacity: 0.8; }
    50% { transform: scale(1.05); opacity: 1; }
}

.empty-state h3 {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 6px;
}

.empty-state p {
    font-size: 0.85rem;
    color: var(--text-muted);
}

/* ===== Toast Notification ===== */
.toast-container {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 9999;
    display: flex;
    flex-direction: column-reverse;
    gap: 8px;
    pointer-events: none;
}

.toast {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 20px;
    background: rgba(17, 24, 39, 0.95);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    backdrop-filter: blur(20px);
    box-shadow: var(--shadow-lg);
    animation: toastIn 0.35s ease-out;
    pointer-events: auto;
    white-space: nowrap;
}

.toast.toast-out {
    animation: toastOut 0.3s ease-in forwards;
}

.toast-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    flex-shrink: 0;
}

.toast-icon.success {
    background: rgba(16, 185, 129, 0.15);
    color: var(--accent-success-light);
}

.toast-icon.error {
    background: rgba(239, 68, 68, 0.15);
    color: var(--accent-danger);
}

.toast-icon.info {
    background: rgba(99, 102, 241, 0.15);
    color: var(--accent-primary-light);
}

.toast-message {
    font-size: 0.82rem;
    font-weight: 500;
    color: var(--text-primary);
}

@keyframes toastIn {
    from {
        opacity: 0;
        transform: translateY(16px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

@keyframes toastOut {
    from {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
    to {
        opacity: 0;
        transform: translateY(16px) scale(0.95);
    }
}

/* ===== Scrollbar ===== */
::-webkit-scrollbar {
    width: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--text-muted);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-tertiary);
}

/* ===== Responsive ===== */
@media (max-width: 640px) {
    .app-container {
        padding: 16px 14px 80px;
    }

    .app-header {
        flex-wrap: wrap;
        gap: 12px;
    }

    .badge {
        display: none;
    }

    .filter-section {
        flex-direction: column;
    }

    .search-box {
        width: 100%;
    }

    .filter-tabs {
        width: 100%;
        justify-content: center;
    }

    .serial-item {
        flex-wrap: wrap;
        gap: 8px;
    }

    .serial-text {
        order: 1;
        flex-basis: calc(100% - 44px);
    }

    .serial-time {
        order: 3;
    }

    .btn-copy {
        order: 2;
        margin-left: auto;
    }

    .btn-delete {
        opacity: 1;
    }

    .btn-restore {
        opacity: 1;
    }
}

/* ===== Login Page ===== */
.login-wrapper {
    position: relative;
    z-index: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 20px;
}

.login-card {
    width: 100%;
    max-width: 400px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-xl);
    padding: 40px 32px;
    backdrop-filter: blur(24px);
    box-shadow: var(--shadow-lg);
    animation: loginFadeIn 0.5s ease-out;
}

@keyframes loginFadeIn {
    from {
        opacity: 0;
        transform: translateY(20px) scale(0.97);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.login-logo {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    margin-bottom: 32px;
}

.logo-icon-lg {
    width: 64px;
    height: 64px;
    border-radius: var(--radius-lg);
    box-shadow: 0 8px 32px rgba(99, 102, 241, 0.4);
}

.login-title {
    font-size: 1.8rem;
    font-weight: 800;
    letter-spacing: -0.02em;
    background: linear-gradient(135deg, var(--text-primary), var(--accent-primary-light));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.login-subtitle {
    font-size: 0.85rem;
    color: var(--text-muted);
    font-weight: 400;
}

/* Login error */
.login-error {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 16px;
    margin-bottom: 20px;
    background: rgba(239, 68, 68, 0.08);
    border: 1px solid rgba(239, 68, 68, 0.2);
    border-radius: var(--radius-sm);
    color: #fca5a5;
    font-size: 0.82rem;
    font-weight: 500;
}

.login-error svg {
    color: var(--accent-danger);
    flex-shrink: 0;
}

.login-error.shake {
    animation: shake 0.5s ease-in-out;
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    10%, 50%, 90% { transform: translateX(-6px); }
    30%, 70% { transform: translateX(6px); }
}

/* Login form */
.login-form {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.login-field {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.login-label {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-secondary);
}

.login-label svg {
    color: var(--accent-primary-light);
}

.password-input-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

.password-input-wrapper input {
    width: 100%;
    padding: 14px 48px 14px 16px;
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-family: var(--font-mono);
    font-size: 0.95rem;
    letter-spacing: 0.05em;
    outline: none;
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.password-input-wrapper input::placeholder {
    color: var(--text-muted);
    font-family: var(--font-sans);
    font-size: 0.85rem;
    letter-spacing: 0;
}

.password-input-wrapper input:focus {
    border-color: var(--accent-primary);
    box-shadow: var(--shadow-glow);
}

.toggle-password {
    position: absolute;
    right: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    background: none;
    border: none;
    border-radius: 6px;
    color: var(--text-muted);
    cursor: pointer;
    transition: color var(--transition-fast), background var(--transition-fast);
}

.toggle-password:hover {
    color: var(--text-secondary);
    background: rgba(255, 255, 255, 0.04);
}

/* Login button */
.btn-login {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    padding: 14px 24px;
    background: linear-gradient(135deg, var(--accent-primary), #7c3aed);
    color: white;
    border: none;
    border-radius: var(--radius-md);
    font-family: var(--font-sans);
    font-size: 0.95rem;
    font-weight: 700;
    cursor: pointer;
    transition: all var(--transition-fast);
    box-shadow: 0 4px 20px rgba(99, 102, 241, 0.35);
}

.btn-login:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 28px rgba(99, 102, 241, 0.5);
    filter: brightness(1.1);
}

.btn-login:active {
    transform: translateY(0);
}

/* ===== Logout Button ===== */
.btn-icon-logout {
    text-decoration: none;
}

.btn-icon-logout:hover {
    background: rgba(239, 68, 68, 0.1);
    border-color: rgba(239, 68, 68, 0.3);
    color: var(--accent-danger);
    transform: translateY(-1px);
}

/* ===== Login Responsive ===== */
@media (max-width: 640px) {
    .login-card {
        padding: 32px 24px;
    }

    .logo-icon-lg {
        width: 56px;
        height: 56px;
    }

    .login-title {
        font-size: 1.5rem;
    }
}
