/* ======================
   URL SHORTENER STYLES
   ====================== */

/* CSS Variables for consistent theming */
:root {
    /* Primary Colors */
    --primary-color: #3b82f6;
    --primary-light: #60a5fa;
    --primary-dark: #2563eb;
    --primary-gradient: linear-gradient(135deg, #3b82f6 0%, #1d4ed8 100%);
    
    /* Secondary Colors */
    --secondary-color: #10b981;
    --secondary-light: #34d399;
    --secondary-dark: #059669;
    
    /* Accent Colors */
    --accent-color: #f59e0b;
    --danger-color: #ef4444;
    --warning-color: #f97316;
    --success-color: #10b981;
    --info-color: #3b82f6;
    
    /* Neutral Colors */
    --gray-50: #f9fafb;
    --gray-100: #f3f4f6;
    --gray-200: #e5e7eb;
    --gray-300: #d1d5db;
    --gray-400: #9ca3af;
    --gray-500: #6b7280;
    --gray-600: #4b5563;
    --gray-700: #374151;
    --gray-800: #1f2937;
    --gray-900: #111827;
    
    /* Background */
    --bg-primary: #ffffff;
    --bg-secondary: #f8fafc;
    --bg-tertiary: #f1f5f9;
    --bg-gradient: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    
    /* Text Colors */
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --text-tertiary: #94a3b8;
    --text-inverse: #ffffff;
    
    /* Shadows */
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px 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);
    --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
    
    /* Border Radius */
    --radius-sm: 0.375rem;
    --radius-md: 0.5rem;
    --radius-lg: 0.75rem;
    --radius-xl: 1rem;
    --radius-2xl: 1.5rem;
    
    /* Transitions */
    --transition-fast: 0.15s ease-in-out;
    --transition-normal: 0.3s ease-in-out;
    --transition-slow: 0.5s ease-in-out;
    
    /* Z-index */
    --z-dropdown: 1000;
    --z-modal: 1050;
    --z-notification: 1100;
}

/* Dark Mode Support */
@media (prefers-color-scheme: dark) {
    :root {
        --bg-primary: #1e293b;
        --bg-secondary: #0f172a;
        --bg-tertiary: #334155;
        --text-primary: #f1f5f9;
        --text-secondary: #cbd5e1;
        --text-tertiary: #94a3b8;
        --gray-100: #334155;
        --gray-200: #475569;
        --gray-300: #64748b;
    }
}

/* Reset & Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    line-height: 1.6;
    color: var(--text-primary);
    background: var(--bg-secondary);
    font-feature-settings: 'liga' 1, 'kern' 1;
    text-rendering: optimizeLegibility;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* Floating Background Animation */
.tool-page::before {
    content: '';
    position: fixed;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle, rgba(59, 130, 246, 0.03) 0%, transparent 50%),
                radial-gradient(circle, rgba(29, 78, 216, 0.02) 0%, transparent 50%);
    animation: floatingBackground 30s ease-in-out infinite;
    pointer-events: none;
    z-index: -1;
}

@keyframes floatingBackground {
    0%, 100% { transform: rotate(0deg) translate(0, 0); }
    33% { transform: rotate(120deg) translate(40px, -40px); }
    66% { transform: rotate(240deg) translate(-40px, 40px); }
}

/* Main Container */
.tool-page {
    min-height: 100vh;
    position: relative;
}

.shortener-container {
    max-width: 1200px;
    margin: 2rem auto;
    padding: 2.5rem;
    background: var(--bg-primary);
    border-radius: var(--radius-2xl);
    box-shadow: var(--shadow-xl);
    border: 1px solid var(--gray-200);
    backdrop-filter: blur(20px);
    position: relative;
    overflow: hidden;
}

.shortener-container::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: var(--primary-gradient);
    border-radius: var(--radius-2xl) var(--radius-2xl) 0 0;
}

/* Tool Header */
.tool-header {
    text-align: center;
    margin-bottom: 3rem;
    padding-bottom: 2rem;
    border-bottom: 1px solid var(--gray-200);
}

