@font-face {
    font-family: 'Open Sans';
    src: url('/static/fonts/OpenSans-Regular.ttf') format('truetype');
    font-weight: normal;
    font-style: normal;
    font-display: swap;
}

@font-face {
    font-family: 'Open Sans';
    src: url('/static/fonts/OpenSans-Bold.ttf') format('truetype');
    font-weight: bold;
    font-style: normal;
    font-display: swap;
}

html {
    font-size: 16px; /* Base font size for rem units */
}

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

body {
    font-family: 'Open Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    font-size: 16px; /* Explicit base font size */
    background: #f5f5f5;
    padding: 20px;
    line-height: 1.6;
}
.container {
    max-width: 1100px;
    margin: 0 auto;
    background: white;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    padding: 10px;
}
h1 {
    color: #0D3D73;
    margin-bottom: 20px;
    text-align: center;
}
ul { margin-left: 20px; }

.form-group {
    margin-bottom: 20px;
}
label {
    display: block;
    font-weight: 600;
    margin-bottom: 8px;
    color: #333;
}
input[type="text"], input[type="file"] {
    width: 100%;
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 14px;
}
input[type="file"] {
    padding: 8px;
}
.btn {
    background: #034592;
    color: white;
    padding: 12px 24px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 16px;
    font-weight: 600;
    margin-right: 10px;
    margin-top: 10px;
    transition: all 0.2s ease;
}
.btn:hover {
    background: #022f68;
}
.btn:disabled {
    background: #ccc;
    cursor: not-allowed;
}
.btn-outline {
    background: #fff;
    color: #034592;
    border: 1px solid #034592;
}
.btn-outline:hover {
    background: #e8f0fa;
}
.btn-login {
    width: 150px;
    margin-bottom: 20px;
}
.preview-section {
    margin-top: 30px;
    text-align: center;
}
.preview-section img {
    max-width: 100%;
    height: auto;
    border: 1px solid #ddd;
    border-radius: 6px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    margin: 20px 0;
}
.hidden {
    display: none;
}
.file-list {
    margin-top: 10px;
    padding: 10px;
    background: #f9f9f9;
    border-radius: 4px;
    max-height: 200px;
    overflow-y: auto;
}
.file-item {
    padding: 5px;
    font-size: 12px;
    color: #666;
}
.loading {
    text-align: center;
    padding: 20px;
    color: #005A9C;
}

/* Size for brand */
nav .navbar-brand
{
    font-size: xx-large;
}
nav .navbar-brand.mx-auto {
    flex: 1;
    text-align: center;
    margin: 0 auto;
}
.navbar-logo {
    height: 40px;
    width: auto;
    max-width: 200px;
}
nav .navbar-tight {
    margin-top: 0px !important;
    margin-bottom: 0px !important;
}

