/* Authentication Styles */
.auth-container {
    position: fixed;
    top: 1rem;
    right: 1rem;
    z-index: 9999;
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 10px;
    font-family: 'Vazirmatn', sans-serif;
}

.auth-section {
    display: flex;
    gap: 8px;
    align-items: center;
    position: relative;
}

.auth-icon-button {
    background-color: rgba(255, 255, 255, 0.15);
    color: white;
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    backdrop-filter: blur(5px);
    -webkit-backdrop-filter: blur(5px);
}

.auth-icon-button:hover {
    background-color: rgba(255, 255, 255, 0.25);
    transform: translateY(-1px);
}

.dark-theme .auth-icon-button {
    background-color: rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

/* User Menu */
.user-menu {
    position: absolute;
    top: 100%;
    right: 0;
    margin-top: 8px;
    background-color: white;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    min-width: 200px;
    max-width: 280px;
    padding: 8px;
    opacity: 1;
    transform: translateY(0);
    transition: all 0.2s ease;
    direction: rtl;
    text-align: right;
    z-index: 9990;
}

.user-menu.hidden {
    opacity: 0;
    transform: translateY(-10px);
    pointer-events: none;
}

.dark-theme .user-menu {
    background-color: var(--card-bg-dark);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.user-menu .user-info {
    padding: 8px 12px;
    border-bottom: 1px solid rgba(0, 0, 0, 0.1);
    margin-bottom: 8px;
    word-break: break-word;
    overflow-wrap: break-word;
    max-width: 100%;
}

.dark-theme .user-menu .user-info {
    border-bottom-color: rgba(255, 255, 255, 0.1);
}

#user-email {
    display: block;
    max-width: 100%;
    overflow-wrap: break-word;
    word-break: break-word;
    font-size: 0.9rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    border-radius: 4px;
    padding: 2px 4px;
    background-color: rgba(0, 0, 0, 0.03);
    transition: all 0.3s ease;
}

#user-email:hover {
    white-space: normal;
    background-color: rgba(0, 0, 0, 0.05);
    cursor: default;
}

.dark-theme #user-email {
    background-color: rgba(255, 255, 255, 0.1);
}

.dark-theme #user-email:hover {
    background-color: rgba(255, 255, 255, 0.15);
}

.user-menu .menu-item {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    padding: 8px 12px;
    border: none;
    background: none;
    color: var(--text-color);
    font-family: inherit;
    font-size: 0.9rem;
    text-align: right;
    cursor: pointer;
    border-radius: 4px;
    transition: background-color 0.2s ease;
}

.user-menu .menu-item:hover {
    background-color: rgba(0, 0, 0, 0.05);
}

.dark-theme .user-menu .menu-item {
    color: var(--text-color-dark);
}

.dark-theme .user-menu .menu-item:hover {
    background-color: rgba(255, 255, 255, 0.05);
}

/* Modal Styles */
.auth-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    opacity: 1;
    visibility: visible;
    transition: opacity 0.3s ease, visibility 0.3s ease;
    direction: rtl;
}

.auth-modal.hidden {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

.auth-modal-content {
    background-color: white;
    border-radius: 12px;
    padding: 24px;
    width: 90%;
    max-width: 400px;
    position: relative;
    transform: translateY(0);
    transition: transform 0.3s ease;
    text-align: right;
    direction: rtl;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.3);
}

.auth-modal.hidden .auth-modal-content {
    transform: translateY(-20px);
}

.wide-modal {
    max-width: 600px !important;
    direction: rtl;
    text-align: right;
    width: 95%;
    max-height: 90vh;
    overflow-y: hidden;
    display: flex;
    flex-direction: column;
}

.auth-modal-content.wide-modal h2 {
    margin-bottom: 15px;
    padding-bottom: 10px;
    border-bottom: 1px solid rgba(0,0,0,0.1);
}

.dark-theme .auth-modal-content.wide-modal h2 {
    border-bottom: 1px solid rgba(255,255,255,0.1);
}

.close-modal {
    position: absolute;
    top: 16px;
    left: 16px;
    font-size: 24px;
    cursor: pointer;
    color: #666;
    line-height: 1;
    transition: color 0.2s ease;
}

.close-modal:hover {
    color: #333;
}