.tool-header h1 {
    font-size: 2.5rem;
    font-weight: 700;
    background: var(--primary-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 1rem;
    letter-spacing: -0.025em;
}

.tool-description {
    color: var(--text-secondary);
    font-size: 1.125rem;
    max-width: 600px;
    margin: 0 auto;
    line-height: 1.7;
}

/* Input Section */
.input-section {
    background: var(--bg-secondary);
    border-radius: var(--radius-xl);
    border: 1px solid var(--gray-200);
    padding: 2rem;
    margin-bottom: 2rem;
}

.section-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
}

.section-title {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text-primary);
}

.input-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.input-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.input-group label {
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.url-input-wrapper {
    position: relative;
}

.url-input {
    width: 100%;
    padding: 1rem 1.25rem 1rem 3rem;
    border: 2px solid var(--gray-200);
    border-radius: var(--radius-lg);
    font-size: 1rem;
    background: var(--bg-primary);
    color: var(--text-primary);
    transition: all var(--transition-fast);
    font-family: 'Fira Code', 'Monaco', 'Cascadia Code', monospace;
}

.url-input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
    transform: translateY(-1px);
}

.url-input::placeholder {
    color: var(--text-tertiary);
    font-family: inherit;
}

.url-icon {
    position: absolute;
    left: 1rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-tertiary);
    font-size: 1rem;
}

.url-input:focus + .url-icon {
    color: var(--primary-color);
}

/* Options Grid */
.options-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1.5rem;
    margin-bottom: 1.5rem;
}

.option-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.select-wrapper {
    position: relative;
}

select {
    width: 100%;
    padding: 0.75rem 1rem;
    border: 2px solid var(--gray-200);
    border-radius: var(--radius-md);
    font-size: 0.875rem;
    background: var(--bg-primary);
    color: var(--text-primary);
    cursor: pointer;
    appearance: none;
    background-image: url('data:image/svg+xml;charset=US-ASCII,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 4 5"><path fill="%23666" d="M2 0L0 2h4zm0 5L0 3h4z"/></svg>');
    background-repeat: no-repeat;
    background-position: right 0.7rem top 50%;
    background-size: 0.65rem auto;
    transition: all var(--transition-fast);
}

select:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.text-input {
    width: 100%;
    padding: 0.75rem 1rem;
    border: 2px solid var(--gray-200);
    border-radius: var(--radius-md);
    font-size: 0.875rem;
    background: var(--bg-primary);
    color: var(--text-primary);
    transition: all var(--transition-fast);
}

.text-input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.date-input {
    width: 100%;
    padding: 0.75rem 1rem;
    border: 2px solid var(--gray-200);
    border-radius: var(--radius-md);
    font-size: 0.875rem;
    background: var(--bg-primary);
    color: var(--text-primary);
    transition: all var(--transition-fast);
}

.date-input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

/* Action Buttons */
.action-buttons {
    display: flex;
    gap: 1rem;
    justify-content: center;
    flex-wrap: wrap;
}

.action-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 1rem 1.5rem;
    border: none;
    border-radius: var(--radius-lg);
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition-fast);
    text-decoration: none;
    white-space: nowrap;
    position: relative;
    overflow: hidden;
}

.action-btn:before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.3), transparent);
    transition: left 0.5s;
}

.action-btn:hover:before {
    left: 100%;
}

.btn-primary {
    background: var(--primary-gradient);
    color: var(--text-inverse);
    box-shadow: var(--shadow-md);
}

.btn-primary:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.btn-secondary {
    background: var(--bg-primary);
    color: var(--text-primary);
    border: 2px solid var(--gray-200);
}

.btn-secondary:hover {
    border-color: var(--primary-color);
    color: var(--primary-color);
    transform: translateY(-1px);
}

.btn-success {
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
    color: var(--text-inverse);
}

.btn-success:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.action-btn:disabled {
    background: var(--gray-300) !important;
    color: var(--gray-500) !important;
    cursor: not-allowed !important;
    transform: none !important;
    box-shadow: none !important;
}

.action-btn:disabled:before {
    display: none;
}

/* Result Section */
.result-section {
    background: var(--bg-secondary);
    border-radius: var(--radius-xl);
    border: 1px solid var(--gray-200);
    padding: 2rem;
    margin-bottom: 2rem;
}

.result-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.5rem;
}

.result-title {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.url-result-container {
    background: var(--bg-primary);
    border: 2px solid var(--success-color);
    border-radius: var(--radius-lg);
    padding: 1rem;
    margin-bottom: 1.5rem;
}

.url-result-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0.75rem;
}

