/* Custom Theme */
:root {
    --primary-gradient: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    --card-shadow: 0 2px 12px rgba(0, 0, 0, 0.08);
    --card-hover-shadow: 0 6px 24px rgba(0, 0, 0, 0.15);
    --bg-color: #f5f7fb;
    --text-color: #212529;
    --card-bg: #fff;
    --ocean-color: rgba(41, 128, 185, 0.15);
    --wave-color-1: rgba(41, 128, 185, 0.12);
    --wave-color-2: rgba(52, 152, 219, 0.08);
}

[data-bs-theme="dark"] {
    --bg-color: #1a1d23;
    --text-color: #e0e0e0;
    --card-bg: #2b2f38;
    --card-shadow: 0 2px 12px rgba(0, 0, 0, 0.3);
    --card-hover-shadow: 0 6px 24px rgba(0, 0, 0, 0.4);
    --ocean-color: rgba(20, 60, 90, 0.3);
    --wave-color-1: rgba(20, 60, 90, 0.25);
    --wave-color-2: rgba(30, 80, 120, 0.15);
}

body {
    background-color: var(--bg-color);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, sans-serif;
    overflow-x: hidden;
}

/* ===== Animated Ocean Background ===== */
.ocean-bg {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 180px;
    z-index: 0;
    pointer-events: none;
    overflow: hidden;
}

/* Waves */
.wave {
    position: absolute;
    bottom: 0;
    left: -5%;
    width: 110%;
    height: 100%;
}

.wave-1 {
    background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 1440 100'%3E%3Cpath fill='%232980B9' fill-opacity='0.12' d='M0,40 C360,80 720,0 1080,40 C1260,60 1380,50 1440,40 L1440,100 L0,100 Z'/%3E%3C/svg%3E") repeat-x bottom;
    background-size: 1440px 100px;
    animation: wave-move 8s linear infinite;
}

.wave-2 {
    background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 1440 100'%3E%3Cpath fill='%233498DB' fill-opacity='0.08' d='M0,60 C360,20 720,80 1080,40 C1260,20 1380,50 1440,60 L1440,100 L0,100 Z'/%3E%3C/svg%3E") repeat-x bottom;
    background-size: 1440px 100px;
    animation: wave-move 12s linear infinite reverse;
}

.wave-3 {
    background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 1440 100'%3E%3Cpath fill='%232C3E50' fill-opacity='0.06' d='M0,50 C480,90 960,10 1440,50 L1440,100 L0,100 Z'/%3E%3C/svg%3E") repeat-x bottom;
    background-size: 1440px 100px;
    animation: wave-move 15s linear infinite;
}

@keyframes wave-move {
    0%   { transform: translateX(0); }
    100% { transform: translateX(-1440px); }
}

/* Ship */
.ship-container {
    position: absolute;
    bottom: 50px;
    animation: sail 25s linear infinite, bob 3s ease-in-out infinite;
    z-index: 1;
}

@keyframes sail {
    0%   { left: -200px; }
    100% { left: calc(100% + 200px); }
}

@keyframes bob {
    0%, 100% { transform: translateY(0) rotate(0deg); }
    25%      { transform: translateY(-6px) rotate(-1deg); }
    75%      { transform: translateY(4px) rotate(1deg); }
}

.ship-svg {
    width: 120px;
    height: 60px;
    opacity: 0.35;
}

[data-bs-theme="dark"] .ship-svg {
    opacity: 0.5;
}

[data-bs-theme="dark"] .wave-1 {
    background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 1440 100'%3E%3Cpath fill='%231A5276' fill-opacity='0.3' d='M0,40 C360,80 720,0 1080,40 C1260,60 1380,50 1440,40 L1440,100 L0,100 Z'/%3E%3C/svg%3E") repeat-x bottom;
    background-size: 1440px 100px;
}

[data-bs-theme="dark"] .wave-2 {
    background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 1440 100'%3E%3Cpath fill='%231B4F72' fill-opacity='0.25' d='M0,60 C360,20 720,80 1080,40 C1260,20 1380,50 1440,60 L1440,100 L0,100 Z'/%3E%3C/svg%3E") repeat-x bottom;
    background-size: 1440px 100px;
}

[data-bs-theme="dark"] .wave-3 {
    background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 1440 100'%3E%3Cpath fill='%23154360' fill-opacity='0.2' d='M0,50 C480,90 960,10 1440,50 L1440,100 L0,100 Z'/%3E%3C/svg%3E") repeat-x bottom;
    background-size: 1440px 100px;
}

