/* Global Styles */
:root {
    --primary-color: #3b41c5;
    --primary-color-rgb: 59, 65, 197;
    --secondary-color: #8187ff;
    --accent-color: #ffbb00;
    --dark-color: #1a1c40;
    --light-color: #f8f9fa;
    --gray-color: #e9ecef;
    --text-color: #333;
    --border-radius: 10px;
    --box-shadow: 0 5px 15px rgba(0,0,0,0.1);
    --transition: all 0.3s ease;
}

/* Flag Styles */
.flag-icon {
    display: inline-block;
    margin-right: 8px;
    border-radius: 2px;
    overflow: hidden;
    vertical-align: middle;
}

.market-flag {
    border-radius: 2px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    transition: opacity 0.3s ease;
}

.flag-container {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

body {
    font-family: 'Poppins', sans-serif;
    color: var(--text-color);
    background-color: #f5f7ff;
    line-height: 1.7;
    overflow-x: hidden;
}

a {
    text-decoration: none;
    color: var(--primary-color);
    transition: var(--transition);
}

a:hover {
    color: var(--secondary-color);
}

/* Common section styling */
.section-header {
    margin-bottom: 3rem;
}

.section-header h2 {
    color: var(--primary-color);
    font-weight: 700;
    margin-bottom: 0.5rem;
    position: relative;
    display: inline-block;
}

.section-header h2:after {
    content: '';
    position: absolute;
    left: 50%;
    bottom: -10px;
    transform: translateX(-50%);
    width: 80px;
    height: 4px;
    background: var(--secondary-color);
    border-radius: 2px;
}

.section-header p {
    color: var(--dark-gray);
    margin-top: 1rem;
}

/* Header & Navigation */
.header {
    background: linear-gradient(to right, var(--primary-color), var(--secondary-color));
    color: white;
    padding-bottom: 2rem;
}

.navbar {
    padding: 1rem 0;
}

.navbar-brand {
    font-size: 2rem;
    font-weight: 700;
}

.brand-text {
    font-weight: 700;
    letter-spacing: 1px;
}

.nav-link {
    font-weight: 500;
    padding: 0.5rem 1rem !important;
    margin: 0 0.2rem;
    border-radius: 5px;
    transition: var(--transition);
}

.nav-link:hover, .nav-link.active {
    background-color: rgba(255, 255, 255, 0.1);
}

.hero-section {
    padding: 4rem 0;
    background: linear-gradient(to right, var(--primary-color), var(--secondary-color));
    color: white;
}

.hero-title {
    font-size: 3rem;
    font-weight: 700;
    margin-bottom: 1.5rem;
}

.hero-subtitle {
    font-size: 1.2rem;
    margin-bottom: 2rem;
    opacity: 0.9;
}

.hero-image {
    width: 420px;
    height: 320px;
    max-width: 100%;
    object-fit: contain;
    display: block;
    margin-left: auto;
    margin-right: auto;
    animation: float 3s ease-in-out infinite;
}

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

.hero-buttons .btn {
    padding: 0.8rem 1.5rem;
    font-weight: 500;
    border-radius: 50px;
}

.hero-buttons .btn-secondary {
    background-color: rgba(255, 255, 255, 0.15);
    border: 2px solid rgba(255, 255, 255, 0.8);
    color: white;
    transition: all 0.3s ease;
    backdrop-filter: blur(10px);
}

.hero-buttons .btn-secondary:hover {
    background-color: rgba(255, 255, 255, 0.25);
    border-color: white;
    color: white;
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(0,0,0,0.2);
}

/* Live Results Section */
.live-results-section {
    padding: 5rem 0;
    background-color: var(--light-color);
}

.last-update {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin-top: 15px;
    padding: 10px;
    background-color: rgba(255, 255, 255, 0.7);
    border-radius: var(--border-radius);
    transition: all 0.3s ease;
}

.last-update.refreshing {
    background-color: rgba(var(--primary-color-rgb), 0.1);
}

.update-label {
    font-size: 0.9rem;
    color: #666;
    margin-right: 5px;
}

.update-time {
    font-weight: 600;
    color: var(--primary-color);
}

#refresh-results {
    padding: 0.2rem 0.5rem;
    border-radius: 50px;
    font-size: 0.8rem;
}

.refresh-spinner {
    min-width: 18px;
    min-height: 18px;
    display: inline-block;
    color: var(--primary-color);
}

