* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --bg-primary: #ffffff;
    --bg-secondary: #f8fafc;
    --bg-tertiary: #edf5ff;
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --accent-primary: #0f4ba5;
    --accent-hover: #1177bb;
    --accent-danger: #c75450;
    --accent-danger-hover: #d96965;
    --accent-success: #4ec9b0;
    --border-color: #e2e8f0;
    --input-bg: #3c3c3c;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    background-color: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    line-height: 1.6;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 20px;
}

header {
    text-align: center;
    margin-bottom: 30px;
    padding: 20px 0;
}

header h1 {
    font-size: 2.5rem;
    font-weight: 300;
    margin-bottom: 8px;
    background: linear-gradient(135deg, var(--accent-primary), var(--accent-success));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.subtitle {
    color: var(--text-secondary);
    font-size: 1.1rem;
}

.toolbar {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
    padding: 15px;
    background: var(--bg-secondary);
    border-radius: 8px;
    border: 1px solid var(--border-color);
    align-items: center;
}

.spacer {
    flex: 1;
}

.btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 20px;
    border: none;
    border-radius: 6px;
    font-size: 0.95rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
    position: relative;
    overflow: hidden;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}

.btn-text {
    display: inline;
}

@media (max-width: 480px) {
    .btn-text {
        display: none;
    }
    
    .btn {
        padding: 12px;
        justify-content: center;
        min-width: 48px;
        min-height: 48px;
    }
}

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

.btn-primary:hover {
    background-color: var(--accent-hover);
    transform: translateY(-1px);
}

.btn-secondary {
    background-color: var(--bg-tertiary);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}

.btn-secondary:hover {
    background-color: var(--bg-primary);
    border-color: var(--accent-primary);
}

.btn-danger {
    background-color: transparent;
    color: var(--accent-danger);
    border: 1px solid var(--accent-danger);
}

.btn-danger:hover {
    background-color: var(--accent-danger);
    color: white;
}

.btn-sm {
    padding: 6px 12px;
    font-size: 0.85rem;
}

.icon {
    width: 16px;
    height: 16px;
}

.content-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    height: calc(100vh - 280px);
    min-height: 400px;
}

.panel {
    background-color: var(--bg-secondary);
    border-radius: 12px;
    border: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 20px;
    border-bottom: 1px solid var(--border-color);
    background: var(--bg-tertiary);
}

.panel-header h2 {
    font-size: 1.1rem;
    font-weight: 500;
    color: var(--text-primary);
}

.url-count {
    font-size: 0.85rem;
    color: var(--text-secondary);
    background: var(--bg-primary);
    padding: 4px 12px;
    border-radius: 12px;
}

.preview-actions {
    display: flex;
    gap: 8px;
}

.panel-content {
    flex: 1;
    overflow: auto;
    position: relative;
}

.urls-list {
    padding: 10px;
}

.url-item {
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 15px;
    margin-bottom: 10px;
    transition: all 0.2s;
}

.url-item:hover {
    border-color: var(--accent-primary);
}

.url-header {
    display: flex;
    gap: 10px;
    margin-bottom: 12px;
}

.url-input {
    flex: 1;
    padding: 8px 12px;
    background: var(--input-bg);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    color: var(--text-primary);
    font-size: 0.95rem;
    outline: none;
    touch-action: manipulation;
    -webkit-appearance: none;
    appearance: none;
}

.url-input:focus {
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 2px rgba(0, 122, 204, 0.2);
}

.url-input:focus {
    border-color: var(--accent-primary);
}

.url-input::placeholder {
    color: var(--text-secondary);
}

.url-options {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr auto;
    gap: 10px;
    align-items: center;
}

.option-group {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.option-label {
    font-size: 0.75rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.option-select,
.option-input {
    padding: 6px 10px;
    background: var(--input-bg);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    color: var(--text-primary);
    font-size: 0.9rem;
    outline: none;
    width: 100%;
}

.option-select:focus,
.option-input:focus {
    border-color: var(--accent-primary);
}

.remove-btn {
    padding: 8px;
    background: transparent;
    border: 1px solid var(--accent-danger);
    border-radius: 4px;
    color: var(--accent-danger);
    cursor: pointer;
    font-size: 18px;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 36px;
    height: 36px;
    align-self: flex-end;
}

.remove-btn:hover {
    background: var(--accent-danger);
    color: white;
}

.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: var(--text-secondary);
    text-align: center;
    padding: 40px;
}

.empty-icon {
    width: 64px;
    height: 64px;
    margin-bottom: 20px;
    opacity: 0.5;
}

.empty-state p {
    margin-bottom: 20px;
    font-size: 1.1rem;
}

.xml-preview {
    height: 100%;
    margin: 0;
    padding: 20px;
    background: var(--bg-primary);
    color: #d4d4d4;
    font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
    font-size: 13px;
    line-height: 1.6;
    overflow: auto;
    white-space: pre-wrap;
    word-wrap: break-word;
}

/* Modal Styles */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    z-index: 1000;
    align-items: center;
    justify-content: center;
}

