/* Main CSS for Archive OCR Web App */

/* Forcefully hide Keyman's On-Screen Keyboard (OSK) to prevent click blocking */
.kmw-osk-inner,
#kmw-osk,
.kmw-osk-wrapper,
.kmw-keyboard-icon {
    display: none !important;
    visibility: hidden !important;
    opacity: 0 !important;
    height: 0 !important;
    width: 0 !important;
    position: absolute !important;
    pointer-events: none !important;
}

:root {
    --primary-color: #6C63FF;
    --primary-dark: #5a52d5;
    --secondary-color: #00d4ff;
    --success-color: #4CAF50;
    --danger-color: #dc3545;
    --warning-color: #ff9800;
    --dark-bg: #1a1a2e;
    --light-bg: #f8f9fa;
    --white: #ffffff;
    --text-dark: #333333;
    --text-muted: #666666;
    --border-color: #e0e0e0;
}

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

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: var(--light-bg);
    color: var(--text-dark);
    line-height: 1.6;
}

/* Header */
.header {
    background: linear-gradient(135deg, var(--dark-bg) 0%, #16213e 100%);
    color: var(--white);
    padding: 10px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.header h1 {
    font-size: 20px;
    font-weight: 700;
    color: var(--secondary-color);
}

.header h1 span {
    color: var(--white);
    font-weight: 400;
}

.header-logo {
    display: flex;
    align-items: center;
    gap: 15px;
}

.navbar-title {
    font-size: 18px;
    font-weight: 700;
    background: linear-gradient(90deg, #00d4ff, #7c3aed);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    padding-left: 15px;
}

.header nav {
    display: flex;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    -ms-overflow-style: none;
    max-width: 100%;
    gap: 8px;
}

.header nav::-webkit-scrollbar {
    display: none;
}

.header nav a {
    color: var(--white);
    text-decoration: none;
    padding: 6px 12px;
    border-radius: 4px;
    transition: background 0.3s;
    font-size: 14px;
    white-space: nowrap;
}

.header nav a:hover {
    background: rgba(255, 255, 255, 0.1);
}

.header nav a.active {
    background: var(--primary-color);
}

/* Main Container */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
}

/* Search Section */
.search-section {
    background: var(--white);
    border-radius: 12px;
    padding: 40px;
    margin-bottom: 30px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
}

.search-section h2 {
    text-align: center;
    margin-bottom: 30px;
    color: var(--dark-bg);
    font-size: 28px;
}

.search-box {
    display: flex;
    gap: 15px;
    max-width: 700px;
    margin: 0 auto;
}

.search-box input {
    flex: 1;
    padding: 15px 20px;
    font-size: 16px;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    outline: none;
    transition: border-color 0.3s;
}

.search-box input:focus {
    border-color: var(--primary-color);
}

.search-box button {
    padding: 15px 30px;
    font-size: 16px;
    font-weight: 600;
    background: var(--primary-color);
    color: var(--white);
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.3s;
}

.search-box button:hover {
    background: var(--primary-dark);
}

.search-type-selector {
    display: flex;
    align-items: center;
    gap: 15px;
    margin-top: 15px;
}

.search-type-selector input[type="radio"] {
    /* Hide default radio button */
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
}

.search-type-selector label {
    display: inline-block;
    padding: 8px 18px;
    border: 2px solid #e0e0e0;
    border-radius: 20px;
    color: #666;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
}

.search-type-selector input[type="radio"]:checked+label {
    background: linear-gradient(135deg, #6C63FF, #7c3aed);
    color: white;
    border-color: #6C63FF;
    box-shadow: 0 4px 10px rgba(108, 99, 255, 0.3);
}

.search-type-selector label:hover {
    border-color: #6C63FF;
    color: #6C63FF;
}

/* Filters */

/* Results Section */
.results-section {
    background: var(--white);
    border-radius: 12px;
    padding: 30px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
}

.results-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-bottom: 20px;
    border-bottom: 1px solid var(--border-color);
    margin-bottom: 20px;
}

.results-header h3 {
    font-size: 18px;
    color: var(--dark-bg);
}

.results-count {
    color: var(--text-muted);
    font-size: 14px;
}

/* Result Card */
.result-card {
    background: var(--light-bg);
    border-radius: 8px;
    padding: 20px;
    margin-bottom: 15px;
    border-left: 4px solid var(--primary-color);
    transition: transform 0.2s, box-shadow 0.2s;
}

.result-card:hover {
    transform: translateX(5px);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
}

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

.result-book {
    font-weight: 600;
    color: var(--dark-bg);
    font-size: 16px;
}

.result-page {
    background: var(--primary-color);
    color: var(--white);
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
}

.result-text {
    color: var(--text-dark);
    font-size: 15px;
    line-height: 1.8;
    margin-bottom: 15px;
}

.result-text .highlight {
    background: #FFEB3B;
    padding: 2px 4px;
    border-radius: 3px;
    font-weight: 600;
}

.result-tags {
    font-size: 12px;
    color: var(--text-muted);
    margin-bottom: 10px;
}

.result-actions {
    display: flex;
    gap: 10px;
}

.btn {
    padding: 8px 16px;
    font-size: 13px;
    font-weight: 600;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    text-decoration: none;
    transition: background 0.3s;
}

.btn-primary {
    background: var(--primary-color);
    color: var(--white);
}

.btn-primary:hover {
    background: var(--primary-dark);
}

.btn-success {
    background: var(--success-color);
    color: var(--white);
}

.btn-danger {
    background: var(--danger-color);
    color: var(--white);
}

/* Loading */
.loading {
    text-align: center;
    padding: 40px;
    color: var(--text-muted);
}

.loading::after {
    content: '';
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid var(--border-color);
    border-top-color: var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-left: 10px;
    vertical-align: middle;
}

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

/* No Results */
.no-results {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-muted);
}

.no-results h4 {
    font-size: 20px;
    margin-bottom: 10px;
}

/* Admin Styles */
.admin-header {
    background: linear-gradient(135deg, #2d2d44 0%, var(--dark-bg) 100%);
}

.login-container {
    max-width: 400px;
    width: 90%;
    margin: 50px auto;
    background: var(--white);
    padding: 40px;
    border-radius: 12px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15);
}

.login-container h2 {
    text-align: center;
    margin-bottom: 30px;
    color: var(--dark-bg);
}

.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: var(--text-dark);
}

