/* =========================================
   SIMPLE COURSE MANAGER STYLES
   ========================================= */

/* --- Card Grid --- */
/* --- Card Grid (Now Horizontal Scroll) --- */
.scm-course-grid {
    display: flex;
    overflow-x: auto;
    gap: 20px;
    padding: 20px 5px;
    /* Padding for shadow visibility */
    scroll-snap-type: x mandatory;
    -webkit-overflow-scrolling: touch;
    margin: 20px 0;
    scrollbar-width: thin;
    /* Firefox */
}

/* Scrollbar styling */
.scm-course-grid::-webkit-scrollbar {
    height: 8px;
}

.scm-course-grid::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 4px;
}

.scm-course-grid::-webkit-scrollbar-thumb {
    background: #ccc;
    border-radius: 4px;
}

.scm-course-grid::-webkit-scrollbar-thumb:hover {
    background: #bbb;
}

.scm-course-card {
    min-width: 280px;
    /* Fixed width for card consistency */
    max-width: 320px;
    /* Prevent too wide on desktop if desired, or remove */
    flex-shrink: 0;
    /* Prevent squeezing */
    scroll-snap-align: start;
    background: #fff;
    border: 1px solid #e0e0e0;
    border-radius: 12px;
    overflow: hidden;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.scm-course-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.1);
}

.scm-card-image {
    height: 180px;
    background-size: cover;
    background-position: center;
}

.scm-card-body {
    padding: 20px;
}

.scm-card-title {
    font-size: 1.25rem;
    margin: 0 0 10px 0;
    color: #333;
}

.scm-card-price {
    font-weight: bold;
    color: #27ae60;
    font-size: 1.2rem;
    margin-bottom: 15px;
}

/* --- Buttons --- */
.scm-btn-buy,
.scm-btn-confirm {
    background-color: #3498db;
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 1rem;
    width: 100%;
    transition: background 0.2s;
}

.scm-btn-buy:hover,
.scm-btn-confirm:hover {
    background-color: #2980b9;
}

.scm-btn-watch {
    background-color: #8e44ad;
}

.scm-btn-watch:hover {
    background-color: #9b59b6;
}

/* --- Modals Premium --- */
.scm-modal {
    display: none;
    position: fixed;
    z-index: 10000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(5px);
    overflow-y: auto;
    /* Enable scrolling on the background overlay too */
    padding: 2.5vh 0;
    /* Add top/bottom padding to ensure modal doesn't touch edges */
    box-sizing: border-box;
}

.scm-modal-content {
    background-color: #ffffff;
    margin: 0 auto;
    /* Centered by padding on parent */
    padding: 30px;
    border: none;
    width: 95%;
    max-width: 600px;
    border-radius: 12px;
    position: relative;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.15), 0 0 0 1px rgba(0, 0, 0, 0.05);
    animation: slideIn 0.3s ease;
    /* Ensure content scrolls if too tall */
    max-height: 90vh;
    overflow-y: auto;
}

/* Scroll inside the Lessons List if it gets too long */
#scm-lessons-container {
    max-height: 300px;
    overflow-y: auto;
    border: 1px solid #dce0e4;
    padding: 10px;
    border-radius: 6px;
    background: #fdfdfd;
    margin-bottom: 10px;
}

/* Scrollbar Styling for Webkit */
.scm-modal-content::-webkit-scrollbar,
#scm-lessons-container::-webkit-scrollbar {
    width: 8px;
}

.scm-modal-content::-webkit-scrollbar-track,
#scm-lessons-container::-webkit-scrollbar-track {
    background: #f1f1f1;
}

.scm-modal-content::-webkit-scrollbar-thumb,
#scm-lessons-container::-webkit-scrollbar-thumb {
    background: #ccc;
    border-radius: 4px;
}

.scm-modal-content::-webkit-scrollbar-thumb:hover,
#scm-lessons-container::-webkit-scrollbar-thumb:hover {
    background: #b3b3b3;
}

.scm-video-content {
    background-color: #000;
    padding: 0;
    border: none;
    max-width: 900px;
    /* Video wider */
    width: 100%;
    overflow: hidden;
    /* No scroll bars on video modal */
}

