:root {
    --primary-color: #d4af37;
    /* Golden */
    --primary-hover: #b8860b;
    --bg-color: #0d1117;
    --card-bg: rgba(22, 27, 34, 0.8);
    --text-color: #f0f6fc;
    --text-secondary: #8b949e;
    --success-color: #238636;
    --danger-color: #da3633;
}

body {
    background-color: var(--bg-color);
    color: var(--text-color);
    font-family: 'Inter', 'Segoe UI', sans-serif;
    min-height: 100vh;
    overflow-x: hidden;
    /* Prevent horizontal scroll */
    background-image:
        radial-gradient(at 0% 0%, rgba(212, 175, 55, 0.08) 0px, transparent 50%),
        radial-gradient(at 100% 0%, rgba(184, 134, 11, 0.08) 0px, transparent 50%);
}

/* Fix Modal Layout Shift */
body.modal-open {
    padding-right: 0 !important;
    padding-left: 0 !important;
    overflow: hidden;
}

.glass-card {
    background: var(--card-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 16px;
    box-shadow: 0 4px 30px rgba(0, 0, 0, 0.1);
}

.form-control {
    background-color: rgba(0, 0, 0, 0.4);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: #ffffff !important;
    padding: 0.75rem 1rem;
    border-radius: 8px;
}

.form-control::placeholder {
    color: rgba(255, 255, 255, 0.6) !important;
}

.form-control:focus {
    background-color: rgba(0, 0, 0, 0.6);
    border-color: var(--primary-color);
    color: white;
    box-shadow: 0 0 0 4px rgba(212, 175, 55, 0.1);
}

/* Login Page Specifics */
.logo-container {
    display: flex;
    justify-content: center;
    align-items: center;
}

.login-logo {
    width: 130px;
    height: 130px;
    object-fit: contain;
    /* Ensure full logo is visible */
    background: #000;
    border: 2px solid var(--primary-color);
    padding: 2px;
}

/* Custom Input Group with Icons */
.input-group-custom {
    position: relative;
    display: flex;
    align-items: center;
    width: 100%;
}

.input-icon {
    position: absolute;
    right: 16px;
    top: 50%;
    transform: translateY(-50%);
    color: rgba(255, 255, 255, 0.5);
    z-index: 10;
    pointer-events: none;
    display: flex;
    align-items: center;
    justify-content: center;
}

.input-group-custom .form-control {
    padding-right: 48px;
    padding-left: 16px;
    width: 100%;
}

.input-group-custom .password-input {
    padding-left: 50px;
}

.toggle-password-btn {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    background: transparent;
    border: none;
    color: rgba(255, 255, 255, 0.5);
    cursor: pointer;
    padding: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    border-radius: 6px;
    z-index: 10;
}

.toggle-password-btn:hover {
    color: rgba(255, 255, 255, 0.9);
    background: rgba(255, 255, 255, 0.1);
}

.toggle-password-btn:focus {
    outline: none;
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.2);
}

/* Mobile Responsive */
@media (max-width: 576px) {
    .input-icon {
        right: 12px;
    }

    .input-group-custom .form-control {
        padding-right: 42px;
        padding-left: 12px;
        font-size: 16px;
        /* Prevents zoom on iOS */
    }

    .input-group-custom .password-input {
        padding-left: 44px;
    }

    .toggle-password-btn {
        left: 8px;
    }

    .glass-card {
        padding: 2rem !important;
    }
}

.btn-primary {
    background-color: var(--primary-color);
    border: none;
    padding: 0.75rem 1.5rem;
    border-radius: 8px;
    font-weight: 500;
    transition: all 0.3s ease;
}

.btn-primary:hover {
    background-color: var(--primary-hover);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3);
}

.btn-success {
    background-color: var(--success-color);
    border: none;
}

.btn-danger {
    background-color: var(--danger-color);
    border: none;
}

.table {
    color: var(--text-color);
    border-color: rgba(255, 255, 255, 0.1);
}

.table thead th {
    background-color: rgba(15, 23, 42, 0.5);
    color: var(--text-secondary);
    border-bottom: 2px solid rgba(255, 255, 255, 0.1);
}