.refreshing .update-time {
    animation: blink 1s infinite;
}

@keyframes blink {
    0% { opacity: 1; }
    50% { opacity: 0.5; }
    100% { opacity: 1; }
}

.result-tabs {
    justify-content: center;
    border: none;
    margin-bottom: 2rem;
}

.result-tabs .nav-link {
    font-weight: 600;
    color: var(--text-color);
    border: none;
    padding: 0.8rem 2rem !important;
    border-radius: 50px;
    margin: 0 0.5rem;
    transition: var(--transition);
}

.result-tabs .nav-link.active {
    background-color: var(--primary-color);
    color: white;
}

.results-grid {
    margin-top: 2rem;
    min-height: 320px; /* Adjust based on expected content height */
}

.result-card {
    position: relative;
    background-color: white;
    border-radius: var(--border-radius);
    box-shadow: var(--box-shadow);
    margin-bottom: 2rem;
    overflow: hidden;
    transition: var(--transition);
}

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

.results-grid > div:first-child .result-card {
    background: linear-gradient(135deg, #fffbe6 60%, #ffe7ba 100%);
    border: 2px solid #ffd666;
    box-shadow: 0 0 16px 0 #ffd666;
    position: relative;
    z-index: 2;
}

.result-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem;
    background-color: var(--gray-color);
}

.country-info {
    display: flex;
    align-items: center;
}

.country-flag {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    object-fit: cover;
    margin-right: 10px;
    border: 2px solid white;
}

.country-name {
    font-size: 1.1rem;
    font-weight: 600;
    margin: 0;
}

.draw-info {
    text-align: right;
}

.draw-date, .draw-time {
    display: block;
    font-size: 0.85rem;
    color: #666;
}

.draw-time {
    font-weight: 600;
    color: var(--primary-color);
}

.result-body {
    position: relative;
    min-height: 150px;
    padding: 1.5rem;
    text-align: center;
}

.prize-numbers {
    display: flex;
    justify-content: center;
    gap: 10px;
    margin-bottom: 1.5rem;
}

.number-ball {
    width: 50px;
    height: 50px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(to right bottom, var(--primary-color), var(--secondary-color));
    color: white;
    font-size: 1.5rem;
    font-weight: 700;
    border-radius: 50%;
    box-shadow: 0 3px 6px rgba(0,0,0,0.1);
}

.prize-details {
    background-color: var(--gray-color);
    border-radius: var(--border-radius);
    padding: 1rem;
}

.prize-row {
    display: flex;
    justify-content: space-between;
    padding: 0.5rem 0;
    border-bottom: 1px dashed #ddd;
}

.prize-row:last-child {
    border-bottom: none;
}

.prize-label {
    font-weight: 500;
    color: #666;
}

.prize-value {
    font-weight: 700;
    color: var(--primary-color);
}

.result-footer {
    padding: 1rem;
    text-align: center;
    border-top: 1px solid var(--gray-color);
}

.btn-details {
    font-weight: 600;
    color: var(--primary-color);
}

.btn-details i {
    margin-left: 5px;
    transition: var(--transition);
}

.btn-details:hover i {
    transform: translateX(5px);
}

.waiting-message {
    padding: 2rem;
    text-align: center;
}

.waiting-message i {
    font-size: 2rem;
    color: var(--accent-color);
    margin-bottom: 1rem;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.1);
    }
    100% {
        transform: scale(1);
    }
}

.waiting-message p {
    font-weight: 500;
    color: #666;
}

.next-draw {
    display: block;
    font-size: 0.9rem;
    color: #666;
    font-weight: 500;
}

/* Live Update Styling */
.next-update {
    display: flex;
    align-items: center;
    justify-content: center;
    margin-top: 8px;
    font-size: 0.85rem;
    color: #666;
}

#countdown-timer {
    margin: 0 5px;
    font-weight: 600;
    color: #333;
    transition: all 0.3s ease;
}

#countdown-timer.text-danger {
    color: #dc3545;
    font-weight: 700;
}

#countdown-timer.text-muted {
    color: #aaa;
    text-decoration: line-through;
}

#toggle-auto-update {
    padding: 2px 6px;
    font-size: 0.75rem;
}

.api-error-message, .fallback-warning {
    font-size: 0.9rem;
    margin-top: 15px;
    border-radius: var(--border-radius);
    animation: fadeIn 0.5s ease-in-out;
}

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