.auth-modal h2 {
    margin-bottom: 24px;
    color: var(--primary-light);
    font-size: 1.5rem;
    font-weight: 600;
}

.dark-theme .auth-modal-content {
    background-color: var(--card-bg-dark);
}

.dark-theme .auth-modal h2 {
    color: var(--primary-dark);
}

/* Form Styles */
.auth-form {
    display: flex;
    flex-direction: column;
    gap: 16px;
    direction: rtl;
    text-align: right;
}

.auth-form input {
    padding: 12px;
    border: 1px solid #ddd;
    border-radius: 8px;
    font-size: 1rem;
    font-family: inherit;
    transition: all 0.2s ease;
    text-align: right;
}

.auth-form input[type="email"],
.auth-form input[dir="ltr"] {
    direction: ltr;
    text-align: left;
}

.auth-form input[type="password"] {
    direction: ltr;
}

.auth-form input:focus {
    outline: none;
    border-color: var(--primary-light);
    box-shadow: 0 0 0 2px rgba(28, 78, 76, 0.2);
}

.auth-submit-button {
    padding: 12px;
    background-color: var(--primary-light);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-family: inherit;
    cursor: pointer;
    transition: all 0.2s ease;
}

.auth-submit-button:hover {
    background-color: #17403e;
    transform: translateY(-1px);
}

.auth-switch {
    text-align: center;
    color: #666;
    font-size: 0.9rem;
    margin-top: 8px;
}

.text-button {
    background: none;
    border: none;
    color: var(--primary-light);
    font-family: inherit;
    font-size: inherit;
    padding: 0;
    margin: 0;
    cursor: pointer;
    transition: color 0.2s ease;
}

.text-button:hover {
    color: #17403e;
    text-decoration: underline;
}

.dark-theme .auth-form input {
    background-color: #2C3440;
    border-color: #3D4654;
    color: #E0E0E0;
}

.dark-theme .auth-form input:focus {
    border-color: var(--primary-dark);
    box-shadow: 0 0 0 2px rgba(38, 121, 124, 0.2);
}

.dark-theme .auth-submit-button {
    background-color: var(--primary-dark);
}

.dark-theme .auth-submit-button:hover {
    background-color: #1d5c5f;
}

.dark-theme .auth-switch {
    color: #aaa;
}

.dark-theme .text-button {
    color: var(--primary-dark);
}

.dark-theme .text-button:hover {
    color: #26797c;
}

/* Error Message */
.auth-error {
    background-color: rgba(231, 76, 60, 0.1);
    border: 1px solid #e74c3c;
    color: #e74c3c;
    padding: 12px;
    border-radius: 8px;
    font-size: 0.9rem;
    text-align: center;
    margin-top: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.dark-theme .auth-error {
    background-color: rgba(231, 76, 60, 0.2);
}

/* Notification */
.auth-notification {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    background-color: #2ecc71;
    color: white;
    padding: 12px 25px;
    border-radius: 8px;
    font-size: 0.9rem;
    z-index: 10000;
    opacity: 0;
    transition: transform 0.3s ease, opacity 0.3s ease;
    text-align: center;
    box-shadow: 0 3px 10px rgba(0, 0, 0, 0.2);
}

.auth-notification.show {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
}

/* History Styles */
.history-item {
    background-color: white;
    border-radius: 8px;
    padding: 15px;
    margin-bottom: 10px;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    border: 1px solid rgba(0,0,0,0.06);
}

.dark-theme .history-item {
    background-color: #2d3748;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(255,255,255,0.06);
}

.history-item:hover {
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
    transform: translateY(-2px);
}

.history-query {
    font-weight: bold;
    font-size: 1.1rem;
    margin-bottom: 8px;
    color: #2c5282;
    cursor: pointer;
}

.dark-theme .history-query {
    color: #90cdf4;
}

.history-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    font-size: 0.85rem;
    color: #718096;
    margin-bottom: 8px;
}

.dark-theme .history-meta {
    color: #cbd5e0;
}

.history-date, .history-method, .history-count {
    background-color: #f7fafc;
    padding: 2px 8px;
    border-radius: 4px;
}

.dark-theme .history-date,
.dark-theme .history-method,
.dark-theme .history-count {
    background-color: #4a5568;
}

