/* General Reset and Base Styles */
body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol";
    line-height: 1.6;
    margin: 0;
    padding: 10px; /* Add some padding for small screens */
    background-color: #f4f4f4;
    color: #333;
    font-size: 16px; /* Base font size */
}

.container {
    max-width: 700px;
    margin: 10px auto; /* Reduced margin for smaller screens */
    background: #fff;
    padding: 15px; /* Reduced padding for smaller screens */
    border-radius: 8px;
    box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
}

h1 {
    font-size: 1.8em; /* Relative font size */
    text-align: center;
    color: #333;
    margin-bottom: 0.8em;
}

h2 {
    font-size: 1.4em; /* Relative font size */
    text-align: center;
    color: #333;
    margin-top: 1.2em;
    margin-bottom: 0.6em;
}

/* Controls Area */
.controls {
    display: flex;
    flex-direction: column; /* Stack vertically on small screens by default */
    align-items: stretch;  /* Make items take full width */
    gap: 10px;
    margin-bottom: 20px;
}

.controls span {
    text-align: center;
    font-style: italic;
    margin: 5px 0;
}

button,
input[type="file"] {
    padding: 12px 15px; /* Slightly larger padding for easier tapping */
    border-radius: 5px;
    font-size: 1em; /* Relative font size */
    box-sizing: border-box; /* Include padding and border in the element's total width and height */
    width: 100%; /* Full width for stacked items */
}

button {
    background-color: #007bff;
    color: white;
    border: none;
    cursor: pointer;
    transition: background-color 0.3s ease;
}

button:hover:not(:disabled) {
    background-color: #0056b3;
}

button:disabled {
    background-color: #cccccc;
    cursor: not-allowed;
}

input[type="file"] {
    border: 1px solid #ddd;
    background-color: #fff; /* Ensure consistent background */
}
/* Specific style for file input button text if needed */
input[type="file"]::file-selector-button {
    background-color: #6c757d;
    color: white;
    border: none;
    padding: 10px 12px;
    border-radius: 4px;
    cursor: pointer;
    margin-right: 10px;
}
input[type="file"]::file-selector-button:hover {
    background-color: #5a6268;
}


/* Preview Area */
.preview-area {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin-bottom: 20px;
    border: 1px dashed #ccc;
    padding: 10px;
    min-height: 150px; /* Adjusted min-height */
    background-color: #f9f9f9;
}

#videoPreview, #imagePreview {
    max-width: 100%;
    height: auto; /* Maintain aspect ratio */
    max-height: 300px; /* Max height for preview on mobile */
    border: 1px solid #ddd;
    border-radius: 4px;
    object-fit: contain; /* Ensure the whole image/video is visible */
}

#videoPreview {
    display: none;
}
#imagePreview {
    display: none;
}

/* Status Area */
.status-area {
    text-align: center;
    margin-bottom: 15px;
    font-style: italic;
    color: #555;
    padding: 5px;
}

#statusMessage.error {
    color: red;
    font-weight: bold;
}
#statusMessage.success {
    color: green;
    font-weight: bold;
}

/* Result Area */
.result-area {
    margin-top: 20px;
    border-top: 1px solid #eee;
    padding-top: 15px;
}

#extractedTextOutput {
    background-color: #e9ecef;
    padding: 10px; /* Adjusted padding */
    border-radius: 5px;
    white-space: pre-wrap;
    word-wrap: break-word;
    min-height: 50px;
    border: 1px solid #ced4da;
    font-size: 0.9em; /* Slightly smaller for more text visibility */
    overflow-x: auto; /* Allow horizontal scroll if text is too wide */
}

/* --- Media Queries for Larger Screens --- */

/* For tablets and small desktops (e.g., > 600px) */
@media (min-width: 600px) {
    body {
        padding: 20px; /* Restore original padding */
    }

    .container {
        padding: 20px; /* Restore original padding */
        margin: 20px auto;
    }

    h1 {
        font-size: 2em;
    }
    h2 {
        font-size: 1.5em;
    }

    .controls {
        flex-direction: row; /* Horizontal layout for controls */
        justify-content: center;
        align-items: center;
    }

    button,
    input[type="file"] {
        width: auto; /* Allow buttons to size based on content */
    }

    #videoPreview, #imagePreview {
        max-height: 400px; /* Allow larger preview on bigger screens */
    }

    #extractedTextOutput {
        font-size: 1em; /* Restore base font size */
        padding: 15px;
    }
}