
/* ===== GREETING BANNER RESPONSIVE  ===== */
@media (max-width: 768px) {
    .greeting-banner {
        display: flex;
        flex-direction: column;
        align-items: stretch;
        gap: 1rem;
        padding: 1rem;
        margin: 0 auto 1.5rem auto;
        border-radius: 18px;
        width: calc(100% - 2rem);
        max-width: 100%;
        box-sizing: border-box;
        overflow: hidden;
        word-break: break-word;
        overflow-wrap: break-word;
    }

    .greeting-left {
        display: flex;
        flex-direction: column;
        gap: 0.5rem;
        width: 100%;
        box-sizing: border-box;
        min-width: 0;
    }

    .greeting-main {
        display: flex;
        gap: 0.4rem;
        flex-wrap: wrap;
        align-items: center;
        width: 100%;
        min-width: 0;
        box-sizing: border-box;
    }

    .greeting-line {
        font-size: 1.25rem;
        font-weight: 800;
        word-wrap: break-word;
        overflow-wrap: break-word;
        word-break: break-word;
        max-width: calc(100% - 1.5rem);
        flex: 1;
        min-width: 0;
    }

    .greeting-emoji {
        font-size: 1.25rem;
        flex-shrink: 0;
        white-space: nowrap;
    }

    .greeting-subline {
        font-size: 0.9rem;
        opacity: 0.92;
        word-wrap: break-word;
        overflow-wrap: break-word;
        max-width: 100%;
        width: 100%;
        box-sizing: border-box;
        line-height: 1.4;
    }

    .greeting-meta {
        display: flex;
        gap: 0.4rem;
        font-size: 0.75rem;
        flex-wrap: wrap;
        width: 100%;
        box-sizing: border-box;
        min-width: 0;
    }

    .greeting-meta-item {
        padding: 0.3rem 0.55rem;
        font-size: 0.75rem;
        white-space: normal;
        word-break: break-word;
        max-width: 100%;
        flex-shrink: 0;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .greeting-quote {
        font-size: 0.8rem;
        margin-top: 0.5rem;
        word-wrap: break-word;
        overflow-wrap: break-word;
        max-width: 100%;
        width: 100%;
        box-sizing: border-box;
        line-height: 1.4;
    }

    .greeting-dismiss {
        align-self: flex-start;
        margin-top: 0.25rem;
        font-size: 1rem;
        padding: 0.5rem;
    }
}

@media (max-width: 480px) {
    .greeting-banner {
        padding: 0.75rem;
        margin: 0 auto 1.25rem auto;
        gap: 0.5rem;
        width: calc(100% - 1.5rem);
    }

    .greeting-main {
        gap: 0.3rem;
    }

    .greeting-line {
        font-size: 1.1rem;
        max-width: calc(100% - 1.2rem);
    }

    .greeting-emoji {
        font-size: 1.1rem;
    }

    .greeting-subline {
        font-size: 0.85rem;
        line-height: 1.3;
    }

    .greeting-meta {
        gap: 0.3rem;
        font-size: 0.7rem;
    }

    .greeting-meta-item {
        padding: 0.25rem 0.45rem;
        font-size: 0.7rem;
    }

    .greeting-quote {
        font-size: 0.75rem;
        line-height: 1.3;
    }

    .greeting-dismiss {
        font-size: 0.95rem;
        padding: 0.4rem;
    }
}

@media (max-width: 360px) {
    .greeting-banner {
        padding: 0.6rem;
        margin: 0 auto 1rem auto;
        gap: 0.4rem;
        width: calc(100% - 1.2rem);
    }

    .greeting-line {
        font-size: 1rem;
        max-width: calc(100% - 1rem);
    }

    .greeting-emoji {
        font-size: 1rem;
    }

    .greeting-subline {
        font-size: 0.8rem;
        line-height: 1.3;
    }

    .greeting-meta-item {
        padding: 0.2rem 0.4rem;
        font-size: 0.65rem;
    }

    .greeting-quote {
        font-size: 0.7rem;
        margin-top: 0.3rem;
    }

    .greeting-dismiss {
        font-size: 0.9rem;
        padding: 0.3rem;
    }
}

/* ===== TABLET & MOBILE (768px and below) ===== */
@media (max-width: 768px) {
    /* Base overrides */
    * {
        min-width: 0;
        word-wrap: break-word;
        overflow-wrap: break-word;
    }

    /* Main Layout */
    body {
        font-size: 14px;
    }

    .main-container {
        flex-direction: column;
    }

    /* Sidebar */
    .sidebar {
        position: fixed;
        left: 0;
        top: 0;
        width: 100%;
        height: 100%;
        background: var(--bg);
        z-index: 999;
        transform: translateX(-100%);
        transition: transform 0.3s ease;
        overflow-y: auto;
        padding-bottom: 60px;
    }

    .sidebar.mobile-open {
        transform: translateX(0);
    }

    .sidebar::before {
        content: '';
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: rgba(0, 0, 0, 0.5);
        z-index: -1;
    }

    /* Main Content */
    .main-content {
        margin-left: 0;
        width: 100%;
        padding: 1rem;
    }

    .top-bar {
        padding: 1rem;
        gap: 0.5rem;
    }

    /* Mobile Menu Toggle */
    .mobile-menu-toggle {
        display: flex;
        padding: 0.5rem;
        font-size: 1.2rem;
        cursor: pointer;
    }

    /* User Profile Section */
    .user-profile {
        gap: 0.5rem;
    }

    .user-avatar {
        width: 32px;
        height: 32px;
    }

    .user-profile span {
        display: none;
    }

    /* Loader */
    .loader-logo {
        font-size: 2rem;
    }

    .loader-text {
        font-size: 0.85rem;
    }

    .progress-bar {
        height: 8px;
    }

    /* Stats Grid */
    .stats-grid {
        grid-template-columns: 1fr 1fr !important;
        gap: 1rem;
    }

    .stat-card {
        padding: 1rem;
        font-size: 0.9rem;
    }

    .stat-card h3 {
        font-size: 0.8rem;
    }

    .stat-card .stat-value {
        font-size: 1.5rem;
    }

    .stat-card .stat-change {
        font-size: 0.7rem;
    }

    /* Cards */
    .anime-card {
        width: 100%;
        max-width: none;
    }

    .anime-card-grid {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 1rem;
    }

    /* Tables */
    .anime-table {
        font-size: 0.85rem;
    }

    .anime-table th,
    .anime-table td {
        padding: 0.75rem 0.5rem;
    }

    .anime-title-cell {
        gap: 0.5rem;
    }

    .anime-title-cell .anime-cover {
        width: 40px;
        height: 56px;
    }

    .anime-title {
        font-size: 0.85rem;
    }

    .anime-genres {
        font-size: 0.7rem;
    }

    /* Modals */
    .modal-content {
        width: 95vw;
        max-height: 90vh;
        padding: 1.5rem;
        margin: auto;
    }

    .modal-content h2 {
        font-size: 1.3rem;
    }

    /* Forms */
    .form-group {
        margin-bottom: 1rem;
    }

    .form-group label {
        font-size: 0.9rem;
    }

    .form-group input,
    .form-group select,
    .form-group textarea {
        font-size: 14px;
        padding: 0.75rem;
    }

    /* Buttons */
    .btn,
    .action-btn {
        padding: 0.75rem 1.25rem;
        font-size: 0.9rem;
    }

    .filter-btn {
        padding: 0.5rem 1rem;
        font-size: 0.8rem;
    }

    /* Section Title */
    .section-title {
        font-size: 1.2rem;
        margin-bottom: 1rem;
    }

    /* Charts */
    #monthlyProgressChart,
    #genreDistributionChart,
    #completionChart,
    #scoreDistributionChart,
    #statusDistributionChart,
    #typeDistributionChart,
    #genreStatsChart {
        height: 250px !important;
    }

    .chart-card {
        padding: 1rem;
    }

    /* Progress wrapper */
    .progress-wrapper {
        gap: 0.5rem;
    }

    .progress-container {
        height: 6px;
    }

    .progress-container small {
        font-size: 0.75rem;
    }

    /* Badge */
    .badge {
        padding: 0.2rem 0.6rem;
        font-size: 0.7rem;
    }

    /* Activity */
    .activity-item {
        gap: 0.75rem;
        padding: 0.75rem;
    }

    .activity-icon {
        width: 32px;
        height: 32px;
        min-width: 32px;
    }

    .activity-icon i {
        font-size: 0.8rem;
    }

    .activity-anime {
        font-size: 0.9rem;
    }

    .activity-desc {
        font-size: 0.8rem;
    }

    .activity-time {
        font-size: 0.75rem;
    }

    /* Menu items */
    .menu-item {
        padding: 0.75rem 1rem;
        font-size: 0.95rem;
    }

    .menu-item i {
        font-size: 1.1rem;
    }

    /* Close button */
    .close-modal {
        width: 28px;
        height: 28px;
        font-size: 1.5rem;
    }

    /* Toast */
    .toast {
        padding: 1rem;
        font-size: 0.9rem;
        max-width: 90vw;
    }

    /* Dashboard sections */
    .dashboard-section {
        margin-bottom: 1.5rem;
    }

    /* Watchlist grid */
    .watchlist-filters {
        flex-wrap: wrap;
        gap: 0.5rem;
    }

    .watchlist-filters .filter-btn {
        flex: 0 1 calc(50% - 0.25rem);
    }

    /* Text truncation */
    .anime-title {
        max-width: 100%;
        white-space: normal;
    }

    /* Ensure no horizontal overflow */
    .page {
        overflow-x: hidden;
    }

    main {
        overflow-x: hidden;
    }
}