/* Colors for brand */
.blue
{
    color: #244E77;
}
.red
{
    color: #ea433b;
}
.green
{
    color: #2e944b;
}
.section {
    margin-bottom: 10px;
    padding: 5px;
    background: linear-gradient(135deg, #f8fbff 0%, #eef3fb 100%);
    border-radius: 5px;
    border: 1px solid #d8e2f2;
}
.section h2 {
    color: #034592;
    margin-bottom: 16px;
    font-size: 1.4em;
}
textarea {
    width: 100%;
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 14px;
    font-family: inherit;
    resize: vertical;
}
.btn-primary {
    background: #244e77;
}
.btn-primary:hover {
    background: #034592;
}
.std-box {
    padding: 10px 20px; min-width: 200px;
}
.status-text {
    margin-left: 10px;
    font-size: 14px;
    font-weight: 500;
}
.form-control {
    width: 100%;
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 14px;
}
.toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 8px;
    align-items: flex-end;
}
.toolbar-inline {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}
.toolbar-inline .small-label {
    margin: 0;
    white-space: nowrap;
}
.toolbar-inline select,
.toolbar-inline button {
    margin: 0;
}
.tool-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.tool-group input[type="file"],
.tool-group select {
    padding: 8px;
    border: 1px solid #d0d7e2;
    border-radius: 6px;
}
.small-label {
    font-size: 12px;
    color: #4a6183;
}
.va-layout {
    display: flex;
    flex-direction: column;
    gap: 12px;
}
.panel {
    background: #fff;
    border: 1px solid #d8e2f2;
    border-radius: 5px;
    padding: 5px;
    box-shadow: 0 1px 4px rgba(0,0,0,0.04);
}
.panel-label {
    display: block;
    font-weight: 700;
    color: #034592;
    margin-bottom: 5px;
}
.title-panel textarea {
    min-height: 12vh;
}
.footer-panel textarea {
    min-height: 8vh;
}
.main-panel {
    display: grid;
    grid-template-columns: 35% 40% 25%;
    gap: 1px;
    min-height: 40vh;
    align-items: stretch;
}
.left-panel textarea,
.right-panel textarea {
    min-height: 20vh;
}
.left-panel,
.right-panel {
    display: flex;
    flex-direction: column;
    height: 100%;
}
.results-textarea,
.conclusion-textarea {
    height: 100%;
    flex: 1;
    min-height: 200px;
}
.skip-ai-section {
    margin-bottom: 10px;
    padding: 10px;
    background: #f8f9fb;
    border: 1px solid #d8e2f2;
    border-radius: 10px;
}
.image-panel {
    display: flex;
    flex-direction: column;
    gap: 5px;
}
.image-upload input[type="file"] {
    width: 100%;
}
.image-stage {
    background: #f6f8fb;
    border: 1px dashed #b4c5e4;
    border-radius: 4px;
    min-height: 320px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #6b7a99;
    text-align: center;
    padding: 8px;
    position: relative;
    overflow: hidden;
}
.image-stage .stage-image {
    user-select: none;
    -webkit-user-drag: none;
}
.resizable {
    resize: both;
    overflow: auto;
}
.thumbnail-bar {
    display: flex;
    gap: 4px;
    flex-wrap: wrap;
    justify-content: center;
}
.thumbnail-bar .thumb {
    height: 40px;
    width: auto;
    border: 1px solid #d8e2f2;
    border-radius: 4px;
    object-fit: contain;
    background: #fff;
    padding: 4px;
}
.thumbnail-bar .portrait {
    max-height: 60px;
}
.muted {
    color: #6b7a99;
    font-size: 12px;
}
.actions {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    margin-top: 6px;
    margin-bottom: 6px;
}
.article-input-section {
    background: #f8f9fb;
    border: 1px solid #d8e2f2;
    border-radius: 10px;
    padding: 10px;
    margin-bottom: 10px;
}
.section-header {
    margin-bottom: 10px;
}
.section-header h3 {
    color: #034592;
    font-size: 18px;
    margin-bottom: 4px;
}
.section-desc {
    color: #6b7a99;
    font-size: 13px;
    margin: 0;
}
.article-controls {
    display: flex;
    flex-direction: column;
    gap: 12px;
}
.article-textarea {
    width: 100%;
    padding: 12px;
    border: 1px solid #d8e2f2;
    border-radius: 6px;
    font-size: 14px;
    font-family: inherit;
    resize: vertical;
    background: #fff;
    color: #1a1a1a;
}
.article-textarea:focus {
    outline: none;
    border-color: #034592;
    box-shadow: 0 0 0 3px rgba(3, 69, 146, 0.1);
}
.toolbar {
    background: #fff;
    border: 1px solid #d8e2f2;
    border-radius: 4px;
    padding: 8px;
    margin-bottom: 8px;
}
.panel {
    transition: box-shadow 0.2s ease;
}
.panel:hover {
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
}
.btn-outline {
    background: transparent;
    border: 2px solid #034592;
    color: #034592;
}
.btn-outline:hover {
    background: #034592;
    color: #fff;
}