.table td {
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.status-dot {
    height: 12px;
    width: 12px;
    border-radius: 50%;
    display: inline-block;
    box-shadow: 0 0 10px currentColor;
}

.status-online {
    color: var(--success-color);
    background-color: currentColor;
}

.status-offline {
    color: var(--danger-color);
    background-color: currentColor;
}

#qr-container canvas {
    border-radius: 10px;
    border: 5px solid white;
}

.navbar {
    background: rgba(15, 23, 42, 0.8) !important;
    backdrop-filter: blur(10px);
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.navbar-brand {
    font-weight: 700;
    letter-spacing: 0.5px;
}

/* Animations */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.animate-fade-in {
    animation: fadeIn 0.5s ease-out;
}

/* Main Content Layout */
.main-content {
    margin-right: 100px;
    transition: margin-right 0.3s ease;
}


@media (max-width: 992px) {
    .main-content {
        margin-right: 0 !important;
    }
}

/* --- Instructions Page Styles (Restored from Backup) --- */

.instruction-item {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    padding: 1.25rem;
    margin-bottom: 1rem;
    transition: all 0.3s;
}

.instruction-item:hover {
    background: rgba(255, 255, 255, 0.05);
    border-color: var(--primary-color);
    transform: translateX(-3px);
}

.instruction-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    flex-wrap: wrap;
    gap: 0.5rem;
}

.instruction-content {
    background: rgba(0, 0, 0, 0.2);
    padding: 1rem;
    border-radius: 8px;
    color: #cbd5e1;
    font-size: 0.95rem;
    line-height: 1.6;
    white-space: pre-wrap;
    max-height: 200px;
    overflow-y: auto;
}

.instruction-content::-webkit-scrollbar {
    width: 6px;
}

.instruction-content::-webkit-scrollbar-track {
    background: transparent;
}

.instruction-content::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.2);
    border-radius: 3px;
}

/* Gallery Styles */
.instruction-preview-gallery {
    display: flex;
    gap: 10px;
    margin-top: 10px;
    overflow-x: auto;
    padding-bottom: 5px;
}

.instruction-image {
    width: 80px;
    height: 80px;
    object-fit: cover;
    border-radius: 8px;
    border: 2px solid rgba(255, 255, 255, 0.1);
    cursor: pointer;
    transition: transform 0.3s;
}

.instruction-image:hover {
    transform: scale(1.05);
    border-color: var(--primary-color);
}

.border-dashed {
    border: 2px dashed rgba(255, 255, 255, 0.2) !important;
    background: transparent;
    transition: all 0.3s;
}

.border-dashed:hover {
    border-color: var(--primary-color) !important;
    background: rgba(255, 255, 255, 0.05);
}

.gallery-item {
    background: rgba(0, 0, 0, 0.3);
    border-radius: 8px;
    padding: 10px;
    position: relative;
    border: 1px solid rgba(255, 255, 255, 0.1);
    display: flex;
    align-items: center;
    gap: 15px;
}

.gallery-thumb {
    width: 60px;
    height: 60px;
    object-fit: cover;
    border-radius: 6px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    flex-shrink: 0;
}