.modal.show {
    display: flex;
}

.modal-content {
    background: var(--bg-secondary);
    border-radius: 12px;
    border: 1px solid var(--border-color);
    width: 90%;
    max-width: 600px;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px;
    border-bottom: 1px solid var(--border-color);
}

.modal-header h3 {
    font-size: 1.2rem;
    font-weight: 500;
}

.modal-close {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    font-size: 24px;
    cursor: pointer;
    padding: 0;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
}

.modal-close:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.modal-body {
    padding: 20px;
    flex: 1;
    overflow: auto;
}

.modal-body p {
    margin-bottom: 15px;
    color: var(--text-secondary);
}

.import-textarea {
    width: 100%;
    min-height: 200px;
    padding: 12px;
    background: var(--input-bg);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    color: var(--text-primary);
    font-family: 'Consolas', 'Monaco', monospace;
    font-size: 14px;
    resize: vertical;
    outline: none;
}

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

.import-options {
    margin-top: 15px;
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    color: var(--text-primary);
}

.checkbox-label input[type="checkbox"] {
    width: 18px;
    height: 18px;
    accent-color: var(--accent-primary);
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    padding: 20px;
    border-top: 1px solid var(--border-color);
}

footer {
    text-align: center;
    padding: 30px 0;
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin-top: 20px;
}

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

::-webkit-scrollbar-track {
    background: var(--bg-primary);
}

::-webkit-scrollbar-thumb {
    background: var(--bg-tertiary);
    border-radius: 5px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--border-color);
}

/* Touch Improvements */
@media (hover: none) and (pointer: coarse) {
    .btn:hover {
        transform: none;
        background-color: inherit;
    }
    
    .btn:active {
        transform: scale(0.95);
    }
    
    .url-item:hover {
        border-color: inherit;
    }
    
    .url-item:active {
        transform: scale(0.98);
    }
    
    .remove-btn:hover {
        background: transparent;
        color: inherit;
    }
    
    .remove-btn:active {
        background: var(--accent-danger);
        color: white;
    }
}

/* Focus Improvements */
.btn:focus-visible,
.option-select:focus,
.option-input:focus,
.url-input:focus,
.exclude-textarea:focus,
.import-textarea:focus {
    outline: 2px solid var(--accent-primary);
    outline-offset: 2px;
}

/* High Contrast Mode Support */
@media (prefers-contrast: high) {
    :root {
        --border-color: #666666;
        --text-secondary: #bbbbbb;
    }
    
    .btn {
        border: 2px solid;
    }
    
    .url-input,
    .option-select,
    .option-input {
        border-width: 2px;
    }
}

/* Reduced Motion Support */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* Toast Notification */
.toast {
    position: fixed;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    background: var(--accent-success);
    color: var(--bg-primary);
    padding: 12px 24px;
    border-radius: 8px;
    font-weight: 500;
    opacity: 0;
    transition: all 0.3s;
    z-index: 2000;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    max-width: 90%;
    text-align: center;
    word-wrap: break-word;
}

.toast.show {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
}

/* Crawl Options Styles */
.crawl-options {
    margin-top: 15px;
    padding: 15px;
    background: var(--bg-tertiary);
    border-radius: 8px;
    border: 1px solid var(--border-color);
}

.options-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 15px;
    margin-bottom: 15px;
}

.option-item {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.crawl-filters {
    margin-top: 15px;
}

.exclude-textarea {
    width: 100%;
    min-height: 100px;
    padding: 10px;
    background: var(--input-bg);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    color: var(--text-primary);
    font-family: 'Consolas', 'Monaco', monospace;
    font-size: 12px;
    resize: vertical;
    outline: none;
}

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

/* Crawl Progress Styles */
.crawl-progress {
    margin-top: 15px;
    padding: 15px;
    background: var(--bg-tertiary);
    border-radius: 8px;
    border: 1px solid var(--border-color);
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% { border-color: var(--border-color); }
    50% { border-color: var(--accent-primary); }
}

.progress-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    font-weight: 500;
    color: var(--accent-primary);
}

.progress-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 10px;
    margin-bottom: 15px;
}

.stat-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 8px;
    background: var(--bg-primary);
    border-radius: 6px;
    border: 1px solid var(--border-color);
}