/* Mobile/Smartphone Optimizations */
@media screen and (max-width: 768px) {
    body {
        padding: 10px;
        font-size: 14px;
    }
    
    .container {
        max-width: 100%;
        padding: 8px;
        border-radius: 4px;
    }
    
    h2, h3 {
        font-size: 1.2em;
        margin-bottom: 10px;
    }
    
    .section {
        padding: 8px;
        margin-bottom: 8px;
    }
    
    .section-header h3 {
        font-size: 16px;
    }
    
    .section-desc {
        font-size: 12px;
    }
    
    /* Toolbar stacks vertically on mobile */
    .toolbar-inline {
        flex-direction: column;
        align-items: stretch;
        gap: 8px;
    }
    
    .toolbar-inline .small-label {
        margin-bottom: 4px;
    }
    
    .toolbar-inline select,
    .toolbar-inline button {
        width: 100%;
        padding: 12px;
        font-size: 16px; /* Prevents zoom on iOS */
        margin: 0;
    }
    
.toolbar-inline .status-text {
    margin-left: 0;
    margin-top: 4px;
    font-size: 12px;
    text-align: center;
}
.toolbar-centered {
    justify-content: center;
}
.centered-btn {
    width: 100%;
    display: block;
    margin-left: 0;
    margin-right: 0;
    margin-top: 10px;
}
.centered-file-input {
    width: 100%;
    margin: 0 auto;
    display: block;
}
.tool-group {
    width: 100%;
}
    
    /* Article controls stack */
    .article-controls {
        gap: 8px;
    }
    
    .tool-group {
        width: 100%;
    }
    
    .tool-group button {
        width: 100%;
        margin-left: 0;
        margin-top: 8px;
        padding: 12px;
        font-size: 16px;
    }
    
    /* Main panel stacks vertically on mobile */
    .main-panel {
        display: flex;
        flex-direction: column;
        gap: 8px;
        min-height: auto;
    }
    
    .left-panel,
    .right-panel {
        width: 100%;
        min-height: 120px;
    }
    
    .left-panel textarea,
    .right-panel textarea {
        min-height: 80px;
    }
    
    /* Title and footer panels */
    .title-panel textarea {
        min-height: 80px;
    }
    
    .footer-panel textarea {
        min-height: 60px;
    }
    
    /* Image stage optimized for mobile */
    .image-panel {
        flex-direction: row;
        flex-wrap: wrap;
        gap: 8px;
    }
    
    .image-panel .panel-label {
        flex-basis: 100%;
    }
    
    .image-panel .image-upload {
        flex-basis: 100%;
    }
    
    .image-stage {
        min-height: 200px;
        padding: 5px;
        flex: 1;
        min-width: 70%;
    }
    
    .thumbnail-bar {
        gap: 6px;
        flex-direction: column;
        flex: 0 0 auto;
        width: auto;
        min-width: 20%;
        max-width: 25%;
        max-height: 200px;
        overflow-y: auto;
        align-items: center;
        justify-content: flex-start;
    }
    
    .thumbnail-bar .thumb {
        height: 30px;
        max-height: 40px;
        width: auto;
    }
    
    /* Buttons full width on mobile */
    .btn {
        width: 100%;
        margin-right: 0;
        margin-top: 8px;
        padding: 14px;
        font-size: 16px;
        -webkit-tap-highlight-color: rgba(3, 69, 146, 0.2);
    }
    
    
    /* Article textarea */
    .article-textarea {
        font-size: 16px; /* Prevents zoom on iOS */
        padding: 12px;
    }
    
    /* Panel adjustments */
    .panel {
        padding: 8px;
    }
    
    .panel-label {
        font-size: 13px;
    }
    
    /* Actions section */
    .actions {
        flex-direction: column;
        gap: 8px;
    }
    
    /* Preview section */
    .preview-section {
        margin-top: 20px;
    }
    
    .preview-section img {
        max-width: 100%;
        height: auto;
    }
    
    /* Navbar adjustments */
    nav .navbar-brand {
        font-size: 18px;
    }
    
    .navbar-logo {
        height: 30px;
        max-width: 150px;
    }
    
    /* File list */
    .file-list {
        max-height: 150px;
        font-size: 12px;
    }
    
    /* Loading text */
    .loading {
        padding: 15px;
        font-size: 14px;
    }
}