.form-group input {
    width: 100%;
    padding: 12px 15px;
    font-size: 15px;
    border: 2px solid var(--border-color);
    border-radius: 6px;
    outline: none;
    transition: border-color 0.3s;
}

.form-group input:focus {
    border-color: var(--primary-color);
}

.form-group button {
    width: 100%;
    padding: 14px;
    font-size: 16px;
    font-weight: 600;
    background: var(--primary-color);
    color: var(--white);
    border: none;
    border-radius: 6px;
    cursor: pointer;
    transition: background 0.3s;
}

.form-group button:hover {
    background: var(--primary-dark);
}

/* Flash Messages */
.flash-messages {
    max-width: 400px;
    margin: 0 auto 20px;
}

.flash {
    padding: 12px 20px;
    border-radius: 6px;
    margin-bottom: 10px;
}

.flash.success {
    background: #d4edda;
    color: #155724;
}

.flash.error {
    background: #f8d7da;
    color: #721c24;
}

/* Dashboard */
.dashboard-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
}

.dashboard-header h2 {
    font-size: 24px;
    color: var(--dark-bg);
}

/* Upload Section */
.upload-section {
    background: var(--white);
    border-radius: 12px;
    padding: 30px;
    margin-bottom: 30px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
}

.upload-section h3 {
    margin-bottom: 20px;
    color: var(--dark-bg);
}

.upload-zone {
    border: 2px dashed var(--border-color);
    border-radius: 8px;
    padding: 40px;
    text-align: center;
    cursor: pointer;
    transition: border-color 0.3s, background 0.3s;
}

.upload-zone:hover {
    border-color: var(--primary-color);
    background: rgba(108, 99, 255, 0.05);
}

.upload-zone.dragover {
    border-color: var(--primary-color);
    background: rgba(108, 99, 255, 0.1);
}

.upload-zone p {
    color: var(--text-muted);
    margin-bottom: 15px;
}

.upload-zone input[type="file"] {
    display: none;
}

.upload-progress {
    margin-top: 20px;
    display: none;
}

.progress-bar {
    height: 10px;
    background: var(--border-color);
    border-radius: 5px;
    overflow: hidden;
}

.progress-bar-fill {
    height: 100%;
    background: var(--primary-color);
    width: 0%;
    transition: width 0.3s;
}

/* Books Table */
.books-section {
    background: var(--white);
    border-radius: 12px;
    padding: 30px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
}

.books-section h3 {
    margin-bottom: 20px;
    color: var(--dark-bg);
}

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

.books-table th,
.books-table td {
    padding: 15px;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
}