/* ===== SMALL MOBILE (480px and below) ===== */
@media (max-width: 480px) {
    /* Loader */
    .loader-logo {
        font-size: 1.6rem;
        gap: 0.4rem;
    }

    .loader-text {
        font-size: 0.8rem;
    }

    .progress-wrapper {
        margin-top: 1.5rem;
    }

    /* Main content */
    .main-content {
        padding: 0.75rem;
    }

    .top-bar {
        padding: 0.75rem;
    }

    /* Stats grid - single column */
    .stats-grid {
        grid-template-columns: 1fr !important;
        gap: 0.75rem;
    }

    .stat-card {
        padding: 0.75rem;
        font-size: 0.8rem;
    }

    .stat-card h3 {
        font-size: 0.7rem;
    }

    .stat-card .stat-value {
        font-size: 1.3rem;
    }

    /* Cards */
    .anime-card-grid {
        grid-template-columns: 1fr !important;
        gap: 0.75rem;
    }

    /* Tables - Stack on small screens */
    .anime-table {
        font-size: 0.75rem;
    }

    .anime-table th:not(:first-child),
    .anime-table td:not(:first-child) {
        display: none;
    }

    .anime-table tr {
        display: flex;
        flex-direction: column;
        border-bottom: 2px solid rgba(255, 255, 255, 0.1);
        margin-bottom: 1rem;
        padding: 1rem 0;
    }

    .anime-table td {
        display: flex;
        justify-content: space-between;
        padding: 0.5rem 0;
        border: none;
    }

    .anime-table td::before {
        content: attr(data-label);
        font-weight: 600;
        color: var(--text-light);
        flex: 0 0 40%;
    }

    /* Modal */
    .modal-content {
        width: 98vw;
        max-height: 95vh;
        padding: 1rem;
    }

    .modal-content h2 {
        font-size: 1.1rem;
    }

    /* Forms */
    .form-group input,
    .form-group select,
    .form-group textarea {
        font-size: 16px;
        padding: 0.65rem;
    }

    /* Buttons */
    .btn,
    .action-btn {
        padding: 0.65rem 1rem;
        font-size: 0.85rem;
        width: 100%;
    }

    .filter-btn {
        padding: 0.4rem 0.75rem;
        font-size: 0.75rem;
        flex: 0 1 calc(50% - 0.25rem);
    }

    /* Section title */
    .section-title {
        font-size: 1rem;
        margin-bottom: 0.75rem;
    }

    /* Charts - smaller on mobile */
    #monthlyProgressChart,
    #genreDistributionChart,
    #completionChart,
    #scoreDistributionChart,
    #statusDistributionChart,
    #typeDistributionChart,
    #genreStatsChart {
        height: 200px !important;
    }

    /* Activity */
    .activity-item {
        gap: 0.5rem;
        padding: 0.5rem;
    }

    .activity-icon {
        width: 28px;
        height: 28px;
        min-width: 28px;
    }

    .activity-icon i {
        font-size: 0.7rem;
    }

    /* Menu items */
    .menu-item {
        padding: 0.65rem 0.75rem;
        font-size: 0.9rem;
    }

    .menu-item i {
        font-size: 1rem;
    }

    /* Badge */
    .badge {
        padding: 0.2rem 0.5rem;
        font-size: 0.65rem;
    }

    /* Close button */
    .close-modal {
        width: 24px;
        height: 24px;
        font-size: 1.2rem;
    }

    /* Toast */
    .toast {
        padding: 0.8rem;
        font-size: 0.85rem;
        max-width: 95vw;
    }

    /* Watchlist filters */
    .watchlist-filters .filter-btn {
        flex: 0 1 calc(50% - 0.25rem);
    }

    /* Search results */
    .search-result-item {
        padding: 0.5rem;
        font-size: 0.8rem;
    }

    .search-result-item img {
        width: 30px;
        height: 45px;
    }

    /* User avatar hide on very small */
    .user-profile span {
        display: none;
    }
}

/* ===== EXTRA SMALL (under 360px) ===== */
@media (max-width: 360px) {
    .stat-card .stat-value {
        font-size: 1.1rem;
    }

    .stat-card h3 {
        font-size: 0.65rem;
    }

    .btn,
    .action-btn {
        padding: 0.5rem 0.75rem;
        font-size: 0.8rem;
    }

    .filter-btn {
        padding: 0.35rem 0.6rem;
        font-size: 0.7rem;
    }

    #monthlyProgressChart,
    #genreDistributionChart,
    #completionChart,
    #scoreDistributionChart,
    #statusDistributionChart,
    #typeDistributionChart,
    #genreStatsChart {
        height: 180px !important;
    }
}

/* ===== PREVENT TEXT CUTOFF ===== */
* {
    -webkit-text-size-adjust: 100%;
    -moz-text-size-adjust: 100%;
    text-size-adjust: 100%;
}

/* Prevent images from overflowing */
img {
    max-width: 100%;
    height: auto;
}

/* Ensure containers don't overflow */
.container,
.page,
main,
.modal-content,
.sidebar,
.main-content {
    overflow-x: hidden;
}
