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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
    min-height: 100vh;
    color: #333;
}

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

.loading-overlay.show {
    display: flex;
}

.loading-overlay.hidden {
    display: none;
}

.loading-spinner {
    width: 50px;
    height: 50px;
    border: 4px solid rgba(255, 255, 255, 0.3);
    border-top: 4px solid #007AFF;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 20px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Authentication Styles */
.auth-container {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.auth-view {
    display: none;
    max-width: 400px;
    width: 100%;
}

.auth-view.active {
    display: block;
}

.auth-content {
    background: white;
    border-radius: 20px;
    padding: 40px 30px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
}

/* App Header in Auth */
.app-header {
    text-align: center;
    margin-bottom: 40px;
}

.app-icon {
    font-size: 60px;
    color: #007AFF;
    margin-bottom: 15px;
}

.app-title {
    font-size: 28px;
    font-weight: bold;
    color: #333;
    margin-bottom: 8px;
}

.app-subtitle {
    font-size: 16px;
    color: #666;
}

/* Auth Header */
.auth-header {
    display: flex;
    align-items: center;
    margin-bottom: 30px;
    position: relative;
}

.back-button {
    background: none;
    border: none;
    font-size: 18px;
    color: #007AFF;
    cursor: pointer;
    position: absolute;
    left: 0;
}

.auth-header h2 {
    font-size: 24px;
    font-weight: bold;
    margin: 0 auto;
}

/* Form Styles */
.auth-form {
    margin-bottom: 30px;
}

.input-group {
    margin-bottom: 16px;
}

.input-group input {
    width: 100%;
    padding: 16px;
    border: 1px solid #ddd;
    border-radius: 12px;
    font-size: 16px;
    background: #f8f9fa;
    transition: all 0.2s ease;
}

.input-group input:focus {
    outline: none;
    border-color: #007AFF;
    background: white;
    box-shadow: 0 0 0 3px rgba(0, 122, 255, 0.1);
}

/* Buttons */
.primary-button {
    width: 100%;
    padding: 16px;
    background: #007AFF;
    color: white;
    border: none;
    border-radius: 12px;
    font-size: 18px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
}

.primary-button:hover {
    background: #0056b3;
    transform: translateY(-2px);
}

.primary-button:disabled {
    background: #ccc;
    cursor: not-allowed;
    transform: none;
}

.secondary-button {
    padding: 12px 20px;
    background: #f0f0f0;
    color: #333;
    border: none;
    border-radius: 10px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 8px;
}

.secondary-button:hover {
    background: #e0e0e0;
}

.danger-button {
    padding: 12px 20px;
    background: #ff3b30;
    color: white;
    border: none;
    border-radius: 10px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.danger-button:hover {
    background: #d70015;
}

.text-button {
    background: none;
    border: none;
    color: #007AFF;
    font-size: 14px;
    cursor: pointer;
    text-decoration: underline;
}

.text-button:hover {
    color: #0056b3;
}

.button-spinner {
    margin-left: 10px;
}

.button-spinner.hidden {
    display: none;
}

/* Auth Actions */
.auth-actions {
    text-align: center;
}

.auth-switch {
    margin-top: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.auth-switch-text {
    font-size: 14px;
    color: #666;
}

/* Messages */
.error-message {
    color: #ff3b30;
    font-size: 14px;
    margin: 10px 0;
    text-align: center;
    padding: 10px;
    background: #ff3b30;
    background: rgba(255, 59, 48, 0.1);
    border-radius: 8px;
}

.error-message:empty {
    display: none;
}

.success-message {
    color: #34c759;
    font-size: 14px;
    margin: 10px 0;
    text-align: center;
    padding: 10px;
    background: rgba(52, 199, 89, 0.1);
    border-radius: 8px;
}

.success-message:empty {
    display: none;
}

/* Main App Styles */
.app-container {
    min-height: 100vh;
    max-width: 600px;
    margin: 0 auto;
    background: white;
    box-shadow: 0 0 20px rgba(0, 0, 0, 0.1);
}

.app-container.hidden {
    display: none;
}

.app-header-nav {
    background: white;
    padding: 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid #f0f0f0;
}

.app-header-nav h1 {
    font-size: 20px;
    font-weight: 600;
    color: #333;
}

.profile-button {
    background: none;
    border: none;
    font-size: 24px;
    color: #007AFF;
    cursor: pointer;
}

/* Main Content */
.main-content {
    padding: 20px;
}

.app-intro {
    text-align: center;
    margin-bottom: 40px;
}

.app-intro .app-icon {
    font-size: 60px;
    color: #007AFF;
    margin-bottom: 15px;
}

.main-title {
    font-size: 32px;
    font-weight: bold;
    color: #333;
    margin-bottom: 8px;
}

.main-subtitle {
    font-size: 16px;
    color: #666;
    margin-bottom: 15px;
}

.welcome-message {
    font-size: 14px;
    color: #666;
}

/* Upload Section */
.upload-section {
    margin-bottom: 20px;
}

.upload-placeholder {
    border: 2px dashed #ccc;
    border-radius: 16px;
    padding: 40px 20px;
    text-align: center;
    background: #f8f9fa;
    transition: all 0.2s ease;
}

.upload-placeholder:hover {
    border-color: #007AFF;
    background: #f0f8ff;
}

.upload-content {
    margin-bottom: 20px;
}

.upload-icon {
    font-size: 50px;
    color: #ccc;
    margin-bottom: 15px;
}

.upload-content h3 {
    font-size: 18px;
    color: #333;
    margin-bottom: 8px;
}

.upload-content p {
    font-size: 14px;
    color: #666;
}

/* Image Preview */
.image-preview {
    text-align: center;
    margin-bottom: 20px;
}

.image-preview.hidden {
    display: none;
}

.image-preview img {
    max-width: 100%;
    max-height: 300px;
    border-radius: 12px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    margin-bottom: 16px;
}

.image-actions {
    display: flex;
    justify-content: center;
    gap: 12px;
}

/* Analyze Section */
.analyze-section {
    text-align: center;
}

.analyze-section.hidden {
    display: none;
}

.analyze-button {
    width: 100%;
    padding: 18px;
    background: #007AFF;
    color: white;
    border: none;
    border-radius: 12px;
    font-size: 18px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
}

.analyze-button:hover {
    background: #0056b3;
    transform: translateY(-2px);
}

.analyze-button:disabled {
    background: #ccc;
    cursor: not-allowed;
    transform: none;
}

/* Results Section */
.results-section {
    margin-top: 20px;
}

.results-section.hidden {
    display: none;
}

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

.result-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 12px;
}

.result-icon {
    font-size: 40px;
}

.result-icon.safe {
    color: #34c759;
}

.result-icon.scam {
    color: #ff3b30;
}

.result-content {
    flex: 1;
}

.result-title {
    font-size: 20px;
    font-weight: bold;
    margin-bottom: 4px;
}

.result-title.safe {
    color: #34c759;
}

.result-title.scam {
    color: #ff3b30;
}

.result-confidence {
    font-size: 14px;
    color: #666;
}

.result-confidence strong {
    color: #333;
}

.result-details {
    margin-top: 16px;
}

.result-section {
    margin-bottom: 20px;
}

.result-section-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
}

.result-section-header i {
    color: #007AFF;
}

.result-section-header h3 {
    font-size: 16px;
    color: #333;
}

.result-section-content {
    font-size: 14px;
    color: #666;
    line-height: 1.5;
}

.risk-factors {
    list-style: none;
    padding: 0;
}

.risk-factors li {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    margin-bottom: 6px;
    font-size: 14px;
    color: #666;
}

.risk-factors li::before {
    content: "•";
    color: #ff9500;
    font-weight: bold;
    margin-top: 2px;
}

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

.modal.active,
.modal.show {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.modal-content {
    background: white;
    border-radius: 16px;
    max-width: 400px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
}

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

.modal-header h2 {
    font-size: 20px;
    font-weight: 600;
}

.close-button {
    background: none;
    border: none;
    font-size: 18px;
    color: #666;
    cursor: pointer;
}

.modal-body {
    padding: 0 20px 20px;
}

/* Profile Styles */
.profile-info {
    text-align: center;
    margin-bottom: 30px;
}

.profile-avatar {
    font-size: 80px;
    color: #ccc;
    margin-bottom: 16px;
}

.profile-details h3 {
    font-size: 20px;
    font-weight: 600;
    margin-bottom: 4px;
}

.profile-details p {
    font-size: 14px;
    color: #666;
    margin-bottom: 10px;
}

.verification-status {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 500;
}

.verification-status.verified {
    background: rgba(52, 199, 89, 0.1);
    color: #34c759;
}

.verification-status.unverified {
    background: rgba(255, 149, 0, 0.1);
    color: #ff9500;
}

.profile-actions {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

/* Responsive Design */
@media (max-width: 600px) {
    .auth-content {
        padding: 30px 20px;
    }
    
    .app-container {
        box-shadow: none;
    }
    
    .main-content {
        padding: 15px;
    }
    
    .modal-content {
        margin: 20px;
        max-height: calc(100vh - 40px);
    }
}

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

.text-center {
    text-align: center;
}

.mb-4 {
    margin-bottom: 1rem;
}

.mt-4 {
    margin-top: 1rem;
}

/* ==========================
   History Styles
   ========================== */

.header-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}

.icon-button {
    background: none;
    border: none;
    color: #007AFF;
    font-size: 24px;
    cursor: pointer;
    padding: 8px;
    border-radius: 50%;
    transition: background-color 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.icon-button:hover {
    background-color: rgba(0, 122, 255, 0.1);
}

.icon-button:active {
    transform: scale(0.95);
}

.modal-wide {
    max-width: 800px !important;
}

.modal-small {
    max-width: 400px !important;
}

.history-content {
    min-height: 300px;
    max-height: 60vh;
    overflow-y: auto;
}

.history-item {
    display: flex;
    align-items: center;
    padding: 16px;
    background: white;
    border: 1px solid #e0e0e0;
    border-radius: 12px;
    margin-bottom: 12px;
    transition: all 0.2s;
}

.history-item:hover {
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    border-color: #007AFF;
}

.history-item-content {
    display: flex;
    align-items: center;
    flex: 1;
    cursor: pointer;
    min-width: 0;
}

.history-item-icon {
    font-size: 24px;
    width: 48px;
    height: 48px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    margin-right: 12px;
}

.history-item-thumbnail {
    width: 64px;
    height: 64px;
    border-radius: 8px;
    overflow: hidden;
    flex-shrink: 0;
    margin-right: 12px;
    background: #f5f5f5;
}

.history-item-thumbnail img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.history-item-icon.scam {
    background: rgba(220, 53, 69, 0.1);
    color: #dc3545;
}

.history-item-icon.safe {
    background: rgba(40, 167, 69, 0.1);
    color: #28a745;
}

.history-item-details {
    flex: 1;
    min-width: 0;
}

.history-item-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 4px;
    flex-wrap: wrap;
    gap: 8px;
}

.history-item-status {
    font-weight: 600;
    font-size: 14px;
}

.history-item-status.scam {
    color: #dc3545;
}

.history-item-status.safe {
    color: #28a745;
}

.history-item-confidence {
    font-weight: 600;
    font-size: 14px;
}

.history-item-date {
    font-size: 12px;
    color: #6c757d;
    margin-bottom: 4px;
}

.history-item-preview {
    font-size: 13px;
    color: #495057;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.history-item-delete {
    background: none;
    border: none;
    color: #dc3545;
    font-size: 18px;
    cursor: pointer;
    padding: 8px;
    border-radius: 50%;
    transition: background-color 0.2s;
    flex-shrink: 0;
    margin-left: 8px;
}

.history-item-delete:hover {
    background-color: rgba(220, 53, 69, 0.1);
}

.history-item-delete:active {
    transform: scale(0.95);
}

.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: #6c757d;
}

.empty-state-icon {
    font-size: 64px;
    color: #dee2e6;
    margin-bottom: 20px;
}

.empty-state h3 {
    font-size: 20px;
    font-weight: 600;
    margin-bottom: 8px;
    color: #495057;
}

.empty-state p {
    font-size: 14px;
    color: #6c757d;
}

.loading-state {
    text-align: center;
    padding: 60px 20px;
    color: #6c757d;
}

.loading-icon {
    font-size: 48px;
    color: #007AFF;
    margin-bottom: 16px;
}

.error-state {
    text-align: center;
    padding: 60px 20px;
    color: #6c757d;
}

.error-icon {
    font-size: 64px;
    color: #dc3545;
    margin-bottom: 20px;
}

.error-state h3 {
    font-size: 20px;
    font-weight: 600;
    margin-bottom: 8px;
    color: #495057;
}

.error-state p {
    font-size: 14px;
    color: #6c757d;
    margin-bottom: 20px;
}

.history-detail-content {
    padding: 8px 0;
}

.modal-actions {
    display: flex;
    gap: 12px;
    margin-top: 24px;
    justify-content: flex-end;
}

.modal-actions button {
    flex: 1;
    max-width: 150px;
}

/* Mobile Responsiveness for History */
@media (max-width: 768px) {
    .modal-wide {
        max-width: 95% !important;
    }

    .history-item {
        padding: 12px;
    }

    .history-item-icon {
        width: 40px;
        height: 40px;
        font-size: 20px;
    }

    .history-item-status {
        font-size: 13px;
    }

    .history-item-confidence {
        font-size: 13px;
    }

    .history-item-preview {
        font-size: 12px;
    }

    .modal-actions button {
        max-width: none;
    }
}