.stat-label {
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin-bottom: 2px;
}

.stat-value {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-primary);
}

.progress-bar {
    width: 100%;
    height: 8px;
    background: var(--bg-primary);
    border-radius: 4px;
    overflow: hidden;
    margin-bottom: 15px;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--accent-primary), var(--accent-success));
    transition: width 0.3s ease;
    border-radius: 4px;
}

.recent-urls {
    max-height: 150px;
    overflow-y: auto;
}

.recent-title {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-bottom: 8px;
    font-weight: 500;
}

.recent-list {
    font-size: 0.8rem;
    font-family: 'Consolas', 'Monaco', monospace;
}

.recent-item {
    padding: 4px 8px;
    margin-bottom: 2px;
    background: var(--bg-primary);
    border-radius: 4px;
    border-left: 3px solid var(--accent-success);
    color: var(--text-primary);
    word-break: break-all;
    animation: slideIn 0.3s ease;
}

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

.crawl-progress.minimized {
    padding: 8px;
}

.crawl-progress.minimized .progress-stats,
.crawl-progress.minimized .recent-urls {
    display: none;
}

/* Crawl Section Responsive */
.crawl-controls {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
}

@media (max-width: 768px) {
    .crawl-controls {
        flex-direction: column;
        align-items: stretch;
    }
    
    .crawl-controls .url-input {
        width: 100%;
    }
    
    .crawl-controls .btn {
        width: 100%;
        justify-content: center;
    }
}

/* Options Grid Responsive */
.options-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 15px;
    margin-bottom: 15px;
}

@media (max-width: 768px) {
    .options-grid {
        grid-template-columns: 1fr;
        gap: 10px;
    }
}

@media (max-width: 480px) {
    .option-item {
        gap: 8px;
    }
    
    .exclude-textarea {
        min-height: 80px;
        font-size: 11px;
    }
}

/* Progress Stats Responsive */
.progress-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 10px;
    margin-bottom: 15px;
}

@media (max-width: 768px) {
    .progress-stats {
        grid-template-columns: repeat(2, 1fr);
        gap: 8px;
    }
}

@media (max-width: 480px) {
    .progress-stats {
        grid-template-columns: 1fr;
        gap: 6px;
    }
    
    .stat-item {
        padding: 6px;
    }
    
    .stat-label {
        font-size: 0.7rem;
    }
    
    .stat-value {
        font-size: 0.9rem;
    }
}

/* Recent URLs Responsive */
.recent-item {
    font-size: 0.8rem;
    word-break: break-all;
}

@media (max-width: 480px) {
    .recent-item {
        font-size: 0.7rem;
        padding: 3px 6px;
    }
}

/* Responsive */
@media (max-width: 1200px) {
    .container {
        padding: 15px;
    }
    
    .content-grid {
        height: calc(100vh - 300px);
    }
}

@media (max-width: 1024px) {
    .content-grid {
        grid-template-columns: 1fr;
        grid-template-rows: 1fr 1fr;
        height: calc(100vh - 320px);
        min-height: 600px;
    }
    
    .panel {
        min-height: 280px;
    }
}

@media (max-width: 768px) {
    .container {
        padding: 10px;
    }
    
    header h1 {
        font-size: 1.8rem;
        margin-bottom: 6px;
    }
    
    .subtitle {
        font-size: 1rem;
    }
    
    .toolbar {
        flex-wrap: wrap;
        gap: 8px;
        padding: 12px;
    }
    
    .btn {
        padding: 8px 16px;
        font-size: 0.9rem;
    }
    
    .btn-sm {
        padding: 5px 10px;
        font-size: 0.8rem;
    }
    
    .crawl-section {
        margin-bottom: 20px;
    }
    
    .crawl-options {
        padding: 12px;
    }
    
    .crawl-progress {
        padding: 12px;
    }
    
    .progress-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }
    
    .progress-header button {
        align-self: flex-end;
    }
    
    .url-options {
        grid-template-columns: 1fr 1fr;
        gap: 8px;
    }
    
    .url-header {
        flex-direction: column;
        gap: 8px;
    }
    
    .option-group {
        gap: 3px;
    }
    
    .option-label {
        font-size: 0.7rem;
    }
    
    .option-select,
    .option-input {
        font-size: 0.85rem;
        padding: 5px 8px;
    }
}

