/* ========================================
   texfer - Apple iOS Inspired Design
   Clean, Minimal, Modern
======================================== */

/* Local Font */
@font-face {
    font-family: 'DejaVuSans';
    src: url('/static/fonts/DejaVuSans.ttf') format('truetype');
    font-weight: 400;
    font-style: normal;
    font-display: swap;
}

/* CSS Variables for Theme System */
:root {
    /* Light Mode (Default) */
    --bg-primary: #f2f2f7;
    --bg-secondary: #ffffff;
    --bg-tertiary: #e5e5ea;
    --bg-elevated: rgba(255, 255, 255, 0.72);
    --bg-blur: rgba(255, 255, 255, 0.85);
    
    --text-primary: #000000;
    --text-secondary: #3c3c43;
    --text-tertiary: #8e8e93;
    --text-placeholder: #c7c7cc;
    
    --accent: #007AFF;
    --accent-secondary: #5856D6;
    --success: #34C759;
    --warning: #FF9500;
    --error: #FF3B30;
    
    --border: rgba(60, 60, 67, 0.12);
    --shadow: rgba(0, 0, 0, 0.04);
    --shadow-elevated: rgba(0, 0, 0, 0.08);
    
    --input-bg: #ffffff;
    --card-bg: #ffffff;
    --code-bg: #f5f5f7;
    
    --transition-fast: 0.15s ease;
    --transition-normal: 0.25s ease;
    --transition-slow: 0.4s ease;
    
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 20px;
    --radius-full: 9999px;
}

/* Dark Mode */
[data-theme="dark"] {
    --bg-primary: #000000;
    --bg-secondary: #1c1c1e;
    --bg-tertiary: #2c2c2e;
    --bg-elevated: rgba(28, 28, 30, 0.72);
    --bg-blur: rgba(28, 28, 30, 0.85);
    
    --text-primary: #ffffff;
    --text-secondary: #ebebf5;
    --text-tertiary: #8e8e93;
    --text-placeholder: #48484a;
    
    --border: rgba(84, 84, 88, 0.36);
    --shadow: rgba(0, 0, 0, 0.3);
    --shadow-elevated: rgba(0, 0, 0, 0.5);
    
    --input-bg: #2c2c2e;
    --card-bg: #1c1c1e;
    --code-bg: #2c2c2e;
}

/* Base Reset & Typography */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    -webkit-tap-highlight-color: transparent;
}

html {
    font-size: 16px;
    -webkit-text-size-adjust: 100%;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro Text", "Helvetica Neue", "Segoe UI", Roboto, sans-serif;
    background-color: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.47;
    letter-spacing: -0.022em;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    transition: background-color var(--transition-normal), color var(--transition-normal);
}


/* Main Content Container */
.main-content {
    flex: 1;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 24px 20px;
    padding-bottom: 80px;
    padding-left: max(20px, env(safe-area-inset-left));
    padding-right: max(20px, env(safe-area-inset-right));
}

/* Card Component */
.card {
    background: var(--card-bg);
    width: 100%;
    max-width: 420px;
    border-radius: var(--radius-xl);
    padding: 32px 24px;
    box-shadow: 
        0 0 0 1px var(--border),
        0 8px 32px var(--shadow),
        0 2px 8px var(--shadow);
    transition: background-color var(--transition-normal), box-shadow var(--transition-normal);
    position: relative;
    overflow: hidden;
}

.card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 1px;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.5), transparent);
    opacity: 0;
}

[data-theme="dark"] .card::before {
    opacity: 0.1;
}

/* Page Title */
.page-title {
    font-size: 28px;
    font-weight: 700;
    letter-spacing: -0.5px;
    text-align: center;
    margin-bottom: 28px;
    color: var(--text-primary);
}

.page-subtitle {
    font-size: 15px;
    color: var(--text-tertiary);
    text-align: center;
    margin-top: -20px;
    margin-bottom: 28px;
}

/* Form Elements */
.form-group {
    margin-bottom: 20px;
}

.form-label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-tertiary);
    text-transform: uppercase;
    letter-spacing: 0.02em;
    margin-bottom: 8px;
    margin-left: 4px;
}