.debug-panel {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 400px;
    max-height: 500px;
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 5px 15px rgba(0,0,0,0.2);
    z-index: 1000;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.debug-header {
    padding: 10px 15px;
    background: var(--primary-color);
    color: white;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.debug-header h4 {
    margin: 0;
    font-size: 16px;
}

.debug-content {
    padding: 15px;
    overflow-y: auto;
    flex: 1;
}

.debug-section {
    margin-bottom: 15px;
}

.debug-section h5 {
    margin-top: 0;
    font-size: 14px;
    font-weight: 600;
    color: #555;
}

#api-status {
    padding: 8px;
    background: #f8f9fa;
    border-radius: 4px;
    font-size: 13px;
}

#last-response {
    max-height: 100px;
    overflow-y: auto;
    font-size: 12px;
    background: #f8f9fa;
    padding: 8px;
    border-radius: 4px;
    white-space: pre-wrap;
}

.update-log {
    max-height: 150px;
    overflow-y: auto;
    font-size: 12px;
    background: #f8f9fa;
    padding: 8px;
    border-radius: 4px;
}

.log-entry {
    margin-bottom: 5px;
    padding-bottom: 5px;
    border-bottom: 1px solid #eee;
}

.log-time {
    color: #888;
    font-size: 11px;
}

.log-success {
    color: green;
}

.log-error {
    color: red;
}

.log-info {
    color: #0066cc;
}

.log-warning {
    color: #cc7700;
}

.debug-actions {
    display: flex;
    gap: 10px;
}

/* Schedule Section */
.schedule-section {
    padding: 5rem 0;
    background-color: white;
}

.schedule-table-wrapper {
    overflow-x: auto;
    border-radius: var(--border-radius);
    box-shadow: var(--box-shadow);
    min-height: 120px;
}

.schedule-table {
    margin-bottom: 0;
}

.schedule-table thead th {
    background-color: var(--primary-color);
    color: white;
    font-weight: 600;
    text-align: center;
    padding: 1rem;
    border: none;
}

.schedule-table tbody tr {
    transition: var(--transition);
}

.schedule-table tbody tr:hover {
    background-color: rgba(129, 135, 255, 0.05);
}

.schedule-table td {
    padding: 1rem;
    vertical-align: middle;
    text-align: center;
    border-color: var(--gray-color);
}

.market-info {
    display: flex;
    align-items: center;
    justify-content: center;
}

.market-flag {
    width: 24px;
    height: 24px;
    margin-right: 10px;
    border-radius: 2px;
    object-fit: cover;
}

.market-name {
    font-weight: 500;
}

/* Status badges for market status */
.status-badge {
    display: inline-block;
    padding: 0.25rem 1rem;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 600;
    text-transform: uppercase;
}

.status-badge.open {
    background-color: #dcf5e7;
    color: #0bb952;
}

.status-badge.closed {
    background-color: #fbe7e6;
    color: #e74c3c;
}

/* Analysis Section */
.analysis-section {
    padding: 5rem 0;
    background-color: #f9f9ff;
}

.analysis-card {
    background-color: white;
    border-radius: var(--border-radius);
    box-shadow: var(--box-shadow);
    padding: 2rem;
    height: 100%;
    min-height: 220px;
}

.analysis-card h3 {
    font-size: 1.3rem;
    font-weight: 600;
    margin-bottom: 1.5rem;
    color: var(--dark-color);
    text-align: center;
}