.result-label {
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.url-display {
    display: flex;
    gap: 0.75rem;
    align-items: center;
}

.short-url-input {
    flex: 1;
    padding: 0.875rem 1rem;
    border: 1px solid var(--gray-200);
    border-radius: var(--radius-md);
    font-family: 'Fira Code', 'Monaco', 'Cascadia Code', monospace;
    font-size: 1rem;
    font-weight: 500;
    background: var(--bg-secondary);
    color: var(--text-primary);
    cursor: text;
    user-select: all;
}

.short-url-input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.copy-btn {
    min-width: 100px;
}

/* URL Statistics */
.url-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.stat-card {
    background: var(--bg-primary);
    border: 1px solid var(--gray-200);
    border-radius: var(--radius-lg);
    padding: 1rem;
    text-align: center;
    transition: all var(--transition-fast);
}

.stat-card:hover {
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

.stat-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--primary-color);
    margin-bottom: 0.25rem;
    font-family: 'Fira Code', 'Monaco', 'Cascadia Code', monospace;
}

.stat-label {
    font-size: 0.75rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-weight: 500;
}

.stat-description {
    font-size: 0.75rem;
    color: var(--text-tertiary);
    margin-top: 0.25rem;
}

/* QR Code Section */
.qr-section {
    background: var(--bg-primary);
    border: 1px solid var(--gray-200);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    text-align: center;
    margin-bottom: 1.5rem;
}

.qr-code-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
}

.qr-code {
    max-width: 200px;
    height: auto;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-md);
}

/* Action Buttons for Result */
.result-actions {
    display: flex;
    gap: 0.75rem;
    justify-content: center;
    flex-wrap: wrap;
}

.result-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    padding: 0.5rem 0.875rem;
    border: 1px solid var(--gray-300);
    border-radius: var(--radius-md);
    background: var(--bg-primary);
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.result-btn:hover {
    border-color: var(--primary-color);
    color: var(--primary-color);
    transform: translateY(-1px);
}

.result-btn i {
    font-size: 0.75rem;
}

/* History Section */
.history-section {
    background: var(--bg-secondary);
    border-radius: var(--radius-xl);
    border: 1px solid var(--gray-200);
    padding: 2rem;
    margin-bottom: 2rem;
}

.history-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

.history-title {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.clear-history-btn {
    background: none;
    border: 1px solid var(--gray-300);
    color: var(--text-secondary);
    font-size: 0.75rem;
    padding: 0.375rem 0.75rem;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.clear-history-btn:hover {
    border-color: var(--danger-color);
    color: var(--danger-color);
}

.history-list {
    max-height: 300px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.history-item {
    background: var(--bg-primary);
    border: 1px solid var(--gray-200);
    border-radius: var(--radius-lg);
    padding: 1rem;
    transition: all var(--transition-fast);
}

.history-item:hover {
    border-color: var(--primary-color);
    transform: translateX(2px);
}

.history-item-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 0.5rem;
}

.history-urls {
    flex: 1;
    min-width: 0;
}

.history-original {
    font-size: 0.875rem;
    color: var(--text-secondary);
    word-break: break-all;
    margin-bottom: 0.25rem;
}

.history-short {
    font-size: 1rem;
    font-weight: 500;
    color: var(--primary-color);
    font-family: 'Fira Code', 'Monaco', 'Cascadia Code', monospace;
    word-break: break-all;
}

.history-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.75rem;
    color: var(--text-tertiary);
    margin-top: 0.5rem;
}

.history-time {
    font-weight: 500;
}

.history-actions {
    display: flex;
    gap: 0.5rem;
    margin-left: 1rem;
}

.history-action {
    width: 28px;
    height: 28px;
    border: none;
    border-radius: var(--radius-sm);
    background: var(--gray-100);
    color: var(--text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    transition: all var(--transition-fast);
}

.history-action:hover {
    background: var(--primary-color);
    color: var(--text-inverse);
    transform: scale(1.1);
}

/* Empty States */
.empty-state {
    text-align: center;
    padding: 3rem 1rem;
    color: var(--text-tertiary);
}

.empty-state i {
    font-size: 3rem;
    margin-bottom: 1rem;
    opacity: 0.5;
}

.empty-state h3 {
    font-size: 1.125rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
    color: var(--text-secondary);
}

.empty-state p {
    font-size: 0.875rem;
}

/* Bulk Operations */
.bulk-section {
    background: var(--bg-secondary);
    border-radius: var(--radius-xl);
    border: 1px solid var(--gray-200);
    padding: 2rem;
    margin-bottom: 2rem;
}

.bulk-textarea {
    width: 100%;
    min-height: 120px;
    padding: 1rem;
    border: 2px solid var(--gray-200);
    border-radius: var(--radius-lg);
    font-size: 0.875rem;
    background: var(--bg-primary);
    color: var(--text-primary);
    font-family: 'Fira Code', 'Monaco', 'Cascadia Code', monospace;
    resize: vertical;
    transition: all var(--transition-fast);
}

.bulk-textarea:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.bulk-results {
    max-height: 300px;
    overflow-y: auto;
    background: var(--bg-primary);
    border: 1px solid var(--gray-200);
    border-radius: var(--radius-lg);
    margin-top: 1rem;
}

.bulk-result-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--gray-100);
    font-size: 0.875rem;
}