.form-input,
.form-textarea,
.form-select {
    width: 100%;
    background: var(--input-bg);
    color: var(--text-primary);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 14px 16px;
    font-size: 17px;
    font-family: inherit;
    outline: none;
    transition: all var(--transition-fast);
    appearance: none;
    -webkit-appearance: none;
}

.form-input:focus,
.form-textarea:focus,
.form-select:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(0, 122, 255, 0.15);
}

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

.form-textarea {
    resize: vertical;
    min-height: 140px;
    line-height: 1.5;
}

/* Custom Select */
.form-select {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23007AFF' d='M6 8.825L1.175 4 2.238 2.938 6 6.7l3.763-3.762L10.825 4z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 16px center;
    padding-right: 44px;
    cursor: pointer;
}

/* Password Input Wrapper */
.password-wrapper {
    position: relative;
}

.password-wrapper .form-input {
    padding-right: 50px;
}

.password-toggle {
    position: absolute;
    right: 4px;
    top: 50%;
    transform: translateY(-50%);
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: var(--accent);
    border-radius: var(--radius-sm);
    transition: background-color var(--transition-fast);
}

.password-toggle:hover {
    background: var(--bg-tertiary);
}

.password-toggle svg {
    width: 22px;
    height: 22px;
    fill: currentColor;
}

/* Help Text */
.help-text {
    font-size: 13px;
    color: var(--text-tertiary);
    margin-top: 8px;
    margin-left: 4px;
    line-height: 1.4;
}

.help-text.error {
    color: var(--error);
}

.help-text.success {
    color: var(--success);
}

/* Error Box */
.error-box {
    background: rgba(255, 59, 48, 0.12);
    color: var(--error);
    padding: 14px 16px;
    border-radius: var(--radius-md);
    font-size: 14px;
    font-weight: 500;
    text-align: center;
    margin-bottom: 20px;
    border: 1px solid rgba(255, 59, 48, 0.2);
}

/* Primary Button */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    padding: 16px 24px;
    font-size: 17px;
    font-weight: 600;
    font-family: inherit;
    border: none;
    border-radius: var(--radius-md);
    cursor: pointer;
    text-decoration: none;
    transition: all var(--transition-fast);
    position: relative;
    overflow: hidden;
}

.btn:active {
    transform: scale(0.98);
}

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

.btn-primary {
    background: var(--accent);
    color: #ffffff;
}

.btn-primary:hover:not(:disabled) {
    background: #0066d6;
}

.btn-secondary {
    background: var(--bg-tertiary);
    color: var(--accent);
}

.btn-secondary:hover:not(:disabled) {
    background: var(--border);
}

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

/* Link Box (for displaying URLs) */
.link-box {
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--bg-tertiary);
    border-radius: var(--radius-md);
    padding: 4px;
    margin-bottom: 20px;
    border: 1px solid var(--border);
}

.link-box input {
    flex: 1;
    background: transparent;
    border: none;
    padding: 12px;
    font-size: 14px;
    color: var(--text-secondary);
    text-align: center;
    outline: none;
    font-family: "SF Mono", "Menlo", "Monaco", "Courier New", monospace;
}

.link-box .btn {
    width: auto;
    padding: 10px 16px;
    font-size: 15px;
    border-radius: var(--radius-sm);
    flex-shrink: 0;
}

/* Actions Grid */
.actions {
    display: grid;
    gap: 12px;
}

/* Code/Text Preview */
.text-preview {
    background: var(--code-bg);
    color: var(--text-secondary);
    padding: 20px;
    border-radius: var(--radius-md);
    font-family: "SF Mono", "Menlo", "Monaco", "Courier New", monospace;
    font-size: 14px;
    line-height: 1.6;
    white-space: pre-wrap;
    word-wrap: break-word;
    overflow-x: auto;
    margin-bottom: 20px;
    border: 1px solid var(--border);
    max-height: 400px;
    overflow-y: auto;
}

/* Header with actions */
.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--border);
}

.card-header h2 {
    font-size: 20px;
    font-weight: 700;
    margin: 0;
}

.card-header .btn {
    width: auto;
    padding: 10px 20px;
    border-radius: var(--radius-full);
    font-size: 15px;
}

/* Theme Toggle */
.theme-toggle {
    position: fixed;
    top: 20px;
    right: 20px;
    width: 48px;
    height: 48px;
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-full);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all var(--transition-fast);
    box-shadow: 0 4px 12px var(--shadow);
    z-index: 1000;
}

