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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    line-height: 1.5;
    color: #333;
    background-color: #f8f9fa;
    height: 100vh; /* Fixed height for single screen layout */
    overflow: hidden; /* Prevent body scroll */
}

/* Container Layout */
.container {
    max-width: 1400px; /* Increased max-width for side-by-side layout */
    margin: 0 auto;
    padding: 15px 20px; /* Reduced padding */
    height: 100%;
    display: flex;
    flex-direction: column;
}

/* Header Styles */
header {
    text-align: center;
    margin-bottom: 15px; /* Reduced margin */
    padding: 10px 0; /* Reduced padding */
    flex-shrink: 0;
}

header h1 {
    font-size: 1.8rem; /* Smaller font */
    font-weight: 700;
    color: #2c3e50;
    margin-bottom: 5px;
}

.subtitle {
    font-size: 0.95rem;
    color: #7f8c8d;
}

/* Main Content Layout */
main {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0; /* Critical for flex child scrolling */
    gap: 15px;
}

/* Panels Row (Side by Side) */
.panels-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    flex: 1;
    min-height: 0; /* Critical for grid item scrolling */
}

/* Text Panel */
.text-panel {
    background: white;
    border-radius: 12px;
    padding: 20px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    border: 1px solid #e1e8ed;
    display: flex;
    flex-direction: column;
    min-height: 0; /* Critical for flex child scrolling */
}

.panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
    flex-shrink: 0;
}

label {
    font-weight: 600;
    color: #2c3e50;
    font-size: 1rem;
}

.char-count, .result-stats {
    font-size: 0.85rem;
    color: #7f8c8d;
}

.separator {
    margin: 0 5px;
}

/* Textareas */
textarea {
    width: 100%;
    flex: 1; /* Fill remaining vertical space */
    padding: 12px 16px;
    border: 2px solid #e1e8ed;
    border-radius: 8px;
    font-size: 1rem;
    font-family: inherit;
    transition: border-color 0.3s ease, box-shadow 0.3s ease;
    background-color: #ffffff;
    resize: none; /* Disable manual resize */
    min-height: 100px;
}

textarea:focus, input[type="text"]:focus {
    outline: none;
    border-color: #3498db;
    box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.1);
}

#result-text {
    background-color: #f8f9fa;
}

.result-actions {
    margin-top: 10px;
    display: flex;
    justify-content: flex-end;
    flex-shrink: 0;
}

/* Controls Panel */
.controls-panel {
    background: white;
    border-radius: 12px;
    padding: 15px 20px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    border: 1px solid #e1e8ed;
    display: flex;
    gap: 20px;
    align-items: flex-start;
    flex-shrink: 0;
}

.filter-group {
    flex: 1;
}

.filter-input-wrapper {
    display: flex;
    flex-direction: column;
}

input[type="text"] {
    width: 100%;
    padding: 10px 14px;
    border: 2px solid #e1e8ed;
    border-radius: 8px;
    font-size: 1rem;
}

.help-text {
    font-size: 0.8rem;
    color: #7f8c8d;
    margin-top: 4px;
}

/* Button Group */
.button-group {
    display: flex;
    gap: 10px;
    margin-top: 29px; /* Align with input box (label height approx) */
}

/* Button Styles */
button {
    padding: 10px 20px;
    border: none;
    border-radius: 8px;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-family: inherit;
    white-space: nowrap;
}

button:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.primary-btn {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.primary-btn:hover:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

.secondary-btn {
    background: #e74c3c;
    color: white;
}

.secondary-btn:hover:not(:disabled) {
    background: #c0392b;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(231, 76, 60, 0.4);
}

.copy-btn {
    background: #27ae60;
    color: white;
}

.copy-btn:hover:not(:disabled) {
    background: #219a52;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(39, 174, 96, 0.4);
}

/* Toast Notification */
.toast {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    background: #27ae60;
    color: white;
    padding: 10px 20px;
    border-radius: 50px;
    font-weight: 600;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
    opacity: 0;
    transition: all 0.3s ease;
    z-index: 1000;
    pointer-events: none;
    font-size: 0.9rem;
}

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

/* Footer */
footer {
    text-align: center;
    padding: 10px 0;
    color: #7f8c8d;
    font-size: 0.8rem;
    flex-shrink: 0;
}

/* Responsive Design */
@media (max-width: 900px) {
    body {
        height: auto;
        overflow: auto;
    }
    
    .container {
        height: auto;
        padding: 15px;
    }

    .panels-row {
        grid-template-columns: 1fr;
        flex: none;
    }

    .text-panel {
        height: 300px; /* Fixed height on mobile */
    }

    .controls-panel {
        flex-direction: column;
        gap: 15px;
    }
    
    .button-group {
        margin-top: 0;
        width: 100%;
    }
    
    button {
        flex: 1;
        justify-content: center;
    }
}