/* ===== Main content above ocean ===== */
main {
    position: relative;
    z-index: 1;
}

/* Navbar */
.navbar {
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
    z-index: 1030;
}

.navbar-brand i {
    color: #64b5f6;
}

.navbar .nav-controls {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.lang-btn, .theme-btn {
    background: transparent;
    border: 1px solid rgba(255,255,255,0.3);
    color: rgba(255,255,255,0.8);
    padding: 0.25rem 0.6rem;
    border-radius: 6px;
    font-size: 0.8rem;
    cursor: pointer;
    transition: all 0.2s;
}

.lang-btn:hover, .theme-btn:hover,
.lang-btn.active, .theme-btn.active {
    background: rgba(255,255,255,0.15);
    color: #fff;
    border-color: rgba(255,255,255,0.5);
}

/* Stat Cards */
.stat-card {
    background: var(--card-bg);
    box-shadow: var(--card-shadow);
    border-radius: 12px;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.stat-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--card-hover-shadow);
}

.stat-icon {
    font-size: 2rem;
    margin-bottom: 0.5rem;
}

.stat-value {
    font-size: 2rem;
    font-weight: 700;
    margin-bottom: 0;
}

.stat-label {
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.metric-value {
    font-size: 2.5rem;
    font-weight: 700;
}

/* Cards */
.card {
    background: var(--card-bg);
    border-radius: 12px;
    box-shadow: var(--card-shadow);
    transition: box-shadow 0.2s ease;
}

.card:hover {
    box-shadow: var(--card-hover-shadow);
}

.card-header {
    border-radius: 12px 12px 0 0 !important;
}

/* Prediction Form */
#prediction-form .form-label {
    font-weight: 600;
    font-size: 0.875rem;
}

#prediction-form .form-control,
#prediction-form .form-select {
    border-radius: 8px;
    border: 1.5px solid #dee2e6;
    transition: border-color 0.2s, box-shadow 0.2s;
}

#prediction-form .form-control:focus,
#prediction-form .form-select:focus {
    border-color: #667eea;
    box-shadow: 0 0 0 0.2rem rgba(102, 126, 234, 0.2);
}

#prediction-form .btn-primary {
    border-radius: 8px;
    padding: 0.6rem;
    font-weight: 600;
    background: var(--primary-gradient);
    border: none;
    transition: opacity 0.2s;
}

#prediction-form .btn-primary:hover {
    opacity: 0.9;
}

/* Inline Prediction Result */
#prediction-result .result-card {
    border-radius: 10px;
    padding: 1rem;
    text-align: center;
}

#prediction-result .result-survived {
    background: linear-gradient(135deg, #d4edda 0%, #c3e6cb 100%);
    border: 1px solid #b1dfbb;
}

#prediction-result .result-died {
    background: linear-gradient(135deg, #f8d7da 0%, #f5c6cb 100%);
    border: 1px solid #f1b0b7;
}

[data-bs-theme="dark"] #prediction-result .result-survived {
    background: linear-gradient(135deg, #1a4731 0%, #1e5631 100%);
    border-color: #2d6a3e;
}

[data-bs-theme="dark"] #prediction-result .result-died {
    background: linear-gradient(135deg, #4a1a1a 0%, #5c2020 100%);
    border-color: #6b2c2c;
}

#prediction-result .result-probability {
    font-size: 1.5rem;
    font-weight: 700;
}

/* ===== Prediction Animation Overlay ===== */
.predict-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: linear-gradient(180deg, #1a2a3a 0%, #0d1b2a 60%, #1b3a4b 100%);
    opacity: 0;
    animation: overlay-fade-in 0.4s ease forwards;
}

@keyframes overlay-fade-in {
    to { opacity: 1; }
}

.predict-overlay .anim-ship {
    width: 180px;
    animation: anim-bob 1.5s ease-in-out infinite;
}

.predict-overlay .anim-text {
    color: #fff;
    font-size: 1.3rem;
    margin-top: 1.5rem;
    opacity: 0;
    animation: anim-text-in 0.6s ease 0.3s forwards;
}

.predict-overlay .anim-waves-bottom {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 120px;
}

.predict-overlay .anim-wave-1 {
    position: absolute;
    bottom: 0;
    left: -5%;
    width: 110%;
    height: 100%;
    background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 1440 100'%3E%3Cpath fill='%232980B9' fill-opacity='0.4' d='M0,40 C360,80 720,0 1080,40 C1260,60 1380,50 1440,40 L1440,100 L0,100 Z'/%3E%3C/svg%3E") repeat-x bottom;
    background-size: 1440px 100px;
    animation: wave-move 6s linear infinite;
}

