/* Base Styles */
body {
    font-family: "Inter", "Segoe UI", Roboto, -apple-system, BlinkMacSystemFont, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    background-size: 400% 400%;
    animation: gradientShift 8s ease-in-out infinite;
    color: #2c3e50;
    line-height: 1.6;
    margin: 0;
    position: relative;
    overflow-x: hidden;
}

/* Fundamental Data Styles */
.fundamental-data {
    border: 1px solid #e3f2fd;
    border-radius: 8px;
    font-size: 0.85rem;
}

.fundamental-data .row {
    margin: 0;
}

.fundamental-data .col-4,
.fundamental-data .col-6 {
    padding: 0.25rem 0.5rem;
    border-right: 1px solid #e9ecef;
}

.fundamental-data .col-4:last-child,
.fundamental-data .col-6:last-child {
    border-right: none;
}

.fundamental-data-compact {
    font-size: 0.75rem;
}

.fundamental-data-compact .col-6 {
    padding: 0.1rem 0.3rem;
    border-right: 1px solid #e9ecef;
}

.fundamental-data-compact .col-6:last-child {
    border-right: none;
}

/* Stock Card Enhancements */

.container {
    max-width: 1100px;
    padding: 1.5rem 1rem;
    margin: 0 auto;
    position: relative;
    z-index: 10;
}

/* Mobile responsive */
@media (max-width: 768px) {
    .container {
        padding: 1rem 0.75rem;
    }
}

/* Floating Elements */
.floating-elements {
    position: fixed;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 1;
    top: 0;
    left: 0;
}

.floating-element {
    position: absolute;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 50%;
    animation: float 6s ease-in-out infinite;
}

.floating-element:nth-child(1) {
    width: 80px;
    height: 80px;
    top: 20%;
    left: 10%;
    animation-delay: 0s;
}

.floating-element:nth-child(2) {
    width: 120px;
    height: 120px;
    top: 60%;
    right: 10%;
    animation-delay: 2s;
}

.floating-element:nth-child(3) {
    width: 60px;
    height: 60px;
    bottom: 20%;
    left: 20%;
    animation-delay: 4s;
}

.floating-element:nth-child(4) {
    width: 100px;
    height: 100px;
    top: 30%;
    right: 20%;
    animation-delay: 1s;
}

.floating-element:nth-child(5) {
    width: 90px;
    height: 90px;
    top: 50%;
    left: 50%;
    animation-delay: 3s;
}

.floating-element:nth-child(6) {
    width: 70px;
    height: 70px;
    bottom: 30%;
    right: 30%;
    animation-delay: 5s;
}

