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

/* Prevent screen rotation - lock to portrait (prevent upside-down) */
html, body {
    position: fixed;
    width: 100%;
    height: 100%;
    overflow: hidden;
    /* Prevent any rotation transforms */
    transform: none !important;
}

/* Force portrait orientation - prevent landscape */
@media screen and (orientation: landscape) {
    html, body {
        /* Don't rotate, just prevent landscape */
        transform: none !important;
        width: 100vw !important;
        height: 100vh !important;
    }
    
    /* Show overlay message if rotation detected */
    body::before {
        content: 'Please rotate device to portrait';
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: #2c5f2d;
        color: white;
        display: flex;
        align-items: center;
        justify-content: center;
        font-size: 1.5em;
        z-index: 99999;
    }
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: linear-gradient(135deg, #2c5f2d 0%, #1e3f1f 100%);
    color: #333;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body.landscape-block .screen {
    display: none !important;
}

.orientation-overlay {
    position: fixed;
    inset: 0;
    background: #2c5f2d;
    color: #fff;
    display: none;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 20px;
    z-index: 9999;
}

.orientation-message {
    font-size: 1.4em;
    font-weight: 600;
    line-height: 1.4;
}

body.landscape-block .orientation-overlay {
    display: flex;
}

/* Back Arrow */
.back-arrow {
    background: transparent;
    border: none;
    color: #2c5f2d;
    font-size: 1.2em;
    font-weight: bold;
    cursor: pointer;
    padding: 2px 5px;
    margin-bottom: 2px;
    transition: color 0.2s;
}

.back-arrow:hover {
    color: #1e3f1f;
}

/* Container */
.container {
    max-width: 600px;
    margin: 0 auto;
    padding: 10px;
    background: white;
    height: 100vh; /* Use full viewport height */
    box-shadow: 0 0 20px rgba(0, 0, 0, 0.1);
    overflow-y: hidden;
}

.container.compact {
    max-width: 100%;
    padding: 5px;
}

/* Compact scanning interface - two columns */
.scan-columns-container {
    display: flex;
    flex-direction: row;
    gap: 2%;
    align-items: flex-start;
    width: 100%;
}

.scan-column {
    width: 49%;
    display: flex;
    flex-direction: column;
}

.scan-field {
    margin-bottom: 4px;
}

.scan-field label {
    display: block;
    font-size: 0.7em;
    color: #666;
    margin-bottom: 3px;
    font-weight: 600;
}

.scan-input {
    width: 100%;
    background: #fffacd;
    border: 1px solid #ddd;
    padding: 4px 6px;
    border-radius: 3px;
    font-size: 0.9em;
    color: #333;
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    box-sizing: border-box;
}

.scan-input:focus {
    outline: none;
    border-color: #2c5f2d;
    background: #fffef0;
}

.scan-input[readonly] {
    background: #fffacd;
}

.scan-input.clickable {
    cursor: pointer;
    transition: box-shadow 0.2s;
}

.scan-input.clickable:active {
    box-shadow: inset 0 0 0 2px #2c5f2d33;
}

.scan-value {
    background: #fffacd;
    border: 1px solid #ddd;
    padding: 4px 6px;
    border-radius: 3px;
    font-size: 0.9em;
    min-height: 28px;
    color: #333;
}

.scan-total {
    background: #ffd700;
    border: 1px solid #ddd;
    padding: 4px 6px;
    border-radius: 3px;
    font-size: 0.95em;
    font-weight: 600;
    min-height: 28px;
    text-align: center;
    color: #333;
}

.nav-buttons-horizontal {
    display: flex;
    gap: 12px;
    margin-bottom: 15px;
}

.btn-nav {
    flex: 1;
    padding: 30px 20px;
    font-size: 2.2em;
    background: #d4e9d4;
    border: 5px solid #2c5f2d;
    border-radius: 12px;
    color: #2c5f2d;
    cursor: pointer;
    font-weight: 900;
    transition: all 0.2s;
    min-height: 100px;
    box-shadow: 0 3px 6px rgba(0, 0, 0, 0.15);
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn-nav:hover {
    background: #b8d8b8;
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
    border-width: 3px;
}

.btn-nav:active {
    background: #9bc99b;
    transform: translateY(0);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

.btn-nav.light-green {
    background: #90EE90;
    border-color: #228B22;
    color: #000;
}

.btn-nav.light-green:hover {
    background: #7CC87C;
}

.btn-nav.light-green:active {
    background: #68C368;
}

.scan-full-actions {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-top: 6px;
}

.scan-full-actions .btn-secondary {
    width: 100%;
    font-size: 1.05em;
    padding: 14px;
    border-radius: 10px;
}

.range-status {
    margin-top: 8px;
    padding: 8px;
    border: 2px dashed #2c5f2d;
    border-radius: 6px;
    background: #f5fff5;
    text-align: center;
}

.range-message {
    font-size: 0.9em;
    font-weight: 600;
    color: #2c5f2d;
    margin-bottom: 6px;
}

.range-actions {
    display: flex;
    justify-content: center;
}

.range-actions .btn-secondary {
    width: auto;
    min-width: 120px;
}

/* Headings */
h1 {
    text-align: center;
    color: #2c5f2d;
    margin-bottom: 15px;
    margin-top: 5px;
    font-size: 1.5em;
}

h2 {
    color: #2c5f2d;
    margin-bottom: 15px;
    font-size: 1.2em;
}

/* Screens */
.screen {
    display: none;
    animation: fadeIn 0.3s ease-in;
}

.screen.active {
    display: block;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Form Elements */
.form-group {
    margin-bottom: 12px;
}

.form-group label {
    display: block;
    margin-bottom: 5px;
    font-weight: 600;
    color: #555;
}

.input {
    width: 100%;
    padding: 10px;
    font-size: 1em;
    border: 2px solid #ddd;
    border-radius: 6px;
    transition: border-color 0.3s;
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
}

select.input {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12'%3E%3Cpath fill='%23333' d='M6 9L1 4h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
    background-size: 20px;
    padding-right: 40px;
}

.input:focus {
    outline: none;
    border-color: #2c5f2d;
}

/* Buttons */
.btn {
    width: 100%;
    padding: 15px 20px;
    font-size: 1.1em;
    font-weight: 600;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s;
    margin-bottom: 10px;
}

.btn.compact {
    padding: 8px 12px;
    font-size: 0.9em;
    margin-bottom: 5px;
}

.btn-primary {
    background: #2c5f2d;
    color: white;
}

.btn-primary:hover:not(:disabled),
.btn-primary:active:not(:disabled) {
    background: #1e3f1f;
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}

.btn-secondary {
    background: #4f8a4f;
    color: white;
    border: 2px solid #397339;
}

.btn-secondary:hover:not(:disabled) {
    background: #3e753e;
}

.btn-large {
    padding: 12px;
    font-size: 1em;
    margin-top: 10px;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Toggle Group */
.toggle-group {
    display: flex;
    gap: 10px;
}

.toggle-btn {
    flex: 1;
    padding: 12px;
    font-size: 1em;
    font-weight: 600;
    border: 2px solid #ddd;
    background: white;
    color: #555;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s;
}

.toggle-btn.active {
    background: #2c5f2d;
    color: white;
    border-color: #2c5f2d;
}

/* Mode Selection */
.mode-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 15px;
    margin: 30px 0;
}

.mode-btn {
    padding: 30px 20px;
    background: white;
    border: 2px solid #2c5f2d;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.3s;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
}

.mode-btn.active {
    background: #2c5f2d;
    color: white;
}

.mode-btn.disabled {
    opacity: 0.3;
    cursor: not-allowed;
    border-color: #ccc;
}

.mode-icon {
    font-size: 2.5em;
}

.mode-label {
    font-size: 1.1em;
    font-weight: 600;
}

/* Location Display */
.location-display {
    background: #f8f9fa;
    padding: 15px;
    border-radius: 8px;
    margin-bottom: 20px;
    text-align: center;
}

.location-display h2 {
    margin: 0;
    font-size: 1.3em;
}

.container.history {
    display: flex;
    flex-direction: column;
    gap: 10px;
    overflow-y: auto;
    padding-bottom: 20px;
}

.history-controls {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.history-controls .btn-secondary,
.history-controls .btn-primary {
    flex: 1;
    min-width: 120px;
}

.history-stats {
    display: flex;
    gap: 12px;
    justify-content: space-between;
}

.history-stat {
    flex: 1;
    background: #fffacd;
    border: 1px solid #ddd;
    border-radius: 6px;
    padding: 8px;
    text-align: center;
}

.history-stat span {
    display: block;
    font-size: 0.8em;
    color: #666;
    margin-bottom: 4px;
}

.history-stat div {
    font-size: 1.2em;
    font-weight: 700;
    color: #2c5f2d;
}

.history-filters {
    display: flex;
    gap: 8px;
}

.history-filters .btn-secondary {
    flex: 1;
}

.history-filters .btn-secondary.active {
    background: #2c5f2d;
    border-color: #2c5f2d;
}

.history-table-container {
    flex: 1;
    overflow-y: auto;
    border: 1px solid #ddd;
    border-radius: 6px;
    background: #fff;
}

.history-table {
    width: 100%;
    border-collapse: collapse;
}

.history-table th,
.history-table td {
    padding: 8px;
    border-bottom: 1px solid #eee;
    font-size: 0.9em;
    text-align: left;
}

.history-table th:first-child,
.history-table td:first-child {
    width: 60px;
    text-align: center;
}

.history-table tbody tr:nth-child(odd) {
    background: #f9f9f9;
}

.history-table tbody tr.selected {
    background: #dff0d8;
}

.history-table input[type="checkbox"] {
    transform: scale(1.2);
}

.container.sessions {
    display: flex;
    flex-direction: column;
    gap: 12px;
    overflow-y: auto;
    padding-bottom: 20px;
}

.sessions-header {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.sessions-info {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}

.sessions-count {
    flex: 1;
    background: #fffacd;
    border: 1px solid #ddd;
    border-radius: 6px;
    padding: 8px;
    min-width: 140px;
}

.sessions-count .label {
    display: block;
    font-size: 0.8em;
    color: #666;
    margin-bottom: 4px;
}

.sessions-count span:last-child {
    font-size: 1.2em;
    font-weight: 700;
    color: #2c5f2d;
}

.sessions-actions {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.sessions-actions .btn-primary,
.sessions-actions .btn-secondary {
    width: 100%;
    font-size: 1.05em;
    padding: 14px;
    border-radius: 10px;
}

.sessions-actions .btn-primary {
    margin-top: -4px;
}

.sessions-table-container {
    flex: 1;
    overflow-y: auto;
    border: 1px solid #ddd;
    border-radius: 6px;
    background: #fff;
}

.sessions-table {
    width: 100%;
    border-collapse: collapse;
    table-layout: auto;
}

.sessions-table th,
.sessions-table td {
    padding: 9px 10px;
    border-bottom: 1px solid #eee;
    font-size: 0.95em;
    text-align: left;
    white-space: nowrap;
}

.sessions-table th:first-child,
.sessions-table td:first-child {
    width: 60px;
    text-align: center;
}

.sessions-table tbody tr:nth-child(odd) {
    background: #f9f9f9;
}

.sessions-table tbody tr.selected {
    background: #dff0d8;
}

.sessions-table input[type="checkbox"] {
    transform: scale(1.2);
}

/* Scan Input */
.scan-input-area {
    margin: 10px 0;
    width: 100%;
}

.scan-input-area.hidden-input-container {
    height: 0;
    overflow: hidden;
    margin: 0;
    padding: 0;
}

.barcode-input {
    width: 100%;
    padding: 12px;
    font-size: 1.0em;
    text-align: center;
    letter-spacing: 2px;
    border: 2px solid #2c5f2d;
    border-radius: 4px;
    background: #f8f9fa;
    /* Disable Android autocomplete and suggestions */
    -webkit-appearance: none;
    -webkit-tap-highlight-color: transparent;
}

.barcode-input.compact {
    padding: 10px;
    font-size: 0.95em;
}

.barcode-input.hidden-input {
    position: fixed;
    left: -9999px;
    width: 1px;
    height: 1px;
    opacity: 0;
    pointer-events: none;
}

.scan-input-area.hidden-input-container {
    height: 0;
    overflow: hidden;
    margin: 0;
    padding: 0;
    width: 0;
}

/* Prevent keyboard suggestions on all inputs */
input:-webkit-autofill {
    box-shadow: 0 0 0px 1000px white inset !important;
}

input[autocomplete="off"] {
    /* Force disable Chrome autocomplete */
    background-color: transparent !important;
}

input::-webkit-contacts-auto-fill-button {
    display: none !important;
}

/* Bale Count */
.bale-count {
    text-align: center;
    font-size: 1.5em;
    font-weight: 600;
    color: #2c5f2d;
    margin: 20px 0;
}

/* Bale List */
.bale-list {
    max-height: 400px;
    overflow-y: auto;
    border: 2px solid #ddd;
    border-radius: 8px;
    margin-bottom: 20px;
    background: #f8f9fa;
}

.bale-item {
    padding: 15px;
    border-bottom: 1px solid #ddd;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: white;
}

.bale-item:last-child {
    border-bottom: none;
}

.bale-item:first-child {
    border-radius: 8px 8px 0 0;
}

.bale-item:last-child {
    border-radius: 0 0 8px 8px;
}

.bale-info {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.bale-gin {
    font-weight: 600;
    color: #2c5f2d;
}

.bale-number {
    color: #666;
    font-size: 0.9em;
}

.bale-time {
    font-size: 0.8em;
    color: #999;
}

.empty-list {
    padding: 40px;
    text-align: center;
    color: #999;
    font-style: italic;
}

/* License Status */
.license-status {
    background: #f8f9fa;
    padding: 10px;
    border-radius: 6px;
    margin: 10px 0;
    text-align: center;
}

.status-text {
    font-size: 0.9em;
    color: #555;
}

.status-warning {
    color: #f39c12;
    font-weight: 600;
}

.status-error {
    color: #e74c3c;
    font-weight: 600;
}

.status-ok {
    color: #27ae60;
    font-weight: 600;
}

/* Summary */
.summary {
    background: #f8f9fa;
    padding: 20px;
    border-radius: 8px;
    margin: 20px 0;
}

.summary-item {
    display: flex;
    justify-content: space-between;
    padding: 10px 0;
    border-bottom: 1px solid #ddd;
}

.summary-item:last-child {
    border-bottom: none;
}

.summary-label {
    font-weight: 600;
    color: #555;
}

.summary-value {
    font-size: 1.2em;
    font-weight: 600;
    color: #2c5f2d;
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1000;
    animation: fadeIn 0.3s;
}

.modal.active {
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-content {
    background: white;
    border-radius: 12px;
    max-width: 500px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
    animation: slideUp 0.3s;
}

@keyframes slideUp {
    from {
        transform: translateY(50px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px;
    border-bottom: 2px solid #ddd;
}

.modal-header h2 {
    margin: 0;
}

.modal-close {
    background: none;
    border: none;
    font-size: 2em;
    cursor: pointer;
    color: #999;
    line-height: 1;
    padding: 0;
    width: 30px;
    height: 30px;
}

.modal-body {
    padding: 20px;
}

.setting-item {
    padding: 15px 0;
    border-bottom: 1px solid #eee;
}

.setting-item:last-child {
    border-bottom: none;
}

.setting-item label {
    display: block;
    margin-bottom: 5px;
    font-weight: 600;
    color: #555;
}

.btn-danger {
    background: #e74c3c;
    color: white;
    margin-top: 20px;
}

.btn-danger:hover {
    background: #c0392b;
}

/* Loading Overlay */
.overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 2000;
}

.spinner {
    width: 50px;
    height: 50px;
    border: 5px solid rgba(255, 255, 255, 0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.loading-text {
    color: white;
    margin-top: 20px;
    font-size: 1.2em;
}

/* Toast */
#toast-container {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 3000;
    max-width: 90%;
}

.toast {
    background: #333;
    color: white;
    padding: 15px 20px;
    border-radius: 8px;
    margin-bottom: 10px;
    animation: slideInUp 0.3s;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.3);
}

.toast.success {
    background: #27ae60;
}

.toast.error {
    background: #e74c3c;
}

.toast.warning {
    background: #f39c12;
}

@keyframes slideInUp {
    from {
        transform: translateY(100px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

/* Error Message */
.error-message {
    background: #fee;
    border: 2px solid #e74c3c;
    color: #e74c3c;
    padding: 15px;
    border-radius: 8px;
    margin-top: 10px;
    font-weight: 600;
}

/* Scrollbar Styling */
::-webkit-scrollbar {
    width: 10px;
}

::-webkit-scrollbar-track {
    background: #f1f1f1;
}

::-webkit-scrollbar-thumb {
    background: #888;
    border-radius: 5px;
}

::-webkit-scrollbar-thumb:hover {
    background: #555;
}

/* Break File Screens */
.break-files-list {
    margin-top: 20px;
}

.break-files-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 20px;
    margin-top: 20px;
}

.break-file-card {
    background: white;
    border-radius: 8px;
    padding: 20px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.break-file-card h3 {
    margin: 0 0 10px 0;
    color: #2c3e50;
    font-size: 1.1em;
}

.break-file-card p {
    margin: 5px 0;
    color: #666;
    font-size: 0.9em;
}

.break-scanned-list {
    background: #f8f9fa;
    border: 1px solid #dee2e6;
    border-radius: 4px;
    padding: 10px;
    margin: 10px 0;
    font-size: 12px;
}

.break-shortlist-container {
    margin-top: 20px;
    max-height: 60vh;
    overflow-y: auto;
}