.predict-overlay .anim-wave-2 {
    position: absolute;
    bottom: 0;
    left: -5%;
    width: 110%;
    height: 100%;
    background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 1440 100'%3E%3Cpath fill='%233498DB' fill-opacity='0.3' d='M0,60 C360,20 720,80 1080,40 C1260,20 1380,50 1440,60 L1440,100 L0,100 Z'/%3E%3C/svg%3E") repeat-x bottom;
    background-size: 1440px 100px;
    animation: wave-move 9s linear infinite reverse;
}

@keyframes anim-bob {
    0%, 100% { transform: translateY(0) rotate(0deg); }
    30%      { transform: translateY(-12px) rotate(-2deg); }
    70%      { transform: translateY(6px) rotate(1.5deg); }
}

@keyframes anim-text-in {
    to { opacity: 1; }
}

/* Survived animation */
.predict-overlay.result-survived .anim-ship {
    animation: ship-celebrate 1s ease forwards;
}

.predict-overlay.result-survived .celebration {
    font-size: 3rem;
    animation: celebrate-pop 0.6s ease forwards;
}

@keyframes ship-celebrate {
    0%   { transform: translateY(0); }
    40%  { transform: translateY(-30px) rotate(-3deg); }
    70%  { transform: translateY(-10px) rotate(2deg); }
    100% { transform: translateY(0) rotate(0); }
}

@keyframes celebrate-pop {
    0%   { transform: scale(0); opacity: 0; }
    60%  { transform: scale(1.3); opacity: 1; }
    100% { transform: scale(1); opacity: 1; }
}

/* Did not survive animation */
.predict-overlay.result-died .anim-ship {
    animation: ship-sink 1.5s ease forwards;
}

@keyframes ship-sink {
    0%   { transform: translateY(0) rotate(0); opacity: 1; }
    40%  { transform: translateY(10px) rotate(8deg); opacity: 1; }
    70%  { transform: translateY(40px) rotate(15deg); opacity: 0.7; }
    100% { transform: translateY(80px) rotate(25deg); opacity: 0.3; }
}

.predict-overlay .result-text {
    font-size: 2rem;
    font-weight: 700;
    margin-top: 1rem;
    opacity: 0;
    animation: anim-text-in 0.5s ease 0.8s forwards;
}

.predict-overlay .result-text.survived { color: #2ecc71; }
.predict-overlay .result-text.died { color: #e74c3c; }

.predict-overlay .continue-btn {
    cursor: pointer;
    transition: all 0.3s ease;
}

.predict-overlay .continue-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 5px 20px rgba(255, 255, 255, 0.3);
}

/* Progress bar in results */
.progress {
    border-radius: 15px;
    overflow: hidden;
}

.progress-bar {
    font-weight: 600;
    font-size: 0.8rem;
    line-height: 30px;
}

/* Confusion Matrix */
.confusion-matrix th,
.confusion-matrix td {
    vertical-align: middle;
    font-size: 0.9rem;
}

.confusion-matrix .fw-bold {
    font-size: 1.2rem;
}

/* Tables */
.table-responsive {
    border-radius: 0 0 12px 12px;
}

.table thead th {
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Charts */
canvas {
    max-height: 300px;
}

/* Footer */
footer {
    border-top: 1px solid #343a40;
    position: relative;
    z-index: 1;
}

/* Back button */
.btn-primary {
    border-radius: 8px;
    font-weight: 600;
}

/* Badge */
.badge {
    font-weight: 600;
    padding: 0.35em 0.65em;
}

/* ===== RTL Support ===== */
body.rtl {
    text-align: right;
}

body.rtl .navbar-nav {
    padding-right: 0;
}

body.rtl .ms-auto {
    margin-left: unset !important;
    margin-right: auto !important;
}

body.rtl .nav-controls {
    margin-left: 0 !important;
    margin-right: 1rem;
}

body.rtl .form-label {
    text-align: right;
}

body.rtl .text-muted {
    text-align: right;
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .stat-value {
        font-size: 1.5rem;
    }

    .metric-value {
        font-size: 2rem;
    }

    .stat-icon {
        font-size: 1.5rem;
    }

    .ocean-bg {
        height: 100px;
    }

    .ship-svg {
        width: 80px;
        height: 40px;
    }

    .predict-overlay .anim-ship {
        width: 120px;
    }
}