.number-frequency {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.freq-item {
    display: flex;
    align-items: center;
    gap: 15px;
}

.freq-bar {
    flex: 1;
    height: 20px;
    background-color: var(--gray-color);
    border-radius: 10px;
    position: relative;
    overflow: hidden;
}

.freq-fill {
    height: 100%;
    background: linear-gradient(to right, var(--primary-color), var(--secondary-color));
    border-radius: 10px;
}

.freq-value {
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(0%);
    font-weight: 600;
    font-size: 0.85rem;
    color: white;
    text-shadow: 0 1px 2px rgba(0,0,0,0.5);
    z-index: 10;
}

.pattern-analysis {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.pattern-item {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.pattern-label {
    font-weight: 500;
}

.pattern-chart {
    height: 20px;
    background-color: var(--gray-color);
    border-radius: 10px;
    position: relative;
    overflow: hidden;
}

.chart-fill {
    height: 100%;
    background: linear-gradient(to right, var(--accent-color), #ffce52);
    border-radius: 10px;
}

.chart-value {
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    font-weight: 600;
    font-size: 0.85rem;
    color: #333;
    z-index: 10;
    background-color: rgba(255,255,255,0.9);
    padding: 2px 6px;
    border-radius: 3px;
    min-width: 35px;
    text-align: center;
}

/* History Section */
.history-section {
    padding: 5rem 0;
    background-color: white;
}

.history-search {
    background-color: #f8f9fa;
    padding: 1.5rem;
    border-radius: var(--border-radius);
    margin-bottom: 2rem;
    box-shadow: var(--box-shadow);
}

.history-table {
    border-radius: var(--border-radius);
    overflow: hidden;
    box-shadow: var(--box-shadow);
}

.history-table thead th {
    background-color: var(--primary-color);
    color: white;
    border: none;
    text-align: center;
    padding: 1rem;
}

.history-table tbody td {
    vertical-align: middle;
    text-align: center;
    padding: 0.75rem;
}

.history-numbers {
    display: flex;
    justify-content: center;
    gap: 5px;
}

/* CTA Section */
.cta-section {
    padding: 4rem 0;
    background: linear-gradient(to right, var(--primary-color), var(--secondary-color));
    color: white;
}

.cta-section h2 {
    font-weight: 700;
    margin-bottom: 1rem;
}

.cta-section p {
    font-size: 1.1rem;
    opacity: 0.9;
    margin-bottom: 0;
}

/* Footer */
.footer {
    background-color: var(--dark-color);
    color: #ddd;
    padding: 5rem 0 2rem;
}

.footer-brand {
    font-size: 2rem;
    font-weight: 700;
    margin-bottom: 1rem;
    color: white;
}

.footer-description {
    margin-bottom: 2rem;
    opacity: 0.8;
}

.social-links {
    display: flex;
    gap: 10px;
    margin-bottom: 2rem;
}

.social-link {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    background-color: rgba(255, 255, 255, 0.1);
    color: white;
    border-radius: 50%;
    transition: var(--transition);
}

.social-link:hover {
    background-color: var(--accent-color);
    color: var(--dark-color);
    transform: translateY(-3px);
}

.footer-title {
    font-size: 1.2rem;
    font-weight: 600;
    color: white;
    margin-bottom: 1.5rem;
    position: relative;
}

.footer-title::after {
    content: '';
    position: absolute;
    bottom: -10px;
    left: 0;
    width: 50px;
    height: 3px;
    background: var(--accent-color);
}

.footer-links {
    list-style: none;
    padding: 0;
    margin: 0;
}

.footer-links li {
    margin-bottom: 10px;
}

.footer-links a {
    color: #ddd;
    transition: var(--transition);
}

.footer-links a:hover {
    color: var(--accent-color);
    padding-left: 5px;
}

.footer-subscribe .form-control {
    background-color: rgba(255, 255, 255, 0.1);
    border: none;
    color: white;
    border-radius: 50px 0 0 50px;
    padding: 0.5rem 1.5rem;
}

.footer-subscribe .form-control::placeholder {
    color: rgba(255, 255, 255, 0.6);
}

.footer-subscribe .btn {
    border-radius: 0 50px 50px 0;
    font-weight: 600;
}

.footer-bottom {
    margin-top: 4rem;
    padding-top: 2rem;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.copyright {
    margin-bottom: 0;
    opacity: 0.7;
}

.footer-bottom-links {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    justify-content: flex-end;
    gap: 20px;
}

.footer-bottom-links a {
    color: #ddd;
    opacity: 0.7;
    transition: var(--transition);
}

.footer-bottom-links a:hover {
    color: var(--accent-color);
    opacity: 1;
}

/* Official Source Badge */
.official-source-badge {
    position: absolute;
    top: 10px;
    right: 10px;
    background-color: #28a745;
    color: white;
    font-size: 0.7rem;
    padding: 3px 8px;
    border-radius: 20px;
    display: flex;
    align-items: center;
    gap: 4px;
    z-index: 5;
    box-shadow: 0 2px 5px rgba(0,0,0,0.2);
    animation: fadeIn 0.5s ease-in;
}

.official-source-badge i {
    font-size: 0.8rem;
}

.draw-number {
    font-size: 0.8rem;
    color: #777;
    text-align: center;
    margin-bottom: 5px;
}

/* Enhanced highlight effects for live updates */
@keyframes highlight {
    0% { box-shadow: 0 0 0 rgba(255, 187, 0, 0); }
    50% { box-shadow: 0 0 20px rgba(255, 187, 0, 0.7); }
    100% { box-shadow: 0 0 0 rgba(255, 187, 0, 0); }
}

@keyframes highlight-new {
    0% { box-shadow: 0 0 0 rgba(59, 65, 197, 0); transform: scale(1); }
    10% { box-shadow: 0 0 30px rgba(59, 65, 197, 0.9); transform: scale(1.05); }
    20% { box-shadow: 0 0 20px rgba(59, 65, 197, 0.7); transform: scale(1.03); }
    100% { box-shadow: 0 0 0 rgba(59, 65, 197, 0); transform: scale(1); }
}

.highlight-update {
    animation: highlight 3s ease-in-out;
    position: relative;
    z-index: 1;
}

.highlight-update-new {
    animation: highlight-new 6s ease-in-out;
    position: relative;
    z-index: 10;
}

/* Force visibility for percentage values - highest specificity */
.analysis-card .pattern-analysis .pattern-item .pattern-chart .chart-value,
.number-frequency .freq-item .freq-bar .freq-value {
    color: #000 !important;
    background-color: rgba(255,255,255,0.95) !important;
    font-weight: 700 !important;
    font-size: 0.9rem !important;
    padding: 3px 8px !important;
    border-radius: 4px !important;
    border: 1px solid rgba(0,0,0,0.1) !important;
    z-index: 999 !important;
    min-width: 40px !important;
    text-align: center !important;
    position: absolute !important;
    right: 8px !important;
    top: 50% !important;
    transform: translateY(-50%) !important;
    text-shadow: none !important;
    opacity: 1 !important;
    visibility: visible !important;
    display: block !important;
}

.analysis-card .number-frequency .freq-item .freq-bar .freq-value {
    color: #000 !important;
    background-color: rgba(255,255,255,0.95) !important;
}

/* Responsive Styles */
@media (max-width: 992px) {
    .hero-title {
        font-size: 2.5rem;
    }
    
    .hero-section {
        text-align: center;
        padding: 3rem 0;
    }
    
    .hero-buttons {
        justify-content: center;
    }
    
    .result-tabs .nav-link {
        padding: 0.6rem 1rem !important;
        margin: 0 0.3rem;
    }
}

@media (max-width: 768px) {
    .hero-title {
        font-size: 2rem;
    }
    
    .section-header h2 {
        font-size: 1.8rem;
    }
    
    .footer {
        padding: 3rem 0 1rem;
    }
    
    .footer-title {
        margin-top: 2rem;
    }
    
    .footer-bottom-links {
        justify-content: flex-start;
        margin-top: 1rem;
    }
}

@media (max-width: 576px) {
    .hero-title {
        font-size: 1.8rem;
    }
    
    .hero-subtitle {
        font-size: 1rem;
    }
    
    .hero-buttons .btn {
        padding: 0.6rem 1.2rem;
        font-size: 0.9rem;
    }
    
    .number-ball {
        width: 40px;
        height: 40px;
        font-size: 1.2rem;
    }
    
    .result-tabs .nav-link {
        font-size: 0.9rem;
        padding: 0.5rem 0.8rem !important;
        margin: 0 0.2rem;
    }
}

/* --- CLS Fixes for layout stability --- */

/* Reserve space for results grid (live results) */
.results-grid {
    min-height: 320px; /* Adjust based on expected content height */
}

/* Reserve space for section headers to avoid jump */
.section-header {
    min-height: 110px;
}

/* Reserve space for tab content */
.tab-content {
    min-height: 220px;
}

/* Reserve space for schedule table */
.schedule-table-wrapper {
    min-height: 120px;
}

/* Explicit size for hero image to avoid shift */
.hero-image {
    width: 420px;
    height: 320px;
    max-width: 100%;
    object-fit: contain;
    display: block;
    margin-left: auto;
    margin-right: auto;
}

/* Spinner placeholder to avoid shift */
.refresh-spinner {
    min-width: 18px;
    min-height: 18px;
    display: inline-block;
}

/* History results table min-height */
.history-results {
    min-height: 260px;
}

/* Analysis section cards min-height */
.analysis-card {
    min-height: 220px;
}
