/* ============================================
   EcoSort - Custom Styles
   ============================================ */

/* ============================================
   Variables & Root Styles
   ============================================ */
:root {
    --primary-color: #198754;
    --success-color: #198754;
    --warning-color: #ffc107;
    --danger-color: #dc3545;
    --info-color: #0dcaf0;
    --secondary-color: #6c757d;
    --gradient-primary: #198754;
    --gradient-success: #20bf6b;
    --gradient-info: #198754;
    --gradient-secondary: #6c757d;
    --shadow-sm: 0 0.125rem 0.25rem rgba(0, 0, 0, 0.075);
    --shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.15);
    --shadow-lg: 0 1rem 3rem rgba(0, 0, 0, 0.175);
}

/* ============================================
   General Styles
   ============================================ */
body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    line-height: 1.6;
    color: #333;
    overflow-x: hidden;
}

/* Smooth Scrolling */
html {
    scroll-behavior: smooth;
}

/* Enhanced smooth scrolling */
* {
    scroll-behavior: smooth;
}

/* Reduce motion for users who prefer it */
@media (prefers-reduced-motion: reduce) {
    html {
        scroll-behavior: auto;
    }
    
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* ============================================
   Hero Section
   ============================================ */
.hero-section {
    position: relative;
    min-height: 100vh;
    background-image: url('https://images.unsplash.com/photo-1532996122724-e3c354a0b15b?q=80&w=2070');
    background-size: cover;
    background-position: center;
    background-attachment: fixed;
    display: flex;
    align-items: center;
}

.hero-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(135deg, rgba(0, 0, 0, 0.7) 0%, rgba(34, 139, 34, 0.6) 100%);
}

.hero-content {
    position: relative;
    z-index: 2;
    animation: fadeInUp 1s ease-out;
}

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

/* ============================================
   Gradient Backgrounds
   ============================================ */
.bg-gradient-primary {
    background: var(--gradient-primary);
}

.bg-gradient-success {
    background: var(--gradient-success);
}

.bg-gradient-info {
    background: var(--gradient-info);
}

.bg-gradient-secondary {
    background: var(--gradient-secondary);
}

/* ============================================
   Material Icons
   ============================================ */
.material-icon {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2rem;
    margin: 0 auto;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

.material-card:hover .material-icon {
    transform: scale(1.1);
    box-shadow: 0 10px 30px rgba(0,0,0,0.3);
}

.material-icon.plastic {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.material-icon.paper {
    background: #20bf6b;
    color: white;
}

.material-icon.metal {
    background: linear-gradient(135deg, #fdc830 0%, #f37335 100%);
    color: white;
}

.material-icon.glass {
    background: linear-gradient(135deg, #a8edea 0%, #fed6e3 100%);
    color: white;
}

/* Filter button material icons */
.btn .material-icon {
    width: 24px;
    height: 24px;
    border-radius: 6px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.9rem;
    margin-right: 8px;
    transition: all 0.3s ease;
}

.btn .material-icon.all {
    background: #dc3545;
    color: white;
}

.btn .material-icon.plastic {
    background: #198754;
    color: white;
}

.btn .material-icon.paper, .btn .material-icon.cardboard {
    background: #20bf6b;
    color: white;
}

.btn .material-icon.metal {
    background: #fd7e14;
    color: white;
}

.btn .material-icon.glass {
    background: #0dcaf0;
    color: white;
}

.material-icon-large {
    width: 120px;
    height: 120px;
    border-radius: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 3.5rem;
    margin: 0 auto;
}

.material-icon-large.plastic {
    background: #198754;
    color: white;
}

.material-icon-large.paper {
    background: #20bf6b;
    color: white;
}

.material-icon-large.metal {
    background: #fd7e14;
    color: white;
}

.material-icon-large.glass {
    background: linear-gradient(135deg, #a8edea 0%, #fed6e3 100%);
    color: white;
}

.material-icon-large.cardboard {
    background: linear-gradient(135deg, #d4a373 0%, #8b7355 100%);
    color: white;
}

.material-result-icon {
    width: 60px;
    height: 60px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2rem;
}

/* ============================================
   Cards & Hover Effects
   ============================================ */
.material-card,
.step-card {
    padding: 2rem;
    border-radius: 15px;
    background: white;
    transition: all 0.3s ease;
    height: 100%;
    border: 2px solid #e9ecef;
    box-shadow: var(--shadow-sm);
    display: flex;
    flex-direction: column;
}

.material-card .btn {
    margin-top: auto;
}

.material-card:hover,
.step-card:hover {
    transform: translateY(-10px);
    box-shadow: var(--shadow-lg);
    border-color: #dee2e6;
}

.material-card {
    position: relative;
    overflow: hidden;
}

.material-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: linear-gradient(90deg, 
        var(--primary-color) 0%, 
        var(--success-color) 25%, 
        var(--warning-color) 50%, 
        var(--info-color) 75%, 
        var(--secondary-color) 100%
    );
    transform: scaleX(0);
    transform-origin: left;
    transition: transform 0.3s ease;
}

.material-card:hover::before {
    transform: scaleX(1);
}

/* Material Card Button Enhancement */
.material-card .btn {
    border-radius: 25px;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

.material-card .btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.3), transparent);
    transition: left 0.5s;
}

.material-card:hover .btn::before {
    left: 100%;
}

.material-card .btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(0,0,0,0.15);
}

.hover-lift {
    transition: all 0.3s ease;
}

.hover-lift:hover {
    transform: translateY(-5px);
    box-shadow: var(--shadow-lg);
}

/* ============================================
   Stats & Steps
   ============================================ */
.stat-card {
    padding: 2rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 120px;
}

.stat-card .display-5 {
    font-size: 2.5rem !important;
    line-height: 1.2;
    margin-bottom: 0.5rem;
    font-weight: 700;
    display: flex;
    align-items: baseline;
    justify-content: center;
    min-height: 60px;
}

.stat-card p {
    margin: 0;
    font-size: 0.9rem;
    text-align: center;
    line-height: 1.4;
}

.stat-icon {
    font-size: 3rem;
    margin-bottom: 1rem;
}

.step-number {
    position: absolute;
    top: -15px;
    right: 20px;
    width: 50px;
    height: 50px;
    background: var(--gradient-success);
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    font-weight: bold;
}

.step-card {
    position: relative;
}

.step-icon {
    font-size: 3rem;
    color: var(--success-color);
}

/* ============================================
   CTA Section
   ============================================ */
.cta-section {
    background: var(--gradient-success);
    padding: 5rem 0;
}

/* ============================================
   Upload Area
   ============================================ */
.upload-area {
    padding: 3rem;
    border: 3px dashed #dee2e6;
    border-radius: 15px;
    background: #f8f9fa;
    transition: all 0.3s ease;
    cursor: pointer;
}

.upload-area:hover {
    border-color: var(--primary-color);
    background: #e9ecef;
}

.upload-area.dragover {
    border-color: var(--success-color);
    background: #d1e7dd;
}

/* ============================================
   Buttons
   ============================================ */
.btn {
    border-radius: 8px;
    padding: 0.5rem 1.5rem;
    font-weight: 500;
    transition: all 0.3s ease;
}

.btn:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow);
}