.scm-close,
.scm-close-modal,
.scm-close-video {
    color: #aaa;
    float: right;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
    position: absolute;
    right: 15px;
    top: 10px;
    z-index: 10;
}

.scm-close:hover,
.scm-close-modal:hover,
.scm-close-video:hover {
    color: #000;
    text-decoration: none;
}

/* --- Forms --- */
.scm-form-group {
    margin-bottom: 20px;
}

.scm-form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: #333;
}

.scm-form-group.half {
    flex: 1;
}

.scm-form-group input[type="text"],
.scm-form-group input[type="number"],
.scm-form-group input[type="email"],
.scm-form-group input[type="tel"],
.scm-form-group textarea {
    width: 100%;
    padding: 12px 15px;
    border: 1px solid #dce0e4;
    border-radius: 6px;
    background: #fdfdfd;
    font-size: 0.95rem;
    color: #333;
    transition: all 0.2s;
    box-sizing: border-box;
    display: block;
}

.scm-form-group input:focus,
.scm-form-group textarea:focus {
    border-color: #3498db;
    background: #fff;
    outline: none;
    box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.1);
}

.scm-form-row {
    display: flex;
    gap: 15px;
}

.scm-form-group.half {
    flex: 1;
}

/* --- Video Player Custom --- */
.scm-player-wrapper {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: #000;
    overflow: hidden;
}

#scm-yt-placeholder {
    width: 100%;
    height: 100%;
    pointer-events: none;
    /* Disable native interaction */
}

.scm-full-shield {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: calc(100% - 50px);
    /* Leave space for controls at bottom to be clickable */
    z-index: 10;
    background: transparent;
}

/* Fullscreen Overrides */
#scm-video-container:fullscreen,
#scm-video-container:-webkit-full-screen {
    background-color: #000;
    width: 100% !important;
    height: 100% !important;
    padding-bottom: 0 !important;
    /* Disable 16:9 hack in fullscreen */
    margin: 0 !important;
    position: fixed !important;
    /* Ensure it escapes any modal boundaries */
    top: 0 !important;
    left: 0 !important;
    z-index: 2147483647 !important;
    /* Max Z-index */
}

#scm-video-container:fullscreen iframe,
#scm-video-container:-webkit-full-screen iframe {
    width: 100% !important;
    height: 100% !important;
}

#scm-video-container:fullscreen .scm-player-main,
#scm-video-container:-webkit-full-screen .scm-player-main {
    height: 100% !important;
    width: 100% !important;
    background: #000;
}

#scm-video-container:fullscreen iframe,
#scm-video-container:-webkit-full-screen iframe {
    width: 100% !important;
    height: 100% !important;
}

/* Hide sidebar in fullscreen to focus on video */
#scm-video-container:fullscreen .scm-playlist-sidebar,
#scm-video-container:-webkit-full-screen .scm-playlist-sidebar {
    display: none !important;
}

.scm-custom-controls {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 50px;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding: 0 10px;
    box-sizing: border-box;
    z-index: 20;
    /* Above shield */
    transition: opacity 0.3s;
}

.scm-controls-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
}

.scm-controls-left,
.scm-controls-right {
    display: flex;
    gap: 10px;
}

.scm-ctrl-btn {
    background: none;
    border: none;
    color: #fff;
    font-size: 18px;
    cursor: pointer;
    padding: 5px;
    transition: color 0.2s;
}

.scm-ctrl-btn:hover {
    color: #3498db;
}

.scm-progress-container {
    width: 100%;
    margin-bottom: 5px;
}

#scm-progress-bar {
    width: 100%;
    height: 4px;
    appearance: none;
    -webkit-appearance: none;
    background: #555;
    border-radius: 5px;
    outline: none;
    cursor: pointer;
}

#scm-progress-bar::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 15px;
    height: 15px;
    background: #3498db;
    border-radius: 50%;
    cursor: pointer;
}

/* --- Admin Dashboard --- */
/* --- Admin Dashboard (Premium SaaS Style) --- */
.scm-admin-dashboard {
    background: #ffffff;
    /* Clean white background */
    padding: 30px;
    border-radius: 12px;
    max-width: 1400px;
    width: 98%;
    /* Ensure it takes up space even with padding */
    margin: 30px auto;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
    /* Soft shadow */
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
}

