/* css/document-creator.css */

/* Ensure the body takes full height for proper footer positioning */
html, body {
    height: 100%;
}

body {
    display: flex;
    flex-direction: column;
}

main {
    flex-grow: 1; /* Allows main content to take available space */
}

/* Base styles for the main container and header/footer are in inline <style> */

/* Toolbar styles */
.toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem; /* Smaller gap for compact buttons */
    padding: 0.75rem;
    background-color: #f0f4f8;
    border-bottom: 1px solid #e2e8f0;
    border-top-left-radius: 0.5rem;
    border-top-right-radius: 0.5rem;
    margin-bottom: 0.5rem;
    align-items: center;
}
.toolbar button,
.toolbar select {
    background-color: #ffffff;
    border: 1px solid #cbd5e0;
    padding: 0.4rem 0.6rem;
    border-radius: 0.375rem;
    font-size: 0.875rem;
    color: #4a5568;
    cursor: pointer;
    transition: all 0.2s ease-in-out;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
    min-width: 30px;
    min-height: 30px;
}
.toolbar button:hover,
.toolbar select:hover {
    background-color: #e2e8f0;
    border-color: #a0aec0;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}
.toolbar button:active,
.toolbar button.active {
    background-color: #3b82f6;
    color: white;
    border-color: #3b82f6;
    box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.2);
}
.toolbar button svg {
    width: 1rem;
    height: 1rem;
    fill: currentColor;
}

/* Custom styling for the select dropdowns in the toolbar */
.toolbar select {
    appearance: none; /* Remove default select arrow */
    -webkit-appearance: none;
    -moz-appearance: none;
    background-image: url('data:image/svg+xml;utf8,<svg fill="currentColor" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path fill-rule="evenodd" d="M5.293 7.293a1 1 0 011.414 0L10 10.586l3.293-3.293a1 1 0 111.414 1.414l-4 4a1 1 0 01-1.414 0l-4-4a1 1 0 010-1.414z" clip-rule="evenodd"></path></svg>');
    background-repeat: no-repeat;
    background-position: right 0.5rem center;
    background-size: 0.8rem;
    padding-right: 1.8rem; /* Make space for the custom arrow */
}

/* Styling for Heading dropdown options to show boldness */
#formatBlock option[value="h1"] {
    font-weight: 900; /* Extra bold for "Title" */
}
#formatBlock option[value="h2"] {
    font-weight: bold; /* Bold for "Heading 1" */
}
#formatBlock option[value="h3"] {
    font-weight: bold; /* Bold for "Heading 2" */
}
#formatBlock option[value="h4"] {
    font-weight: bold; /* Bold for "Heading 3" */
}


/* Color input specific styles */
.toolbar input[type="color"] {
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    border: none;
    background: none;
    padding: 0;
    width: 30px; /* Match button size */
    height: 30px; /* Match button size */
    cursor: pointer;
    border-radius: 0.375rem; /* Match button border-radius */
    overflow: hidden; /* Hide the default color swatch border */
}

.toolbar input[type="color"]::-webkit-color-swatch-wrapper {
    padding: 0;
}
.toolbar input[type="color"]::-webkit-color-swatch {
    border: 1px solid #cbd5e0; /* Add a subtle border */
    border-radius: 0.375rem;
}
.toolbar input[type="color"]::-moz-color-swatch-wrapper {
    padding: 0;
}
.toolbar input[type="color"]::-moz-color-swatch {
    border: 1px solid #cbd5e0; /* Add a subtle border */
    border-radius: 0.375rem;
}

/* Image scale controls */
.image-scale-controls {
    display: flex; /* Always display as flex to occupy space */
    align-items: center; /* Vertically center items */
    gap: 0.5rem;
    background-color: #e2e8f0;
    padding: 0.4rem 0.6rem;
    border-radius: 0.375rem;
    border: 1px solid #cbd5e0;
    min-height: 38px; /* Ensure a consistent height for the control group */
}

/* Control visibility of message vs. actual controls via JS, not CSS classes on parent */
.image-control-message {
    /* display: none; will be set by JS */
    line-height: 1.5; /* Ensure consistent line height */
}
.image-control-content {
    display: flex; /* Always flex to align its children */
    align-items: center; /* Vertically center items within this sub-group */
    gap: 0.5rem;
    /* display: none; will be set by JS */
}

.image-control-content label,
.image-control-content span {
    flex-shrink: 0; /* Prevent text from shrinking */
    line-height: 1; /* Ensure consistent vertical alignment */
}


.image-scale-controls input[type="range"] {
    -webkit-appearance: none;
    appearance: none;
    width: 100px; /* Adjust as needed */
    height: 8px;
    background: #cbd5e0;
    outline: none;
    border-radius: 4px;
    transition: opacity .2s;
    /* Ensure no extra margin/padding affecting alignment */
    margin: 0;
    padding: 0;
}