/* Header */
header {
    background: linear-gradient(135deg, #1da1f2 0%, #1da1f2 100%);
    background: linear-gradient(45deg, #ff6b6b, #4ecdc4, #45b7d1, #f9ca24);
    background-size: 400% 400%;
    animation: gradientShift 3s ease-in-out infinite;
    color: white;
    padding: 2rem 0;
    border-bottom: 3px solid #3498db;
    text-align: center;
    box-shadow: 0 4px 20px rgba(0,0,0,0.1);
    position: relative;
    overflow: visible; /* Changed from hidden to visible */
    z-index: 1000; /* High z-index for header */
}

header::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100"><defs><pattern id="grid" width="10" height="10" patternUnits="userSpaceOnUse"><path d="M 10 0 L 0 0 0 10" fill="none" stroke="rgba(255,255,255,0.1)" stroke-width="0.5"/></pattern></defs><rect width="100" height="100" fill="url(%23grid)"/></svg>');
    opacity: 0.3;
}

header h1 {
    font-size: 2.8rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
    position: relative;
    z-index: 1;
    color: #ffffff;
    text-shadow: 0 0 20px rgba(255,255,255,0.8), 
                 2px 2px 4px rgba(0,0,0,0.5);
}

header p {
    font-size: 1.2rem;
    color: #ecf0f1;
    font-weight: 300;
    position: relative;
    z-index: 1;
}

/* Footer */
footer {
    background: linear-gradient(135deg, #1da1f2 0%, #1da1f2 100%);
    background: linear-gradient(45deg, #ff6b6b, #4ecdc4, #45b7d1, #f9ca24);
    background-size: 400% 400%;
    animation: gradientShift 3s ease-in-out infinite;
    color: #ffffff;
    padding: 1.5rem 0;
    font-size: 0.9rem;
    text-align: center;
    box-shadow: 0 -2px 10px rgba(0,0,0,0.1);
    position: relative;
    z-index: 10;
}

/* Form & Alerts */
.form-control, .form-select {
    border: 2px solid #e0e6ed;
    border-radius: 8px;
    padding: 0.75rem 1rem;
    font-size: 1rem;
    transition: all 0.3s ease;
    background-color: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
    position: relative;
    z-index: 10;
}

.form-control:focus, .form-select:focus {
    border-color: #3498db;
    box-shadow: 0 0 0 0.2rem rgba(52, 152, 219, 0.25);
    outline: none;
    background-color: rgba(255, 255, 255, 0.98);
}

form {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    padding: 2rem;
    border-radius: 15px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.1);
    position: relative;
    z-index: 10;
}

form .form-label {
    font-weight: 600;
    color: #2c3e50;
    margin-bottom: 0.5rem;
    font-size: 1rem;
}

.btn-primary {
    background: linear-gradient(135deg, #1da1f2 0%, #1da1f2 100%);
    border: none;
    padding: 0.75rem 2rem;
    font-weight: 600;
    border-radius: 8px;
    box-shadow: 0 4px 15px rgba(52, 152, 219, 0.3);
    transition: all 0.3s ease;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(52, 152, 219, 0.4);
    background: linear-gradient(135deg, #2980b9 0%, #3498db 100%);
}

.alert {
    margin-top: 1.5rem;
    border: none;
    border-radius: 10px;
    padding: 1rem 1.5rem;
    font-weight: 500;
    box-shadow: 0 4px 15px rgba(0,0,0,0.1);
    backdrop-filter: blur(10px);
    position: relative;
    z-index: 10;
}

.alert-success {
    background: linear-gradient(135deg, #27ae60 0%, #2ecc71 100%);
    color: white;
}

.alert-danger {
    background: linear-gradient(135deg, #e74c3c 0%, #c0392b 100%);
    color: white;
}

.alert-warning {
    background: linear-gradient(135deg, #f39c12 0%, #e67e22 100%);
    color: white;
}

/* Spinner */
#loadingSpinner {
    margin-top: 2rem;
}

#loadingSpinner .spinner-border {
    width: 3rem;
    height: 3rem;
    border-width: 0.3em;
    border-color: #3498db;
    border-right-color: transparent;
}

#loadingText {
    margin-top: 1.5rem;
    font-style: italic;
    color: #7f8c8d;
    font-size: 1.1rem;
    font-weight: 500;
}

/* Form centered layout */
@media (min-width: 768px) {
    .container {
        max-width: 1200px;
        padding: 2rem;
    }
    
    form {
        max-width: 600px;
        margin: 0 auto;
        padding: 2rem;
    }
}

#results::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: linear-gradient(90deg, #3498db, #2ecc71, #f39c12, #e74c3c);
    border-radius: 15px 15px 0 0;
}

#results h3 {
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 1.5rem;
    color: #2c3e50;
    text-align: center;
    position: relative;
    padding-bottom: 1rem;
}

#results h3::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 60px;
    height: 3px;
    background: linear-gradient(90deg, #3498db, #2ecc71);
    border-radius: 2px;
}

/* Cards */
.card {
    border: none;
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.08);
    transition: all 0.3s ease;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    overflow: hidden;
    position: relative;
    margin-bottom: 1rem;
    z-index: 10;
}

.stock-card {
    margin-bottom: 1rem !important;
}

.stock-card .card-body {
    padding: 1.25rem;
}

.stock-details {
    font-size: 0.9rem;
    line-height: 1.4;
}

.stock-details strong {
    font-weight: 600;
}

/* Icon actions styling */
.action-icons {
    display: flex;
    gap: 1rem;
    align-items: center;
}

.icon-action {
    transition: transform 0.2s ease, opacity 0.2s ease;
    display: inline-block;
}

.icon-action:hover {
    transform: scale(1.2);
    opacity: 0.8;
}

.icon-action:active {
    transform: scale(0.9);
}

/* Smart filter adjustment notifications */
.alert-info {
    border-left: 4px solid #0dcaf0;
    background-color: #e7f3ff;
    border-color: #b3e5fc;
}

.alert-info strong {
    color: #0c7cd5;
}

/* Never empty results styling */
.closest-match-indicator {
    background: linear-gradient(45deg, #fff3cd, #ffeaa7);
    border: 1px solid #f39c12;
    border-radius: 8px;
    padding: 0.75rem;
    margin-bottom: 1rem;
    font-size: 0.9rem;
}

.auto-adjust-badge {
    background-color: #17a2b8;
    color: white;
    font-size: 0.75rem;
    padding: 0.25rem 0.5rem;
    border-radius: 12px;
    margin-left: 0.5rem;
}

.card:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 30px rgba(0,0,0,0.15);
}

.card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: linear-gradient(90deg, #3498db, #2ecc71);
}

.card-body {
    padding: 1.5rem;
}

.card-title {
    font-weight: 700;
    color: #2c3e50;
    font-size: 1.25rem;
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.card-title::before {
    content: '📈';
    font-size: 1.2rem;
}

.card-text {
    font-size: 1rem;
    color: #34495e;
    line-height: 1.6;
    margin-bottom: 0.75rem;
}

.card-text:last-of-type {
    margin-bottom: 1.5rem;
    padding: 1rem;
    background: #f8f9fa;
    border-radius: 8px;
    border-left: 4px solid #3498db;
    font-style: italic;
}

/* Buttons */
.btn {
    font-weight: 600;
    border-radius: 8px;
    padding: 0.5rem 1rem;
    transition: all 0.3s ease;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-size: 0.85rem;
}

.copy-btn {
    background: linear-gradient(135deg, #3498db 0%, #2980b9 100%);
    border: none;
    color: white;
    margin-right: 0.5rem;
}

.copy-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(52, 152, 219, 0.3);
    background: linear-gradient(135deg, #2980b9 0%, #3498db 100%);
}

.save-btn {
    background: linear-gradient(135deg, #27ae60 0%, #2ecc71 100%);
    border: none;
    color: white;
    margin-left: 0.5rem;
}

.save-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(39, 174, 96, 0.3);
    background: linear-gradient(135deg, #2ecc71 0%, #27ae60 100%);
}

.copy-all-btn {
    background: linear-gradient(135deg, #8e44ad 0%, #9b59b6 100%);
    border: none;
    color: white;
    margin-right: 1rem;
    padding: 0.75rem 1.5rem;
    font-size: 1rem;
}

.copy-all-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(142, 68, 173, 0.3);
    background: linear-gradient(135deg, #9b59b6 0%, #8e44ad 100%);
}

/* Modal Styles */
.modal-xl {
    max-width: 90%;
}

.modal-content {
    border: none;
    border-radius: 15px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.2);
    backdrop-filter: blur(10px);
}

.modal-header {
    background: linear-gradient(135deg, #3498db 0%, #2980b9 100%);
    color: white;
    border-radius: 15px 15px 0 0;
    padding: 1.5rem;
    border-bottom: none;
}

.modal-title {
    font-weight: 700;
    font-size: 1.3rem;
}

.modal-body {
    padding: 2rem;
    max-height: 70vh;
    overflow-y: auto;
}

.modal-footer {
    border-top: 1px solid #e9ecef;
    border-radius: 0 0 15px 15px;
    padding: 1rem 2rem;
}

#savedRecommendations ul {
    padding-left: 1.5rem;
}

#savedRecommendations li {
    margin-bottom: 1rem;
    padding: 1rem;
    background: #f8f9fa;
    border-radius: 8px;
    border-left: 4px solid #3498db;
}

/* Sector Badge Styles */
.sector-badge {
  display: inline-block;
  padding: 0.2em 0.6em;
  font-size: 0.75em;
  border-radius: 0.25rem;
  color: white;
}

.sector-Technology { background-color: #007bff; }
.sector-Financial { background-color: #28a745; }
.sector-Pharma { background-color: #dc3545; }
.sector-Energy { background-color: #ffc107; }
.sector-Auto { background-color: #17a2b8; }
.sector-Metals { background-color: #6c757d; }
.sector-Telecommunications { background-color: #6610f2; }
.sector-Unknown { background-color: #6c757d; }

/* Price Change Indicators */
.price-positive { color: #28a745; }
.price-negative { color: #dc3545; }
.price-neutral { color: #6c757d; }

/* Animation for loading */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Responsive Design */
@media (max-width: 768px) {
    .container {
        padding: 1rem;
    }
    
    header h1 {
        font-size: 2.2rem;
    }
    
    .card-body {
        padding: 1rem;
    }
    
    .btn {
        width: 100%;
        margin: 0.25rem 0;
    }
    
    .copy-all-btn {
        margin-bottom: 1rem;
    }
}

/* Dynamic Color Pattern Animations */
@keyframes gradientShift {
    0% {
        background-position: 0% 50%;
    }
    50% {
        background-position: 100% 50%;
    }
    100% {
        background-position: 0% 50%;
    }
}

@keyframes float {
    0%, 100% {
        transform: translateY(0px) rotate(0deg);
    }
    50% {
        transform: translateY(-20px) rotate(180deg);
    }
}

/* Custom Prompts Styling */
.prompt-card {
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    cursor: pointer;
}

.prompt-clickable {
    position: relative;
    overflow: hidden;
    transition: all 0.3s ease;
    border: 2px solid transparent;
}

.prompt-clickable:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.15) !important;
    border-color: #007bff;
}

.prompt-icon {
    font-size: 2.5rem;
    transition: transform 0.3s ease;
}

.prompt-clickable:hover .prompt-icon {
    transform: scale(1.1);
}

.prompt-hover-effect {
    opacity: 0;
    transition: opacity 0.3s ease;
    position: absolute;
    bottom: 1rem;
    left: 50%;
    transform: translateX(-50%);
}

.prompt-clickable:hover .prompt-hover-effect {
    opacity: 1;
}

/* Dropdown Menu Styles */
.dropdown-toggle::after {
    display: none; /* Hide default Bootstrap arrow */
}

.dropdown {
    position: relative;
    z-index: 9999; /* Ensure dropdown container is on top */
}

.dropdown-menu {
    border: none;
    border-radius: 12px;
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.15);
    background: rgba(255, 255, 255, 0.98);
    backdrop-filter: blur(15px);
    padding: 0.5rem 0;
    min-width: 180px;
    margin-top: 0.5rem;
    z-index: 10000; /* Very high z-index to appear above everything */
    position: absolute;
    top: 100%;
    right: 0;
}

.dropdown-menu.show {
    display: block !important;
    opacity: 1;
    transform: translateY(0);
    visibility: visible;
}

.dropdown-item {
    padding: 0.75rem 1.25rem;
    font-size: 0.95rem;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    border: none;
    background: none;
    color: #2c3e50;
}

.dropdown-item:hover {
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    transform: translateX(3px);
}

.dropdown-item i {
    width: 18px;
    margin-right: 0.75rem;
}

.dropdown-item.text-danger:hover {
    background: linear-gradient(135deg, #ffe6e6 0%, #ffcccc 100%);
    color: #dc3545 !important;
}

.dropdown-divider {
    margin: 0.5rem 0;
    border-color: #e9ecef;
}

/* Header Dropdown Button */
#userMenuDropdown {
    border: none;
    background: none;
    transition: all 0.2s ease;
    padding: 0.5rem;
    border-radius: 50%;
}

#userMenuDropdown:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: scale(1.1);
}

#userMenuDropdown:focus {
    box-shadow: 0 0 0 0.2rem rgba(255, 255, 255, 0.3);
}

/* Header layout adjustments */
header .container {
    position: relative;
    z-index: 1001; /* Higher than regular header z-index */
}

header .flex-grow-1 {
    text-align: center;
}

/* Ensure main content doesn't overlap dropdown */
main.container {
    position: relative;
    z-index: 1; /* Lower z-index than header and dropdown */
}

.prompt-card .card-title {
    font-weight: 600;
    color: #2c3e50;
    margin-bottom: 0.5rem;
}

.prompt-card .card-text {
    font-size: 0.9rem;
    line-height: 1.4;
}

.prompt-stats {
    padding: 1.5rem;
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.1), rgba(255, 255, 255, 0.05));
    border-radius: 15px;
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.prompt-loading {
    position: relative;
    overflow: hidden;
}

.prompt-loading::after {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.4), transparent);
    animation: shimmer 1.5s infinite;
}

@keyframes shimmer {
    0% { left: -100%; }
    100% { left: 100%; }
}

/* Responsive adjustments for prompt cards */
@media (max-width: 768px) {
    .prompt-card .card-body {
        padding: 1.5rem !important;
    }
    
    .prompt-icon {
        font-size: 2rem;
    }
    
    .prompt-hover-effect {
        opacity: 1;
        position: static;
        transform: none;
        margin-top: 0.5rem;
    }
}

/* Error Messages and Loading States */
.error-container {
  background: rgba(255, 0, 0, 0.1);
  border: 1px solid rgba(255, 0, 0, 0.3);
  border-radius: 8px;
  padding: 1rem;
  margin: 1rem 0;
  color: #721c24;
}

.loading-state {
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 2rem;
  opacity: 0.7;
}

@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}