/* ============================================
   Navbar
   ============================================ */
.navbar {
    transition: all 0.3s ease;
}

.navbar.fixed-top {
    background: white !important;
}

.nav-link {
    position: relative;
    transition: color 0.3s ease;
}

.nav-link::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 50%;
    width: 0;
    height: 2px;
    background: var(--success-color);
    transition: all 0.3s ease;
    transform: translateX(-50%);
}

.nav-link:hover::after,
.nav-link.active::after {
    width: 80%;
}

/* ============================================
   Footer
   ============================================ */
footer {
    color: #ffffff !important;
}

footer h4,
footer h5,
footer p,
footer .text-muted {
    color: rgba(255, 255, 255, 0.9) !important;
}

footer a {
    color: rgba(255, 255, 255, 0.7) !important;
    text-decoration: none;
    transition: color 0.3s ease;
}

footer a:hover {
    color: var(--success-color) !important;
}

/* ============================================
   Lesson Items
   ============================================ */
.lesson-complete .accordion-button {
    background-color: #d1e7dd;
}

.accordion-button:not(.collapsed) {
    background-color: #cfe2ff;
}

/* ============================================
   History Items
   ============================================ */
.history-item {
    transition: all 0.3s ease;
}

.history-item:hover {
    transform: translateX(5px);
    box-shadow: var(--shadow);
}

/* ============================================
   Loading Animation
   ============================================ */
@keyframes spin {
    0% {
        transform: rotate(0deg);
    }
    100% {
        transform: rotate(360deg);
    }
}

/* ============================================
   Material Section Filter
   ============================================ */
.material-section {
    transition: opacity 0.3s cubic-bezier(0.4, 0, 0.2, 1), transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    transform: translateY(0);
    opacity: 1;
    /* Prevent layout shift during show/hide */
    contain: layout;
}

.material-section.fade-out {
    opacity: 0;
    transform: translateY(-10px);
    pointer-events: none;
}

.material-section.fade-in {
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
}

.material-section.hidden {
    display: none !important;
}

/* Prevent scroll jumps during filtering */
.filtering-active {
    overflow-anchor: none;
}

/* Filter button transitions */
.btn[data-filter] {
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    transform: translateY(0);
}

