/* Custom styles go here */
body {
    font-family: 'Arial', sans-serif;
    direction: rtl;
    text-align: right;
}

.navbar {
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
}

/* RTL adjustments */
.navbar-nav {
    margin-right: auto;
    margin-left: 0;
}

.navbar-nav .nav-link {
    margin-left: 0.5em;
    margin-right: 0;
}

form {
    direction: rtl;
    text-align: right;
}

.form-group label {
    text-align: right;
}

.form-control {
    direction: rtl;
}

@media (max-width: 768px) {
    .navbar-brand {
        font-size: 1.2rem;
    }
}

main {
    padding: 20px;
    max-width: 960px;
    margin: 20px auto;
    background-color: #fff;
    box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
}

section {
    margin-bottom: 20px;
}

h2, h3 {
    color: #333;
}

.button {
    display: inline-block;
    background-color: #007bff;
    color: #fff;
    padding: 10px 20px;
    text-decoration: none;
    border-radius: 5px;
    margin-top: 10px;
}

.button:hover {
    background-color: #0056b3;
}

footer {
    text-align: center;
    padding: 20px;
    background-color: #333;
    color: #fff;
    position: relative;
    bottom: 0;
    width: 100%;
}

/* Form styles */
form {
    background-color: #f9f9f9;
    padding: 20px;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

form label {
    display: block;
    margin-bottom: 8px;
    font-weight: bold;
}

form input[type="text"],
form input[type="password"],
form input[type="email"],
form input[type="file"],
form textarea {
    width: calc(100% - 22px);
    padding: 10px;
    margin-bottom: 15px;
    border: 1px solid #ddd;
    border-radius: 4px;
}

form input[type="submit"] {
    background-color: #28a745;
    color: white;
    padding: 10px 20px;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-size: 16px;
}

form input[type="submit"]:hover {
    background-color: #218838;
}

.error-message {
    color: red;
    margin-bottom: 10px;
}

.success-message {
    color: green;
    margin-bottom: 10px;
}

/* Dashboard and Uploads History styles */
.card-list, .upload-list {
    list-style: none;
    padding: 0;
}

.card-list li, .upload-list li {
    background-color: #e9e9e9;
    margin-bottom: 10px;
    padding: 15px;
    border-radius: 5px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.card-list li span, .upload-list li span {
    font-weight: bold;
}

.card-list li .actions, .upload-list li .actions {
    display: flex;
    gap: 10px;
}

.card-list li .actions button, .upload-list li .actions button {
    padding: 8px 12px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
}

.card-list li .actions .view-btn {
    background-color: #17a2b8;
    color: white;
}

.card-list li .actions .view-btn:hover {
    background-color: #138496;
}

.upload-list li .actions .download-btn {
    background-color: #007bff;
    color: white;
}

.upload-list li .actions .download-btn:hover {
    background-color: #0056b3;
}

.upload-list li .actions .download-second-btn {
    background-color: #ffc107;
    color: #333;
}

.upload-list li .actions .download-second-btn:hover {
    background-color: #e0a800;
}

/* Image processing display */
#image-preview-container {
    position: relative;
    margin-top: 20px;
    border: 1px solid #ddd;
    padding: 10px;
    text-align: center;
}

#image-preview {
    max-width: 100%;
    height: auto;
    display: block;
    margin: 0 auto;
}

.bounding-box {
    position: absolute;
    border: 2px solid red;
    box-sizing: border-box;
    cursor: pointer;
}

.bounding-box.highlight {
    border-color: blue;
}

.ocr-text-list {
    margin-top: 20px;
    border-top: 1px solid #eee;
    padding-top: 15px;
}

.ocr-text-list div {
    background-color: #f0f0f0;
    padding: 8px;
    margin-bottom: 5px;
    border-radius: 3px;
}

.ocr-text-list div.matched {
    background-color: #d4edda;
    border: 1px solid #28a745;
}

.ocr-text-list div.matched span {
    font-weight: bold;
    color: #28a745;
}

/* Admin settings */
.settings-form .api-key-entry {
    display: flex;
    align-items: center;
    margin-bottom: 10px;
}

.settings-form .api-key-entry input[type="text"] {
    flex-grow: 1;
    margin-right: 10px;
}

.settings-form .api-key-entry button {
    padding: 8px 12px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    background-color: #dc3545;
    color: white;
}

.settings-form .api-key-entry button:hover {
    background-color: #c82333;
}

.settings-form .add-key-btn {
    background-color: #007bff;
    color: white;
    padding: 10px 15px;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    margin-top: 10px;
}

.settings-form .add-key-btn:hover {
    background-color: #0056b3;
}

.settings-form textarea {
    min-height: 200px;
    font-family: 'Courier New', Courier, monospace;
}

/* --- Pattern Icon Styles --- */
.pattern-container {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: 10px;
    margin-bottom: 20px;
}

.pattern-icon-btn {
    background-color: #f0f0f0;
    border: 2px solid #ddd;
    border-radius: 8px;
    padding: 15px 10px;
    cursor: pointer;
    text-align: center;
    font-weight: bold;
    transition: all 0.2s ease-in-out;
}

.pattern-icon-btn:hover {
    background-color: #e0e0e0;
    border-color: #ccc;
}

.pattern-icon-btn.selected {
    background-color: #d4edda; /* Bootstrap success light */
    border-color: #28a745; /* Bootstrap success */
    color: #155724;
    transform: scale(1.05);
    box-shadow: 0 0 10px rgba(40, 167, 69, 0.5);
}

/* --- Responsive Navbar --- */
@media (max-width: 991.98px) { /* Bootstrap's lg breakpoint */
    .navbar-collapse .navbar-nav {
        flex-direction: row !important;
        justify-content: space-around !important;
        width: 100%;
        margin-top: 1rem;
    }

    .navbar-collapse .nav-item {
        text-align: center;
    }

    .navbar-collapse .nav-link {
        padding: 0.5rem !important;
    }

    .navbar-collapse .nav-link i {
        font-size: 1.5rem !important; /* Larger icons for mobile */
        margin: 0 !important;
    }
}