.empty-history {
    text-align: center;
    color: #718096;
    padding: 20px;
}

.error-message {
    text-align: center;
    padding: 20px;
    color: #e74c3c;
}

/* Helper Classes */
.hidden {
    display: none !important;
}

/* Loading Dots */
.loading-dots {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
    padding: 20px;
}

.loading-dots div {
    width: 8px;
    height: 8px;
    background-color: var(--primary-light);
    border-radius: 50%;
    animation: bounce 0.5s infinite alternate;
}

.loading-dots div:nth-child(2) {
    animation-delay: 0.2s;
}

.loading-dots div:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes bounce {
    to {
        transform: translateY(-8px);
    }
}

.dark-theme .loading-dots div {
    background-color: var(--primary-dark);
}

/* Responsive Styles */
@media (max-width: 768px) {
    .auth-container {
        top: 0.5rem;
        right: 0.5rem;
    }
    
    .auth-icon-button {
        width: 36px;
        height: 36px;
        padding: 6px;
    }
    
    .user-menu {
        min-width: 180px;
        right: 0;
        left: auto;
    }
    
    .auth-modal-content.wide-modal {
        width: 95%;
        max-width: 95%;
        padding: 15px;
        height: auto;
        max-height: 85vh;
    }
    
    .auth-form input {
        text-align: right;
        direction: rtl;
    }
    
    .auth-form input[type="email"] {
        direction: ltr;
        text-align: left;
    }
    
    .history-item {
        padding: 12px;
    }
    
    .history-query {
        font-size: 0.95rem;
        line-height: 1.4;
    }
    
    .history-meta {
        flex-direction: column;
        gap: 5px;
    }
}

/* History Modal Specific Styles */
#search-history-container {
    padding: 10px;
    max-height: 70vh;
    overflow-y: auto;
    scrollbar-width: thin;
    -webkit-overflow-scrolling: touch;
}

#search-history-container::-webkit-scrollbar {
    width: 6px;
}

#search-history-container::-webkit-scrollbar-track {
    background: rgba(0,0,0,0.05);
    border-radius: 10px;
}

#search-history-container::-webkit-scrollbar-thumb {
    background: rgba(0,0,0,0.15);
    border-radius: 10px;
}

.dark-theme #search-history-container::-webkit-scrollbar-track {
    background: rgba(255,255,255,0.05);
}

.dark-theme #search-history-container::-webkit-scrollbar-thumb {
    background: rgba(255,255,255,0.15);
}

.info-message {
    background-color: rgba(25, 118, 210, 0.1);
    border: 1px solid rgba(25, 118, 210, 0.5);
    color: #1976d2;
    padding: 12px;
    border-radius: 8px;
    font-size: 0.9rem;
    text-align: center;
    margin: 10px 0;
}

.dark-theme .info-message {
    background-color: rgba(33, 150, 243, 0.1);
    border-color: rgba(33, 150, 243, 0.3);
    color: #42a5f5;
}

.dev-notice, .fallback-notice {
    text-align: center;
    color: #666;
    font-size: 0.85rem;
    margin: 15px 0 5px;
    font-style: italic;
}

.dark-theme .dev-notice, 
.dark-theme .fallback-notice {
    color: #aaa;
}

.fallback-notice {
    color: #1976d2;
    background-color: rgba(25, 118, 210, 0.05);
    padding: 5px;
    border-radius: 4px;
}

.dark-theme .fallback-notice {
    color: #42a5f5;
    background-color: rgba(33, 150, 243, 0.05);
}

/* Improved history-details-modal */
.history-details-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.7);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 10001; /* Higher than auth-modal */
    opacity: 0;
    transition: opacity 0.3s ease;
    -webkit-backdrop-filter: blur(3px);
    backdrop-filter: blur(3px);
    visibility: hidden;
}

.history-details-modal.show {
    opacity: 1;
    visibility: visible;
}

.history-details-content {
    background-color: white;
    border-radius: 10px;
    width: 90%;
    max-width: 500px;
    max-height: 80vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    direction: rtl;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.3);
    animation: modalSlideIn 0.3s ease;
}

.history-details-body {
    padding: 20px;
    overflow-y: auto;
    flex: 1;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
}

.history-details-body::-webkit-scrollbar {
    width: 6px;
}