.scm-header-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
    border-bottom: 1px solid #f0f0f0;
    padding-bottom: 15px;
}

.scm-header-actions h2 {
    margin: 0;
    font-size: 1.5rem;
    color: #2c3e50;
    font-weight: 700;
}

/* --- Modern Tabs --- */
.scm-tabs {
    display: flex;
    gap: 10px;
    margin-bottom: 30px;
    border-bottom: 2px solid #eaebed;
}

.scm-tab-link {
    background: transparent;
    border: none;
    border-bottom: 3px solid transparent;
    padding: 12px 24px;
    font-size: 15px;
    font-weight: 600;
    color: #7f8c8d;
    cursor: pointer;
    transition: all 0.3s ease;
    border-radius: 4px 4px 0 0;
}

.scm-tab-link:hover {
    color: #3498db;
    background: rgba(52, 152, 219, 0.05);
}

.scm-tab-link.active {
    color: #3498db;
    border-bottom-color: #3498db;
    background: #fff;
}

/* --- Premium Tables --- */
.scm-table-wrapper {
    background: #fff;
    border-radius: 10px;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
    border: 1px solid #eee;
}

.scm-table-responsive {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.scm-table {
    width: 100%;
    min-width: 800px;
    /* Ensure structure on mobile */
    border-collapse: separate;
    border-spacing: 0;
    background: white;
}

.scm-table th {
    background-color: #f8f9fa;
    color: #555;
    font-weight: 700;
    text-transform: uppercase;
    font-size: 0.8rem;
    padding: 18px 20px;
    border-bottom: 2px solid #eaebed;
    letter-spacing: 0.5px;
}

.scm-table td {
    padding: 16px 20px;
    border-bottom: 1px solid #f0f0f0;
    color: #444;
    vertical-align: middle;
    font-size: 0.95rem;
    white-space: nowrap;
}

.scm-table tr:hover td {
    background-color: #fcfcfc;
}

.scm-table tr:last-child td {
    border-bottom: none;
}

/* Badges & Status */
.scm-badge-success {
    background: #d4edda;
    color: #155724;
    padding: 5px 10px;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 600;
}

.scm-badge-warning {
    background: #fff3cd;
    color: #856404;
    padding: 5px 10px;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 600;
}

/* Buttons */
.scm-action-btn {
    padding: 8px 14px;
    border-radius: 6px;
    border: none;
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 5px;
    transition: transform 0.2s, box-shadow 0.2s;
}

.scm-action-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
}

.scm-btn-primary {
    background: #3498db;
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 6px;
    font-weight: 600;
    cursor: pointer;
    box-shadow: 0 2px 4px rgba(52, 152, 219, 0.3);
}

.scm-btn-primary:hover {
    background: #2980b9;
}

.scm-btn-secondary {
    background: #f8f9fa;
    color: #333;
    border: 1px solid #ddd;
    padding: 10px 20px;
    border-radius: 6px;
    cursor: pointer;
}

.scm-btn-secondary:hover {
    background: #e9ecef;
}

.scm-btn-whatsapp {
    background: #25D366;
    color: white;
}

.scm-btn-edit {
    background: #f39c12;
    color: white;
}

.scm-btn-delete {
    background: #e74c3c;
    color: white;
}