/* Small smartphones (portrait) */
@media screen and (max-width: 480px) {
    body {
        padding: 2px;
    }
    
    .container {
        padding: 2px;
    }
    
    .section {
        padding: 2px;
    }
    
    .section-header h3 {
        font-size: 14px;
    }
    
    .section-desc {
        font-size: 11px;
    }
    
    .toolbar-inline select,
    .toolbar-inline button,
    .btn {
        padding: 10px 8px;
        font-size: 14px;
    }
    
    .title-panel textarea {
        min-height: 60px;
    }
    
    .left-panel,
    .right-panel {
        width: 100%;
        min-height: 120px;
    }
    
    .left-panel textarea,
    .right-panel textarea {
        min-height: 80px;
    }
    
    .footer-panel textarea {
        min-height: 50px;
    }
    
    .image-stage {
        min-height: 150px;
        min-width: 70%;
    }
    
    .thumbnail-bar {
        min-width: 20%;
        max-width: 25%;
        max-height: 150px;
    }
    
    .thumbnail-bar .thumb {
        height: 25px;
    }
}

/* Landscape orientation on mobile */
@media screen and (max-width: 768px) and (orientation: landscape) {
    .main-panel {
        display: grid;
        grid-template-columns: 1fr 1fr;
        grid-template-rows: auto auto;
    }
    
    .left-panel {
        grid-column: 1;
        grid-row: 1;
    }
    
    .right-panel {
        grid-column: 2;
        grid-row: 1;
    }
    
    .image-panel {
        grid-column: 1 / -1;
        grid-row: 2;
        flex-direction: row;
        flex-wrap: wrap;
        gap: 8px;
    }
    
    .image-panel .panel-label {
        flex-basis: 100%;
    }
    
    .image-panel .image-upload {
        flex-basis: 100%;
    }
    
    .image-stage {
        min-height: 200px;
        padding: 5px;
        flex: 1;
        min-width: 70%;
    }
    
    .thumbnail-bar {
        gap: 6px;
        flex-direction: column;
        flex: 0 0 auto;
        width: auto;
        min-width: 20%;
        max-width: 25%;
        max-height: 200px;
        overflow-y: auto;
        align-items: center;
        justify-content: flex-start;
    }
    
    .thumbnail-bar .thumb {
        height: 30px;
        max-height: 40px;
        width: auto;
    }
    
    .left-panel textarea,
    .right-panel textarea {
        min-height: 120px;
    }
}

/* Touch-friendly improvements */
@media (hover: none) and (pointer: coarse) {
    /* Touch devices */
    .btn {
        min-height: 44px; /* iOS recommended touch target */
        -webkit-tap-highlight-color: rgba(3, 69, 146, 0.2);
    }
    
    .thumb {
        min-width: 44px;
        min-height: 44px;
    }
    
    /* Larger touch targets for file inputs */
    input[type="file"] {
        padding: 12px;
        font-size: 16px;
    }
    
    /* Better spacing for touch */
    .toolbar-inline {
        gap: 10px;
    }
    
    .panel {
        padding: 10px;
    }
    
    /* Prevent text selection on touch drag */
    .stage-image {
        -webkit-user-select: none;
        user-select: none;
        -webkit-touch-callout: none;
    }
}

/* Prevent horizontal scroll on mobile */
@media screen and (max-width: 768px) {
    html, body {
        overflow-x: hidden;
        width: 100%;
    }
    
    .container {
        overflow-x: hidden;
    }
}