.theme-toggle:hover {
    transform: scale(1.05);
    box-shadow: 0 6px 20px var(--shadow-elevated);
}

.theme-toggle:active {
    transform: scale(0.95);
}

.theme-toggle svg {
    width: 24px;
    height: 24px;
    fill: var(--text-primary);
    transition: transform var(--transition-normal);
}

.theme-toggle:hover svg {
    transform: rotate(15deg);
}

/* Sun icon for light mode, Moon icon for dark mode */
.icon-sun,
.icon-moon {
    position: absolute;
    transition: opacity var(--transition-fast), transform var(--transition-fast);
}

.icon-moon {
    opacity: 0;
    transform: rotate(-90deg) scale(0.5);
}

[data-theme="dark"] .icon-sun {
    opacity: 0;
    transform: rotate(90deg) scale(0.5);
}

[data-theme="dark"] .icon-moon {
    opacity: 1;
    transform: rotate(0deg) scale(1);
}

/* Footer / Copyright */
.footer {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 16px 20px;
    text-align: center;
    font-size: 13px;
    color: var(--text-tertiary);
    background: linear-gradient(to top, var(--bg-primary), transparent);
    pointer-events: none;
}

.footer a {
    color: var(--accent);
    text-decoration: none;
    pointer-events: auto;
    font-weight: 500;
}

.footer a:hover {
    text-decoration: underline;
}

/* 404 Page Specific */
.error-page {
    text-align: center;
}

.error-code {
    font-size: 72px;
    font-weight: 800;
    color: var(--text-tertiary);
    opacity: 0.5;
    line-height: 1;
    margin-bottom: 8px;
}

.error-message {
    font-size: 17px;
    color: var(--text-secondary);
    margin-bottom: 28px;
}

/* Success Icon Animation */
.success-icon {
    width: 64px;
    height: 64px;
    background: linear-gradient(135deg, var(--success), #30d158);
    border-radius: var(--radius-full);
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 24px;
    animation: scaleIn 0.4s ease-out;
}

.success-icon svg {
    width: 32px;
    height: 32px;
    fill: #ffffff;
}

@keyframes scaleIn {
    0% {
        transform: scale(0);
        opacity: 0;
    }
    50% {
        transform: scale(1.1);
    }
    100% {
        transform: scale(1);
        opacity: 1;
    }
}

/* Lock Icon */
.lock-icon {
    width: 64px;
    height: 64px;
    background: linear-gradient(135deg, var(--accent), var(--accent-secondary));
    border-radius: var(--radius-full);
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 24px;
}

.lock-icon svg {
    width: 28px;
    height: 28px;
    fill: #ffffff;
}

/* Shake Animation for Errors */
@keyframes shake {
    10%, 90% { transform: translateX(-2px); }
    20%, 80% { transform: translateX(4px); }
    30%, 50%, 70% { transform: translateX(-6px); }
    40%, 60% { transform: translateX(6px); }
}

.shake {
    animation: shake 0.4s cubic-bezier(.36,.07,.19,.97) both;
}

/* Copied State */
.copied {
    background: var(--success) !important;
    color: #ffffff !important;
}

/* Responsive */
@media (max-width: 480px) {
    .main-content {
        padding: 16px;
        padding-bottom: 70px;
        align-items: flex-start;
        padding-top: 60px;
    }
    
    .card {
        padding: 24px 20px;
        border-radius: var(--radius-lg);
    }
    
    .page-title {
        font-size: 24px;
    }
    
    .theme-toggle {
        top: 12px;
        right: 12px;
        width: 42px;
        height: 42px;
    }
    
    .theme-toggle svg {
        width: 20px;
        height: 20px;
    }
    
    .footer {
        padding: 12px 16px;
        font-size: 12px;
    }
}

/* Smooth Loading */
body {
    opacity: 0;
    animation: fadeIn 0.3s ease forwards;
}

@keyframes fadeIn {
    to {
        opacity: 1;
    }
}

/* Focus Visible for Accessibility */
:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

/* Selection Color */
::selection {
    background: var(--accent);
    color: #ffffff;
}

/* Scrollbar Styling */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

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

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

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