.btn[data-filter]:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(0,0,0,0.15);
}

.btn[data-filter].active {
    transform: translateY(0);
    box-shadow: 0 4px 15px rgba(0,0,0,0.2);
}

/* ============================================
   Badges
   ============================================ */
.badge {
    font-weight: 500;
    padding: 0.5rem 1rem;
    border-radius: 8px;
}

/* ============================================
   Progress Bars
   ============================================ */
.progress {
    height: 10px;
    border-radius: 10px;
}

.progress-bar {
    border-radius: 10px;
    transition: width 0.6s ease;
}

/* ============================================
   Forms
   ============================================ */
.form-control,
.form-select {
    border-radius: 8px;
    border: 1px solid #dee2e6;
    padding: 0.75rem 1rem;
    transition: all 0.3s ease;
}

.form-control:focus,
.form-select:focus {
    border-color: var(--success-color);
    box-shadow: 0 0 0 0.25rem rgba(25, 135, 84, 0.25);
}

/* ============================================
   Tables
   ============================================ */
.table-hover tbody tr {
    transition: all 0.3s ease;
}

.table-hover tbody tr:hover {
    background-color: rgba(25, 135, 84, 0.05);
}

/* ============================================
   Animations
   ============================================ */
@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

@keyframes slideInLeft {
    from {
        opacity: 0;
        transform: translateX(-30px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes slideInRight {
    from {
        opacity: 0;
        transform: translateX(30px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.fade-in {
    animation: fadeIn 0.5s ease-out;
}

.slide-in-left {
    animation: slideInLeft 0.5s ease-out;
}

.slide-in-right {
    animation: slideInRight 0.5s ease-out;
}

/* ============================================
   Responsive Design
   ============================================ */
@media (max-width: 768px) {
    .hero-section {
        min-height: 70vh;
        background-attachment: scroll;
    }
    
    .display-3 {
        font-size: 2.5rem;
    }
    
    .stat-card {
        padding: 1.5rem;
        min-height: 100px;
    }
    
    .stat-card .display-5 {
        font-size: 2rem !important;
        min-height: 50px;
    }
    
    .stat-card p {
        font-size: 0.85rem;
    }
    
    .material-icon-large {
        width: 80px;
        height: 80px;
        font-size: 2.5rem;
    }
    
    .material-icon {
        width: 60px;
        height: 60px;
        font-size: 1.5rem;
    }
    
    .material-card {
        padding: 1.5rem;
        margin-bottom: 1.5rem;
    }
    
    .material-card h4 {
        font-size: 1.2rem;
    }
    
    .material-card p {
        font-size: 0.875rem;
    }
    
    .step-number {
        width: 40px;
        height: 40px;
        font-size: 1.2rem;
    }
}

/* ============================================
   Progress Steps (Classify Page)
   ============================================ */
.step-circle {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background-color: #e9ecef;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto;
    font-size: 1.5rem;
    color: #6c757d;
    border: 3px solid #e9ecef;
    transition: all 0.3s ease;
}

.step-circle.active {
    background-color: #0d6efd;
    border-color: #0d6efd;
    color: white;
    box-shadow: 0 0 0 4px rgba(13, 110, 253, 0.2);
}

.step-circle.completed {
    background-color: #198754;
    border-color: #198754;
    color: white;
}

.progress-line {
    height: 3px;
    background-color: #e9ecef;
    position: relative;
    top: -20px;
}

.progress-line.active {
    background-color: #0d6efd;
}

@media (max-width: 768px) {
    .step-circle {
        width: 50px;
        height: 50px;
        font-size: 1.2rem;
    }
}

/* ============================================
   Print Styles
   ============================================ */
@media print {
    .navbar,
    .btn,
    footer {
        display: none;
    }
    
    .hero-section {
        background: none;
        min-height: auto;
        padding: 2rem 0;
    }
    
    .hero-overlay {
        display: none;
    }
}

/* ============================================
   Toast Notifications
   ============================================ */
@keyframes slideInRight {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

@keyframes slideOutRight {
    from {
        transform: translateX(0);
        opacity: 1;
    }
    to {
        transform: translateX(100%);
        opacity: 0;
    }
}

#toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 9999;
    min-width: 300px;
    max-width: 400px;
}

#toast-container .alert {
    margin-bottom: 10px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    border: none;
    border-radius: 8px;
    animation: slideInRight 0.3s ease-out;
}

#toast-container .alert.fade:not(.show) {
    animation: slideOutRight 0.3s ease-out;
}

#toast-container .alert .bi {
    font-size: 1.2rem;
    vertical-align: middle;
}

/* Mobile responsive */
@media (max-width: 768px) {
    #toast-container {
        left: 20px;
        right: 20px;
        min-width: auto;
        max-width: none;
    }
}