/* Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary-color: #4F46E5;
    --primary-hover: #4338CA;
    --secondary-color: #6B7280;
    --success-color: #10B981;
    --error-color: #EF4444;
    --bg-color: #F9FAFB;
    --card-bg: #FFFFFF;
    --text-primary: #111827;
    --text-secondary: #6B7280;
    --border-color: #E5E7EB;
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    line-height: 1.6;
    color: var(--text-primary);
    background-color: var(--bg-color);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Skip Link for Accessibility */
.skip-link {
    position: absolute;
    top: -40px;
    left: 0;
    background: var(--primary-color);
    color: white;
    padding: 8px 16px;
    text-decoration: none;
    z-index: 100;
}

.skip-link:focus {
    top: 0;
}

/* Header */
header {
    background: linear-gradient(135deg, var(--primary-color) 0%, #6366F1 100%);
    color: white;
    padding: 2rem 1rem;
    text-align: center;
    box-shadow: var(--shadow-lg);
}

header h1 {
    font-size: 2.5rem;
    margin-bottom: 0.5rem;
    font-weight: 700;
}

.subtitle {
    font-size: 1.1rem;
    opacity: 0.95;
    margin-bottom: 1.5rem;
}

header nav {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 1rem;
    margin-top: 1.5rem;
}

header nav a {
    color: white;
    text-decoration: none;
    padding: 0.5rem 1rem;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 6px;
    transition: background 0.3s;
    font-size: 0.9rem;
}

header nav a:hover,
header nav a:focus {
    background: rgba(255, 255, 255, 0.3);
    outline: 2px solid white;
    outline-offset: 2px;
}

/* Container Layout */
.container {
    display: grid;
    grid-template-columns: 1fr;
    gap: 2rem;
    max-width: 1400px;
    margin: 2rem auto;
    padding: 0 1rem;
    flex: 1;
}

@media (min-width: 1024px) {
    .container {
        grid-template-columns: 300px 1fr;
    }
}

/* Main Content */
main {
    display: flex;
    flex-direction: column;
    gap: 2rem;
}

/* Tool Sections */
.tool-section {
    background: var(--card-bg);
    border-radius: 12px;
    padding: 2rem;
    box-shadow: var(--shadow);
    border: 1px solid var(--border-color);
    scroll-margin-top: 2rem;
}

.tool-section h2 {
    color: var(--primary-color);
    font-size: 1.8rem;
    margin-bottom: 0.5rem;
}

.tool-description {
    color: var(--text-secondary);
    margin-bottom: 1.5rem;
    font-size: 1rem;
}

/* Tool Interface */
.tool-interface {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.input-group,
.output-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

label {
    font-weight: 600;
    color: var(--text-primary);
    font-size: 0.95rem;
}

textarea {
    width: 100%;
    padding: 0.75rem;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    font-family: 'Courier New', monospace;
    font-size: 0.95rem;
    resize: vertical;
    transition: border-color 0.3s;
}

textarea:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

.input-textarea {
    background-color: #FAFAFA;
}

.output-textarea {
    background-color: #F3F4F6;
    cursor: default;
}

.char-count {
    font-size: 0.85rem;
    color: var(--text-secondary);
    text-align: right;
}

/* Buttons */
.button-group {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
}

.btn {
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.btn:focus {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
}

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

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

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

.btn-secondary:hover {
    background-color: #4B5563;
    transform: translateY(-1px);
}

.btn-copy {
    background-color: var(--success-color);
    color: white;
    align-self: flex-start;
}

.btn-copy:hover {
    background-color: #059669;
    transform: translateY(-1px);
}

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

/* Tool Info */
.tool-info {
    margin-top: 2rem;
    padding-top: 2rem;
    border-top: 1px solid var(--border-color);
}

.tool-info h3 {
    color: var(--text-primary);
    font-size: 1.2rem;
    margin-bottom: 0.75rem;
}

.tool-info p {
    color: var(--text-secondary);
    margin-bottom: 0.75rem;
    line-height: 1.7;
}

/* Ad Containers */
.ad-container {
    background-color: #F9FAFB;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 1rem;
    text-align: center;
    margin: 1.5rem 0;
}

.ad-placeholder {
    color: var(--text-secondary);
    font-size: 0.85rem;
    padding: 2rem;
    background: repeating-linear-gradient(
        45deg,
        transparent,
        transparent 10px,
        rgba(0, 0, 0, 0.02) 10px,
        rgba(0, 0, 0, 0.02) 20px
    );
}

.ad-header {
    max-width: 728px;
    margin: 1rem auto;
}

.ad-sidebar {
    position: sticky;
    top: 1rem;
}

.ad-content {
    max-width: 100%;
}

.ad-footer {
    max-width: 728px;
    margin: 2rem auto;
}

/* Sidebar */
.sidebar-ad {
    display: none;
}

@media (min-width: 1024px) {
    .sidebar-ad {
        display: block;
    }
}

/* Footer */
footer {
    background-color: var(--text-primary);
    color: white;
    padding: 2rem 1rem;
    margin-top: 3rem;
}

.footer-content {
    max-width: 1400px;
    margin: 0 auto;
    text-align: center;
}

.footer-nav {
    display: flex;
    justify-content: center;
    gap: 2rem;
    margin: 1rem 0;
    flex-wrap: wrap;
}

.footer-nav a {
    color: white;
    text-decoration: none;
    transition: opacity 0.3s;
}

.footer-nav a:hover,
.footer-nav a:focus {
    opacity: 0.8;
    text-decoration: underline;
}

.footer-note {
    font-size: 0.9rem;
    opacity: 0.8;
    margin-top: 1rem;
}

/* Responsive Design */
@media (max-width: 768px) {
    header h1 {
        font-size: 1.8rem;
    }

    .subtitle {
        font-size: 1rem;
    }

    header nav {
        gap: 0.5rem;
    }

    header nav a {
        font-size: 0.85rem;
        padding: 0.4rem 0.8rem;
    }

    .tool-section {
        padding: 1.5rem;
    }

    .tool-section h2 {
        font-size: 1.5rem;
    }

    .button-group {
        flex-direction: column;
    }

    .btn {
        width: 100%;
    }
}

/* Print Styles */
@media print {
    .ad-container,
    header nav,
    .btn,
    footer {
        display: none;
    }

    .tool-section {
        page-break-inside: avoid;
    }
}

/* Screen Reader Only */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border-width: 0;
}

/* Focus Visible for Keyboard Navigation */
*:focus-visible {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
}

/* Error State */
.error {
    border-color: var(--error-color) !important;
}

.error-message {
    color: var(--error-color);
    font-size: 0.9rem;
    margin-top: 0.5rem;
}

/* Success State */
.success {
    border-color: var(--success-color) !important;
}

/* Loading State */
.loading {
    opacity: 0.6;
    pointer-events: none;
}