.books-table th {
    background: var(--light-bg);
    font-weight: 600;
    color: var(--text-dark);
}

.books-table tr:hover {
    background: var(--light-bg);
}

.books-table .actions {
    display: flex;
    gap: 10px;
}

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

    .search-section {
        padding: 25px 15px;
    }

    .dashboard-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 15px;
    }

    .books-section header {
        flex-direction: column;
        align-items: flex-start;
        gap: 15px;
    }

    .books-table thead {
        display: none;
    }

    .books-table,
    .books-table tbody,
    .books-table tr,
    .books-table td {
        display: block;
        width: 100%;
    }

    .books-table tr {
        margin-bottom: 20px;
        border: 1px solid var(--border-color);
        border-radius: 8px;
        padding: 10px;
        background: white;
    }

    .books-table td {
        text-align: right;
        padding-left: 50%;
        position: relative;
        border-bottom: 1px solid #f0f0f0;
    }

    .books-table td:last-child {
        border-bottom: none;
    }

    .books-table td::before {
        content: attr(data-label);
        position: absolute;
        left: 15px;
        width: 45%;
        text-align: left;
        font-weight: 700;
        color: var(--text-muted);
        font-size: 13px;
    }

    .books-table td.actions {
        display: flex;
        justify-content: flex-end;
        padding-left: 15px;
        flex-wrap: wrap;
        gap: 8px;
    }

    .books-table td.actions::before {
        display: none;
    }

    /* Dashboard specific responsive fixes */
    .admin-controls-bar {
        flex-direction: column !important;
        align-items: stretch !important;
    }

    .admin-filters {
        flex-direction: column !important;
        width: 100% !important;
    }

    .admin-filters input {
        width: 100% !important;
        min-width: 0 !important;
    }

    .dashboard-header-flex {
        flex-direction: column !important;
        align-items: stretch !important;
        gap: 15px !important;
    }

    .dashboard-actions {
        flex-direction: column !important;
        width: 100% !important;
    }

    .dashboard-actions .btn {
        width: 100% !important;
    }

    /* Edit Book specific responsive fixes */
    .edit-header-flex {
        flex-direction: column !important;
        align-items: stretch !important;
        gap: 15px !important;
    }

    .scratchpad-flex {
        flex-direction: column !important;
    }

    .scratchpad-flex button {
        width: 100% !important;
    }

    .meta-field-group {
        width: 100% !important;
    }

    .bulk-actions {
        flex-direction: column;
        width: 100%;
    }

    .bulk-actions button {
        width: 100%;
    }
}

@media (max-width: 768px) {
    .header {
        flex-direction: column;
        align-items: center;
        padding: 15px;
        gap: 15px;
    }

    .header-logo {
        width: 100%;
        justify-content: center;
    }

    .navbar-title {
        padding-left: 0;
        text-align: center;
    }

    .header nav {
        width: 100%;
        justify-content: center;
        padding-bottom: 5px;
    }

    .search-box {
        flex-direction: column;
    }

    .search-box button {
        width: 100%;
    }

    .result-card-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }

    .search-type-selector {
        flex-wrap: wrap;
        justify-content: center;
    }
}

@media (max-width: 480px) {
    .header h1 {
        font-size: 18px;
    }

    .navbar-title {
        font-size: 16px;
    }

    .search-section h2 {
        font-size: 22px;
    }

    .login-container {
        padding: 25px 20px;
    }

    .btn {
        width: 100%;
        text-align: center;
        justify-content: center;
    }

    .result-actions {
        flex-direction: column;
    }
}

/* Sanskrit Toggle Styles */
.sanskrit-toggle-container {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 15px;
    background: #f8f9ff;
    padding: 8px 15px;
    border-radius: 8px;
    border: 1px solid #eef0ff;
}

.sanskrit-toggle-container label {
    font-size: 14px;
    font-weight: 600;
    color: var(--primary-color);
    cursor: pointer;
}

.switch {
    position: relative;
    display: inline-block;
    width: 40px;
    height: 20px;
}

.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #ccc;
    transition: .4s;
}

.slider:before {
    position: absolute;
    content: "";
    height: 16px;
    width: 16px;
    left: 2px;
    bottom: 2px;
    background-color: white;
    transition: .4s;
}

input:checked+.slider {
    background-color: var(--primary-color);
}

input:focus+.slider {
    box-shadow: 0 0 1px var(--primary-color);
}

input:checked+.slider:before {
    transform: translateX(20px);
}

.slider.round {
    border-radius: 20px;
}

.slider.round:before {
    border-radius: 50%;
}