.bulk-result-item:last-child {
    border-bottom: none;
}

.bulk-original {
    color: var(--text-secondary);
    word-break: break-all;
    margin-right: 1rem;
}

.bulk-short {
    color: var(--primary-color);
    font-family: 'Fira Code', 'Monaco', 'Cascadia Code', monospace;
    font-weight: 500;
    word-break: break-all;
}

/* Notification System */
.notification-container {
    position: fixed;
    top: 2rem;
    right: 2rem;
    z-index: var(--z-notification);
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.notification {
    background: var(--bg-primary);
    border: 1px solid var(--gray-200);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    padding: 1rem 1.5rem;
    min-width: 300px;
    max-width: 400px;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    transform: translateX(100%);
    opacity: 0;
    transition: all var(--transition-normal);
}

.notification.show {
    transform: translateX(0);
    opacity: 1;
}

.notification.success {
    border-left: 4px solid var(--success-color);
}

.notification.error {
    border-left: 4px solid var(--danger-color);
}

.notification.info {
    border-left: 4px solid var(--info-color);
}

/* Responsive Design */
@media (max-width: 1024px) {
    .shortener-container {
        margin: 1rem;
        padding: 1.5rem;
    }
    
    .tool-header h1 {
        font-size: 2rem;
    }
    
    .options-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 768px) {
    .action-buttons {
        flex-direction: column;
    }
    
    .action-btn {
        width: 100%;
        justify-content: center;
    }
    
    .url-display {
        flex-direction: column;
    }
    
    .copy-btn {
        width: 100%;
    }
    
    .url-stats {
        grid-template-columns: 1fr;
    }
    
    .result-actions {
        flex-direction: column;
    }
    
    .history-item-header {
        flex-direction: column;
        gap: 0.5rem;
    }
    
    .history-actions {
        margin-left: 0;
        justify-content: center;
    }
}

@media (max-width: 480px) {
    .shortener-container {
        margin: 0.5rem;
        padding: 1rem;
    }
    
    .tool-header h1 {
        font-size: 1.75rem;
    }
    
    .input-section,
    .result-section,
    .history-section,
    .bulk-section {
        padding: 1rem;
    }
}

/* Print Styles */
@media print {
    .tool-page::before,
    .action-buttons,
    .result-actions,
    .history-actions {
        display: none !important;
    }
    
    .shortener-container {
        box-shadow: none;
        border: 1px solid #000;
        margin: 0;
        padding: 1rem;
    }
    
    .tool-header h1 {
        color: #000;
        -webkit-text-fill-color: initial;
    }
}

/* Accessibility */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
    
    .tool-page::before {
        animation: none;
    }
}

/* Focus Styles for Keyboard Navigation */
.action-btn:focus,
.result-btn:focus,
.history-action:focus {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
}

/* High Contrast Mode */
@media (prefers-contrast: high) {
    :root {
        --primary-color: #0000ff;
        --danger-color: #ff0000;
        --success-color: #008000;
        --text-primary: #000000;
        --bg-primary: #ffffff;
    }
    
    .url-result-container,
    .stat-card,
    .history-item {
        border: 2px solid #000;
    }
    
    .action-btn {
        border: 2px solid currentColor;
    }
}