.history-details-body::-webkit-scrollbar-track {
    background: rgba(0,0,0,0.05);
    border-radius: 10px;
}

.history-details-body::-webkit-scrollbar-thumb {
    background: rgba(0,0,0,0.15);
    border-radius: 10px;
}

.dark-theme .history-details-body::-webkit-scrollbar-track {
    background: rgba(255,255,255,0.05);
}

.dark-theme .history-details-body::-webkit-scrollbar-thumb {
    background: rgba(255,255,255,0.15);
}

.history-details-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 20px;
    border-bottom: 1px solid #e2e8f0;
    background-color: #f8fafc;
    border-radius: 10px 10px 0 0;
}

.dark-theme .history-details-header {
    border-bottom: 1px solid #4a5568;
    background-color: #1a202c;
}

.history-details-header h3 {
    margin: 0;
    font-size: 1.2rem;
    color: #2d3748;
}

.dark-theme .history-details-header h3 {
    color: #f7fafc;
}

.history-details-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: #4a5568;
    transition: color 0.2s;
}

.history-details-close:hover {
    color: #e53e3e;
}

.dark-theme .history-details-close {
    color: #e2e8f0;
}

.dark-theme .history-details-close:hover {
    color: #fc8181;
}

.history-details-item {
    margin-bottom: 15px;
    padding-bottom: 10px;
    border-bottom: 1px solid #edf2f7;
}

.dark-theme .history-details-item {
    border-bottom: 1px solid #4a5568;
}

.history-details-item:last-child {
    border-bottom: none;
    margin-bottom: 0;
    padding-bottom: 0;
}

.history-details-label {
    display: block;
    font-weight: bold;
    margin-bottom: 5px;
    color: #4a5568;
    font-size: 0.9rem;
}

.dark-theme .history-details-label {
    color: #a0aec0;
}

.history-details-value {
    display: block;
    word-break: break-word;
}

.history-details-value.query {
    font-weight: bold;
    font-size: 1.1rem;
    color: #2c5282;
    padding: 5px;
    background-color: #ebf8ff;
    border-radius: 4px;
}

.dark-theme .history-details-value.query {
    color: #90cdf4;
    background-color: #2a4365;
}

.history-details-footer {
    padding: 15px 20px;
    text-align: center;
    border-top: 1px solid #e2e8f0;
    background-color: #f8fafc;
    border-radius: 0 0 10px 10px;
}

.dark-theme .history-details-footer {
    border-top: 1px solid #4a5568;
    background-color: #1a202c;
}

.history-search-again-btn {
    background-color: #4299e1;
    color: white;
    border: none;
    border-radius: 6px;
    padding: 10px 20px;
    font-family: 'Vazir', sans-serif;
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    transition: background-color 0.3s, transform 0.2s;
    box-shadow: 0 2px 5px rgba(66, 153, 225, 0.3);
}

.history-search-again-btn:hover {
    background-color: #3182ce;
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(66, 153, 225, 0.4);
}

.history-search-again-btn:active {
    transform: translateY(0);
}

.history-actions {
    margin-top: 10px;
    display: flex;
    justify-content: flex-end;
}

.search-again-btn {
    display: flex;
    align-items: center;
    gap: 5px;
    background-color: #4299e1;
    color: white;
    border: none;
    border-radius: 4px;
    padding: 5px 10px;
    font-size: 0.85rem;
    font-family: 'Vazir', 'Tahoma', sans-serif;
    cursor: pointer;
    transition: all 0.3s;
    box-shadow: 0 1px 3px rgba(66, 153, 225, 0.2);
}

.search-again-btn:hover {
    background-color: #3182ce;
    transform: translateY(-1px);
    box-shadow: 0 2px 5px rgba(66, 153, 225, 0.3);
}

.search-again-btn svg {
    width: 16px;
    height: 16px;
}

/* Forgot Password Styles */
.forgot-password-section {
    text-align: center;
    margin-top: 10px;
}

.forgot-password-btn {
    color: #4a5568;
    font-size: 0.85rem;
    transition: color 0.2s;
}

.forgot-password-btn:hover {
    color: #3182ce;
}

.dark-theme .forgot-password-btn {
    color: #a0aec0;
}

.dark-theme .forgot-password-btn:hover {
    color: #63b3ed;
} 