.action-buttons {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.badge-container {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.success-msg {
    position: fixed;
    top: 100px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 1060;
    animation: slideDown 0.5s ease;
    width: 90%;
    max-width: 400px;
    text-align: center;
}

@keyframes slideDown {
    from {
        top: 50px;
        opacity: 0;
    }

    to {
        top: 100px;
        opacity: 1;
    }
}

/* Modal Mobile Fixes (Preserved and adjusted) */
body.modal-open {
    padding-right: 0 !important;
    padding-left: 0 !important;
    overflow: hidden;
}

@media (max-width: 576px) {
    .modal-dialog {
        margin: 0.5rem;
    }

    .modal-content {
        border-radius: 12px;
    }

    .modal-body {
        padding: 1rem;
    }

    .instruction-item {
        padding: 1rem;
    }

    /* Change to ROW layout so badges and dropdown are on the same line */
    .instruction-header {
        flex-direction: row;
        align-items: center;
        justify-content: space-between;
    }

    /* Reset action buttons styles as they are now desktop-only or handled differently */
    .action-buttons {
        width: auto;
        margin-top: 0;
    }

    .gallery-item {
        flex-direction: column;
        align-items: stretch;
    }

    .gallery-thumb {
        width: 100%;
        height: 150px;
    }
}

@media (min-width: 768px) {
    .badge-container {
        gap: 0.75rem;
    }

    .badge.bg-success {
        font-size: 0.9rem;
        padding: 0.5rem 1rem !important;
    }
}

/* Desktop Layout - Restored from Backup */
@media (min-width: 992px) {
    .glass-card {
        max-width: 1200px;
        margin: 0 auto;
    }
}

/* Premium User Button */
.btn-user-premium {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(212, 175, 55, 0.2);
    border-radius: 50px;
    padding: 6px 16px 6px 8px;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    color: white;
}

.btn-user-premium:hover {
    background: rgba(212, 175, 55, 0.1);
    border-color: var(--primary-color);
}

.user-avatar-small {
    width: 28px;
    height: 28px;
    background: var(--primary-color);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #000;
    margin-left: 8px;
    /* Correct for RTL: circle on the left of text */
}

.animate-slide-in {
    animation: slideInNav 0.3s ease-out;
}

@keyframes slideInNav {
    from {
        transform: translateY(10px);
        opacity: 0;
    }

    to {
        transform: translateY(0);
        opacity: 1;
    }
}

/* Global Layout Styles */
.main-content {
    margin-right: 70px;
    padding-top: 100px;
    padding-bottom: 50px;
    transition: all 0.5s ease;
}

@media (max-width: 992px) {
    .main-content {
        margin-right: 0;
        padding-top: 80px;
        padding-bottom: 30px;
    }
}

/* Helper Info Icons & Popovers */
.info-btn {
    cursor: pointer;
    color: var(--primary-color);
    opacity: 0.6;
    transition: all 0.3s;
    margin-right: 8px;
    /* Offset in RTL */
    font-size: 0.95rem;
    background: rgba(212, 175, 55, 0.1);
    padding: 2px 8px;
    border-radius: 50%;
    border: 1px solid rgba(212, 175, 55, 0.2);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    vertical-align: middle;
}

.info-btn:hover {
    opacity: 1;
    transform: scale(1.1);
    background: rgba(212, 175, 55, 0.2);
}

.popover {
    --bs-popover-bg: #1e293b;
    --bs-popover-border-color: rgba(212, 175, 55, 0.3);
    --bs-popover-header-bg: rgba(212, 175, 55, 0.1);
    --bs-popover-header-color: #d4af37;
    --bs-popover-body-color: #f0f6fc;
    border-radius: 12px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.4);
    max-width: 320px;
}

.popover-header {
    font-weight: bold;
    border-bottom: 1px solid rgba(212, 175, 55, 0.1);
}

.helper-example-list {
    margin: 0;
    padding: 0;
    list-style: none;
}

.helper-example-list li {
    padding: 6px 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.helper-example-list li:last-child {
    border-bottom: none;
}

/* Dropdown RTL Fixes */
.dropdown-menu {
    border-radius: 12px !important;
    min-width: 180px;
    padding: 8px 0 !important;
}

.dropdown-item {
    transition: all 0.2s ease;
    font-size: 0.95rem;
    padding: 8px 16px !important;
}

.dropdown-item i {
    font-size: 1.1rem;
    color: var(--primary-color);
}

.dropdown-item:hover {
    background: rgba(212, 175, 55, 0.1) !important;
    color: white !important;
}

@media (max-width: 576px) {
    .dropdown-menu {
        position: absolute !important;
        margin-top: 10px !important;
    }
}

/* --- Global Modal Header RTL Fix --- */
.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-direction: row;
    /* Ensure row direction */
}

.modal-header .btn-close {
    margin: 0 !important;
    /* Prevent auto margins from pushing it */
}

/* In RTL, if we want Title on Right and X on Left:
   HTML: Title first, Button second.
   RTL standard flow: Title (Right) -> Button (Left).
   Justify-between pushes them apart.
*/

/* --- Phone Pairing Input Fixes --- */
#countryCode,
#phoneNumberInput {
    height: 50px !important;
    /* Force equal height */
    line-height: normal;
}

#countryCode {
    background-position: left 0.75rem center !important;
    /* Move arrow to left if RTL, or adjust */
    padding-top: 10px;
}

@media (max-width: 576px) {
    #countryCode {
        font-size: 0.85rem !important;
        /* Smaller font to prevent overlap */
        padding-right: 4px !important;
        /* Reduce padding to show text */
        padding-left: 20px !important;
        /* Space for arrow */
    }
}