.image-scale-controls input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: #3b82f6;
    cursor: pointer;
}

.image-scale-controls input[type="range"]::-moz-range-thumb {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: #3b82f6;
    cursor: pointer;
}

.image-scale-controls input[type="number"] {
    width: 60px;
    padding: 0.2rem 0.4rem;
    border: 1px solid #cbd5e0;
    border-radius: 0.25rem;
    text-align: center;
    font-size: 0.875rem;
    color: #4a5568;
    /* Ensure no extra margin/padding affecting alignment */
    margin: 0;
}


/* Editor Area with Page Layout Visuals */
.editor-container {
    flex-grow: 1;
    display: flex;
    justify-content: center;
    padding: 1rem 0;
    overflow: auto;
    background-color: #e2e8f0;
}
.editor-area {
    min-height: 100%;
    width: 794px; /* Default to A4 width at 96 DPI for visual representation */
    border: 1px solid #cbd5e0;
    border-radius: 0.25rem;
    padding: 2.5cm; /* Standard A4 margins */
    font-size: 1rem;
    line-height: 1.5;
    outline: none;
    overflow-y: auto;
    resize: vertical;
    background-color: #ffffff;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
    color: #374151;
    box-sizing: border-box; /* Include padding and border in the element's total width and height */
}
.editor-area:focus {
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.25);
}

/* Specific Page Size Classes (will be applied by JS) */
.editor-area.a4 {
    width: 794px; /* A4 width at 96 DPI */
    min-height: 1123px; /* A4 height at 96 DPI */
}
.editor-area.letter {
    width: 816px; /* Letter width at 96 DPI */
    min-height: 1056px; /* Letter height at 96 DPI */
}
.editor-area.legal {
    width: 816px; /* Legal width at 96 DPI */
    min-height: 1344px; /* Legal height at 96 DPI */
}


/* Download options area */
.download-options {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    margin-top: 1.5rem;
    padding: 1rem;
    background-color: #f0f4f8;
    border-radius: 0.5rem;
    justify-content: center;
    align-items: center;
}
.download-options button {
    background-color: #10b981;
    color: white;
    padding: 0.6rem 1.2rem;
    border-radius: 9999px;
    font-weight: 600;
    transition: background-color 0.2s ease-in-out;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}
.download-options button:hover {
    background-color: #059669;
}
.download-options button svg {
    width: 1.1rem;
    height: 1.1rem;
    fill: currentColor;
}

/* Download dropdown specific styles */
.download-dropdown {
    position: relative;
    display: inline-block;
}
.download-dropdown select {
    background-color: #10b981;
    color: white;
    padding: 0.6rem 2.5rem 0.6rem 1.2rem;
    border-radius: 9999px;
    font-weight: 600;
    cursor: pointer;
    border: none;
    background-image: url('data:image/svg+xml;utf8,<svg fill="white" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path fill-rule="evenodd" d="M5.293 7.293a1 1 0 011.414 0L10 10.586l3.293-3.293a1 1 0 111.414 1.414l-4 4a1 1 0 01-1.414 0l-4-4a1 1 0 010-1.414z" clip-rule="evenodd"></path></svg>');
    background-repeat: no-repeat;
    background-position: right 0.8rem center;
    background-size: 1rem;
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    outline: none;
}
.download-dropdown select:hover {
    background-color: #059669;
}

/* Message box styles */
.message-box {
    padding: 0.75rem 1rem;
    border-radius: 0.5rem;
    margin-top: 1rem;
    display: none; /* Hidden by default */
    font-size: 0.9rem;
    font-weight: 500;
    width: 100%;
    text-align: center;
}
.message-box.active {
    display: block;
}
.message-box.warning {
    background-color: #fefcbf;
    border: 1px solid #fcd34d;
    color: #92400e;
}
.message-box.error {
    background-color: #fee2e2;
    border: 1px solid #f87171;
    color: #991b1b;
}
.message-box.success {
    background-color: #d1fae5;
    border: 1px solid #34d399;
    color: #065f46;
}
.message-box.info {
    background-color: #e0f2fe;
    border: 1px solid #93c5fd;
    color: #1e40af;
}

/* File input button styling */
.toolbar .file-input-group {
    position: relative;
    overflow: hidden;
    display: inline-block; /* Aligns button correctly in flex container */
}

.toolbar .file-input-group input[type="file"] {
    position: absolute;
    left: 0;
    top: 0;
    opacity: 0;
    cursor: pointer;
    width: 100%;
    height: 100%;
    z-index: 2; /* Ensure it's clickable over the button */
}