/* Media Queries for Mobile Responsiveness */
@media (max-width: 768px) {

    /* Improve Modal on Mobile */
    .scm-modal-content {
        width: 95%;
        margin: 5% auto;
        padding: 20px;
    }

    /* Make stats grid 1 col */
    .scm-stats-grid {
        grid-template-columns: 1fr;
    }

    /* Force buttons to be clickable */
    .scm-btn-watch,
    .scm-btn-buy {
        cursor: pointer !important;
        position: relative;
        z-index: 50;
    }

    /* --- 1. Scrollable Tabs --- */
    .scm-tabs {
        flex-wrap: nowrap;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        padding-bottom: 5px;
        /* Space for scrollbar */
        scrollbar-width: none;
        /* Hide scrollbar Firefox */
    }

    .scm-tabs::-webkit-scrollbar {
        display: none;
        /* Hide scrollbar Chrome/Safari */
    }

    .scm-tab-link {
        flex-shrink: 0;
        /* Prevent buttons getting squashed */
        white-space: nowrap;
    }

    /* --- 2. Fix Stats & Header Overflow --- */
    .scm-header-actions {
        flex-direction: column;
        align-items: flex-start;
        gap: 15px;
    }

    .scm-header-actions>div {
        width: 100%;
        flex-direction: column;
    }

    .scm-header-actions select,
    .scm-header-actions button {
        width: 100%;
        margin: 0;
    }

    /* --- 3. Fix Config Box Overflow --- */
    /* Target the flex container inside config tab */
    #scm-config-tab div[style*="display:flex"] {
        flex-direction: column !important;
        align-items: stretch !important;
    }

    #scm-shortcode-text {
        word-break: break-all;
        margin-bottom: 10px;
        display: block;
        text-align: center;
    }

    #scm-btn-copy {
        margin-left: 0 !important;
        width: 100%;
    }

    /* --- 4. Video Modal Mobile --- */
    .scm-modal-content.scm-video-content {
        width: 100% !important;
        margin: 0 !important;
        border-radius: 0;
        height: auto !important;
        min-height: 100vh;
        background: black;
        border: none;
        padding: 0 !important;
        display: block !important;
        overflow-y: auto !important;
        /* Allow scroll of whole modal */
    }

    .scm-video-interface {
        display: block !important;
        width: 100%;
        height: auto !important;
        /* Override inline height:100% */
    }

    #scm-video-container {
        /* Reset wrapper to be just a container */
        width: 100% !important;
        height: auto !important;
        padding-bottom: 0 !important;
        position: static !important;
        background: transparent;
    }

    /* Player Main Container - HANDLES RATIO NOW */
    .scm-player-main {
        width: 100% !important;
        flex: none !important;
        position: relative !important;
        height: 0 !important;
        padding-bottom: 56.25% !important;
        /* 16:9 Ratio */
        min-height: 0 !important;
        /* Override inline min-height */
        background: #000;
    }

    /* Playlist Sidebar on Mobile (Below Video) */
    .scm-playlist-sidebar {
        width: 100% !important;
        border-left: none !important;
        border-top: 1px solid #333;
        display: block !important;
        max-height: none !important;
        /* Let it grow or specific height */
        overflow-y: visible !important;
        height: auto !important;
        background: #1a1a1a;
        padding-bottom: 40px;
        /* Spacer */
    }

    /* --- 5. Mobile Forms Fix --- */
    .scm-modal-content {
        width: 95% !important;
        margin: 10px auto !important;
        padding: 15px !important;
    }
}

/* Purchase Form Styling */
#scm-purchase-form input,
#scm-purchase-form select,
#scm-purchase-form textarea {
    width: 100%;
    padding: 12px;
    border: 1px solid #ddd;
    border-radius: 6px;
    margin-bottom: 15px;
    font-size: 16px;
    /* Stop iOS zoom */
    box-sizing: border-box;
    background: #fff;
    color: #333;
}

#scm-purchase-form button {
    width: 100%;
    background-color: #3498db;
    color: white;
    padding: 14px;
    border: none;
    border-radius: 6px;
    font-size: 1.1rem;
    font-weight: bold;
    cursor: pointer;
}

#scm-purchase-form button:hover {
    background-color: #2980b9;
}

/* Stats Dashboard Desktop */
.scm-stats-dashboard {
    margin-top: 20px;
    display: grid;
    grid-template-columns: 3fr 2fr;
    /* Cards left, Top List right */
    gap: 30px;
    align-items: start;
}

@media (max-width: 900px) {
    .scm-stats-dashboard {
        grid-template-columns: 1fr;
        /* Stack on smaller screens */
    }
}

.scm-stats-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    /* 2 columns for cards */
    gap: 20px;
    margin-bottom: 0;
}

#stats-top-courses {
    background: #fdfdfd;
    padding: 15px;
    border-radius: 8px;
    border: 1px solid #eee;
}

.scm-stat-card {
    background: white;
    padding: 20px;
    border-radius: 8px;
    text-align: center;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.05);
}

.scm-stat-number {
    font-size: 2rem;
    font-weight: bold;
    color: #0073aa;
    margin: 10px 0;
}

.scm-stat-label {
    color: #777;
    font-size: 0.9rem;
    text-transform: uppercase;
}