@media (max-width: 480px) {
    header {
        padding: 15px 0;
        margin-bottom: 20px;
    }
    
    header h1 {
        font-size: 1.5rem;
    }
    
    .subtitle {
        font-size: 0.9rem;
    }
    
    .toolbar {
        padding: 10px;
        gap: 6px;
    }
    
    .toolbar .btn {
        flex: 1;
        min-width: 0;
        padding: 10px 8px;
        font-size: 0.8rem;
        justify-content: center;
    }
    
    .toolbar .btn .icon {
        width: 14px;
        height: 14px;
    }
    
    .crawl-controls {
        gap: 8px;
    }
    
    .crawl-controls .url-input {
        padding: 10px;
        font-size: 0.9rem;
    }
    
    .crawl-options {
        padding: 10px;
    }
    
    .crawl-progress {
        padding: 10px;
    }
    
    .progress-bar {
        height: 6px;
    }
    
    .recent-urls {
        max-height: 120px;
    }
    
    .content-grid {
        gap: 15px;
        height: calc(100vh - 280px);
        min-height: 500px;
    }
    
    .panel {
        border-radius: 8px;
    }
    
    .panel-header {
        padding: 12px 15px;
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }
    
    .panel-header h2 {
        font-size: 1rem;
    }
    
    .url-count {
        align-self: flex-end;
        font-size: 0.8rem;
        padding: 3px 8px;
    }
    
    .preview-actions {
        width: 100%;
        justify-content: flex-end;
    }
    
    .panel-content {
        padding: 5px;
    }
    
    .urls-list {
        padding: 5px;
    }
    
    .url-item {
        padding: 12px;
        margin-bottom: 8px;
    }
    
    .url-options {
        grid-template-columns: 1fr;
        gap: 6px;
    }
    
    .option-group {
        gap: 2px;
    }
    
    .option-label {
        font-size: 0.65rem;
    }
    
    .option-select,
    .option-input {
        padding: 8px;
        font-size: 0.85rem;
    }
    
    .remove-btn {
        width: 100%;
        margin-top: 8px;
        height: 32px;
        font-size: 16px;
    }
    
    .xml-preview {
        padding: 15px;
        font-size: 11px;
        line-height: 1.5;
    }
    
    .empty-state {
        padding: 20px;
    }
    
    .empty-icon {
        width: 48px;
        height: 48px;
        margin-bottom: 15px;
    }
    
    .empty-state p {
        font-size: 1rem;
        margin-bottom: 15px;
    }
    
    .empty-state .btn {
        padding: 8px 16px;
    }
    
    /* Modal Responsive */
    .modal-content {
        width: 95%;
        max-height: 90vh;
    }
    
    .modal-header {
        padding: 15px;
    }
    
    .modal-header h3 {
        font-size: 1.1rem;
    }
    
    .modal-body {
        padding: 15px;
    }
    
    .import-textarea {
        min-height: 150px;
        padding: 10px;
        font-size: 13px;
    }
    
    .modal-footer {
        padding: 15px;
        gap: 8px;
    }
    
    .modal-footer .btn {
        flex: 1;
        padding: 8px 12px;
    }
    
    /* Toast Responsive */
    .toast {
        bottom: 20px;
        left: 50%;
        right: 20px;
        transform: translateX(-50%) translateY(100px);
        padding: 10px 16px;
        font-size: 0.9rem;
        border-radius: 6px;
        max-width: calc(100% - 40px);
    }
    
    @media (max-width: 320px) {
        .toast {
            font-size: 0.8rem;
            padding: 8px 12px;
            bottom: 15px;
        }
    }
}

/* Landscape Mobile */
@media (max-width: 768px) and (orientation: landscape) {
    .content-grid {
        grid-template-columns: 1fr;
        grid-template-rows: 1fr 1fr;
        height: calc(100vh - 240px);
    }
    
    .crawl-options,
    .crawl-progress {
        padding: 8px;
    }
    
    .progress-stats {
        grid-template-columns: repeat(4, 1fr);
    }
    
    .recent-urls {
        max-height: 80px;
    }
}

/* Small Tablets */
@media (min-width: 481px) and (max-width: 768px) {
    .toolbar {
        justify-content: center;
    }
    
    .toolbar .btn {
        flex: 0 0 auto;
    }
    
    .crawl-controls {
        flex-direction: row;
        flex-wrap: wrap;
    }
    
    .crawl-controls .url-input {
        flex: 1;
        min-width: 200px;
    }
    
    .crawl-controls .btn {
        flex: 0 0 auto;
    }
}

/* Print Styles */
@media print {
    .crawl-section,
    .toolbar,
    .panel-header {
        display: none;
    }
    
    .content-grid {
        grid-template-columns: 1fr;
        height: auto;
    }
    
    .preview-panel {
        display: none;
    }
    
    .xml-preview {
        display: block;
        background: white;
        color: black;
        border: 1px solid #ccc;
    }
}
