/* ---
* Globals, Fonts & Variables
--- */
@font-face {
    font-family: 'MyFont';
    src: url('fonts/myfont.woff') format('woff');
    font-weight: normal;
    font-style: normal;
    font-display: swap;
}

:root {
    --font-family-base: 'MyFont', sans-serif;
    --background-color: #f7f8fc;
    --text-color: #333;
    --primary-color: #007bff;
    --primary-color-dark: #0056b3;
    --secondary-color: #6c757d;
    --success-color: #28a745;
    --danger-color: #dc3545;
    --white-color: #fff;
    --card-background: #fff;
    --card-border-color: #e0e0e0;
    --card-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
    --input-border-color: #ccc;
    --input-background-color: #fff;
    --border-radius-md: 12px;
    --border-radius-lg: 24px;

    /* Instagram Colors */
    --ig-gradient: linear-gradient(45deg, #f09433 0%, #e6683c 25%, #dc2743 50%, #cc2366 75%, #bc1888 100%);
    --ig-live-gradient: linear-gradient(to right, #C90083, #D22480, #FF5959);
}

body {
    direction: rtl;
    text-align: start;
    font-family: var(--font-family-base);
    background-color: var(--background-color);
    color: var(--text-color);
    margin: 0;
    padding: 0;
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
}

.container {
    width: 90%;
    max-width: 1200px;
    margin: auto;
    padding: 2rem 0;
}

/* ---
* Login Page
--- */
.login-body {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    background-color: #ffffff;
    margin: 0;
    font-family: inherit;
}
.login-container {
    background-color: #ffffff;
    padding: 2.5rem;
    width: 90%;
    max-width: 400px;
    text-align: center;
    border: 1px solid #e0e0e0;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
    border-radius: 20px;
}
.login-container h2 {
    color: #1e3c72;
    margin-bottom: 0.5rem;
    font-size: 1.5rem;
    font-weight: 800;
    margin-block-end: 1.5rem;
    font-family: 'MyFont', sans-serif;
}
.form-group {
    margin-block-end: 1rem;
    text-align: start;
}
.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 600;
}

.form-group input, .form-group select, .form-control {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid #dbdbdb;
    border-radius: var(--border-radius-md);
    box-sizing: border-box;
    background-color: #fafafa;
    font-family: var(--font-family-base);
    font-size: 14px;
}
.form-group input:focus, .form-control:focus {
    border-color: #a8a8a8;
    outline: none;
}

body .btn,
button,
input[type="submit"],
input[type="reset"],
input[type="button"] {
    display: inline-block;
    text-decoration: none;
    padding: 0.5rem 1rem;
    border: none;
    border-radius: var(--border-radius-md);
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    font-family: var(--font-family-base);
    text-align: center;
    transition: opacity 0.3s;
}
input, select, textarea {
    font-family: var(--font-family-base) !important;
}
.btn-primary {
    background: linear-gradient(to right, #007bff, #0056b3);
    color: var(--white-color);
    width: 100%;
    padding: 1rem;
    border-radius: 50px;
    cursor: pointer;
    font-size: 1rem;
    font-weight: bold;
    border: none;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    box-shadow: 0 4px 15px rgba(0, 123, 255, 0.3);
}
.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0, 123, 255, 0.4);
}
.btn-primary:active {
    transform: translateY(0);
}
.error-message {
    color: var(--danger-color);
    margin-block-start: 1rem;
    font-size: 14px;
}


/* ---
* Dashboard
--- */
.dashboard-body {
    background-color: #f7f8fc;
}
.dashboard-header {
    background-color: var(--white-color);
    padding: 1rem 5%;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 1px 2px rgba(0,0,0,0.1);
}
.dashboard-header h1 {
    font-size: 1.5rem;
    margin: 0;
}
.logout-btn {
    color: var(--primary-color);
    text-decoration: none;
    font-weight: bold;
}
.card {
    background: var(--card-background);
    border-radius: var(--border-radius-md);
    box-shadow: var(--card-shadow);
    overflow: hidden;
    border: 1px solid var(--card-border-color);
    margin-bottom: 2rem;
}
.card-header {
    padding: 1.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--card-border-color);
}
.card-header h2 {
    margin: 0;
    font-size: 1.25rem;
}
.card-body {
    padding: 1.5rem;
}
table {
    width: 100%;
    border-collapse: collapse;
    text-align: start;
}
th, td {
    padding: 1rem;
    border-bottom: 1px solid var(--card-border-color);
}
th {
    font-weight: bold;
    color: #888;
}
.actions a {
    margin-inline-end: 0.5rem;
    text-decoration: none;
    padding: 0.4rem 0.8rem;
    border-radius: var(--border-radius-md);
    color: var(--white-color);
    font-size: 0.9rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
.btn-secondary { background-color: var(--secondary-color); }
.btn-danger { background-color: var(--danger-color); }
.btn-info { background-color: #17a2b8; }

.status-badge {
    padding: 3px 8px;
    border-radius: 12px;
    font-size: 0.8em;
    color: #fff;
    text-shadow: 1px 1px 1px rgba(0,0,0,0.1);
}
.status-active {
    background-color: var(--success-color);
}
.status-inactive {
    background-color: var(--secondary-color);
}
.form-group-checkbox {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 1rem;
}
.copy-link-input { width: 100%; padding: 8px; border: 1px solid #ccc; border-radius: 8px; background-color: #f4f4f4; margin-bottom: 5px; }
.copy-btn { cursor: pointer; padding: 8px 10px; border: none; background-color: var(--success-color); color: white; border-radius: 8px; display: block; width: 100%; text-align: center; margin-top: 5px; }
.tooltip { position: relative; display: inline-block; width: 100%; }
.tooltip .tooltiptext { visibility: hidden; width: 120px; background-color: #555; color: #fff; text-align: center; border-radius: 6px; padding: 5px 0; position: absolute; z-index: 1; bottom: 125%; left: 50%; margin-left: -60px; opacity: 0; transition: opacity 0.3s; }
.tooltip:hover .tooltiptext { visibility: visible; opacity: 1; }

/* Grid for forms */
.row {
    display: flex;
    flex-wrap: wrap;
    margin-right: -15px;
    margin-left: -15px;
}
.col-md-6, .col-lg-8 {
    position: relative;
    width: 100%;
    padding-right: 15px;
    padding-left: 15px;
    box-sizing: border-box;
}
@media (min-width: 768px) {
    .col-md-6 { flex: 0 0 50%; max-width: 50%; }
}
@media (min-width: 992px) {
    .col-lg-8 { flex: 0 0 66.666667%; max-width: 66.666667%; }
    .col-lg-4 { flex: 0 0 33.333333%; max-width: 33.333333%; }
}

/* ---
* Webinar Page (Instagram Live Exact Style)
--- */
.webinar-body {
    background-color: #000;
    color: #fff;
    overflow: hidden;
}

.webinar-container {
    width: 100vw;
    height: 100vh;
    height: calc(var(--vh, 1vh) * 100);
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    position: relative;
}

.video-player-wrapper {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: #222;
    z-index: 1;
}

.pre-webinar-content {
    width: 100%;
    height: 100%;
    background-color: #000;
    display: flex;
    align-items: center;
    justify-content: center;
}
.pre-media-img, .pre-media-video {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

#webinar-video {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* Controls Removal */
.plyr { width: 100%; height: 100%; }
.plyr--video .plyr__controls { display: none !important; }
.plyr--video .plyr__control--overlaid { display: none !important; }

/* --- Tap to Unmute Overlay --- */
.tap-to-unmute {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: rgba(255, 255, 255, 0.9);
    z-index: 15;
    background: rgba(0, 0, 0, 0.4);
    padding: 1.5rem;
    border-radius: 50%;
    width: 100px;
    height: 100px;
    backdrop-filter: blur(4px);
    cursor: pointer;
}
.tap-to-unmute i {
    font-size: 48px;
    margin-bottom: 5px;
}
.tap-to-unmute span {
    font-size: 12px;
    white-space: nowrap;
    display: none;
}


/* --- Header Overlay --- */
.webinar-header {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    z-index: 10;
    width: 100%;
    padding: 1rem;
    padding-top: calc(1rem + env(safe-area-inset-top));
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: linear-gradient(to bottom, rgba(0,0,0,0.4) 0%, rgba(0,0,0,0) 100%);
    pointer-events: none;
    box-sizing: border-box;
}
.webinar-header > * { pointer-events: auto; }

/* Host Info (Right Side in RTL) */
.header-host-info {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}
.host-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    overflow: hidden;
    border: 1px solid rgba(255,255,255,0.2);
}
.host-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}
.host-details {
    display: flex;
    flex-direction: column;
}
.host-name {
    font-weight: 600;
    font-size: 0.9rem;
    text-shadow: 0 1px 2px rgba(0,0,0,0.5);
}

/* Controls (Left Side in RTL) */
.header-controls {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.live-badge-container {
    display: flex;
    align-items: center;
}
.live-badge {
    background: var(--ig-live-gradient);
    color: white;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: bold;
    text-transform: uppercase;
    line-height: 1;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.viewer-count {
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: rgba(0,0,0,0.4);
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    min-width: 30px;
    height: 24px;
    backdrop-filter: blur(4px);
}
.viewer-count i {
    font-size: 16px;
    margin-left: 4px;
}
.viewer-count span {
    font-size: 0.75rem;
    font-weight: 600;
}

.exit-btn {
    color: #fff;
    text-decoration: none;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-inline-start: 0.5rem;
    background: rgba(0,0,0,0.3);
    border-radius: 50%;
    width: 28px;
    height: 28px;
    backdrop-filter: blur(4px);
}
.exit-btn i {
    font-size: 20px;
}


/* --- Footer Overlay --- */
.webinar-footer {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 10;
    width: 100%;
    padding: 1rem;
    padding-bottom: calc(1rem + env(safe-area-inset-bottom));
    background: linear-gradient(to top, rgba(0,0,0,0.6) 0%, rgba(0,0,0,0) 100%);
    pointer-events: none;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    box-sizing: border-box;
}
.webinar-footer > * { pointer-events: auto; }

.chat-area {
    width: 100%;
    max-width: 400px;
    max-height: 30vh;
    display: flex;
    flex-direction: column-reverse;
    align-self: flex-start;
    margin-bottom: 0.5rem;
}

.chat-messages {
    overflow-y: auto;
    padding: 0;
    display: flex;
    flex-direction: column-reverse;
    -ms-overflow-style: none;
    scrollbar-width: none;
    mask-image: linear-gradient(to bottom, transparent, black 10%);
    -webkit-mask-image: linear-gradient(to bottom, transparent, black 10%);
}
.chat-messages::-webkit-scrollbar { display: none; }

.chat-message {
    margin-bottom: 0.5rem;
    padding: 0.25rem 0.5rem;
    color: white;
    font-size: 0.9rem;
    display: flex;
    align-items: baseline;
    text-shadow: 0 1px 1px rgba(0,0,0,0.8);
}
.chat-message strong {
    margin-inline-end: 0.5rem;
    font-weight: 600;
    white-space: nowrap;
}

/* --- Footer Actions Row --- */
.footer-actions {
    display: flex;
    align-items: center;
    gap: 1rem;
    width: 100%;
    position: relative;
}

.chat-form {
    flex-grow: 1;
    display: flex;
    align-items: center;
    background: rgba(255, 255, 255, 0.15);
    border-radius: 50px;
    padding: 4px 4px 4px 16px;
    border: 1px solid rgba(255,255,255,0.1);
    transition: background 0.2s;
}
.chat-form:focus-within {
    background: rgba(0, 0, 0, 0.5);
    border-color: rgba(255,255,255,0.3);
}

.chat-form input {
    flex-grow: 1;
    border: none;
    background: transparent;
    color: #fff;
    padding: 0.5rem;
    font-family: var(--font-family-base);
    font-size: 14px;
}
.chat-form input:focus { outline: none; }
.chat-form input::placeholder { color: rgba(255,255,255,0.8); }

.chat-form button {
    background: transparent;
    border: none;
    color: #fff;
    cursor: pointer;
    padding: 0.4rem;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0.8;
}
.chat-form button i {
    transform: rotate(180deg); /* Point left for RTL */
}
.chat-form button:hover { opacity: 1; }

.action-buttons {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.icon-btn {
    background: transparent;
    border: none;
    color: #fff;
    padding: 0;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}
.icon-btn i {
    font-size: 28px;
    filter: drop-shadow(0 1px 2px rgba(0,0,0,0.5));
}
.heart-btn i {
    font-size: 30px;
}
.share-btn i {
    transform: rotate(-20deg);
    margin-top: -4px;
}

/* --- Floating Hearts Animation --- */
.floating-heart {
    position: absolute;
    bottom: 50px;
    left: 20px;
    color: #e91e63;
    font-size: 24px;
    pointer-events: none;
    animation: floatUp 2s ease-out forwards;
    z-index: 100;
}

.floating-heart:nth-child(odd) {
    color: #ff5252;
}
.floating-heart:nth-child(even) {
    color: #e040fb;
}

@keyframes floatUp {
    0% {
        opacity: 1;
        transform: translateY(0) scale(0.5) rotate(0deg);
    }
    20% {
        transform: translateY(-20px) scale(1.2) rotate(-10deg);
    }
    100% {
        opacity: 0;
        transform: translateY(-200px) scale(1) rotate(10deg);
    }
}


/* --- Countdown Timer --- */
.countdown-timer {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: #fff;
    background-color: rgba(0, 0, 0, 0.8);
    padding: 2rem;
    border-radius: 16px;
    z-index: 20;
    text-align: center;
    font-size: 1.2rem;
    line-height: 1.6;
    display: none;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    backdrop-filter: blur(10px);
    box-shadow: 0 10px 30px rgba(0,0,0,0.5);
    width: 80%;
    max-width: 300px;
}
.countdown-time {
    font-size: 1.8rem;
    font-weight: bold;
    color: #0095f6;
    margin-top: 0.5rem;
}

/* --- Toast Notification --- */
.toast-notification {
    position: absolute;
    top: 20%;
    left: 50%;
    transform: translateX(-50%);
    background-color: rgba(0, 0, 0, 0.8);
    color: white;
    padding: 10px 20px;
    border-radius: 20px;
    z-index: 100;
    backdrop-filter: blur(4px);
    text-align: center;
    font-size: 14px;
}

/* --- Responsiveness --- */
@media screen and (max-width: 768px) {
    .dashboard-header, .card-header {
        flex-direction: column;
        gap: 1rem;
        padding: 1rem;
        text-align: center;
    }
    table { display: block; overflow-x: auto; }
    .login-container { padding: 1.5rem; width: 100%; border: none; background: transparent; }
    .login-body { background-color: #fff; align-items: flex-start; padding-top: 20vh; }
    .form-group input { background-color: #fafafa; border: 1px solid #dbdbdb; }

    .webinar-header { padding-top: calc(1rem + env(safe-area-inset-top)); }
    .chat-area { max-height: 35vh; width: 85%; }
}

/* --- STRICT VIDEO LAYOUT FIXES --- */
/* Force Plyr wrapper to fill the container completely, ignoring aspect ratio calculations */
.plyr,
.plyr__video-wrapper {
    width: 100% !important;
    height: 100% !important;
    background: transparent !important;
    aspect-ratio: unset !important;
    margin: 0 !important;
    padding: 0 !important;
    position: absolute !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    border-radius: 0 !important; /* Ensure no rounding on video container */
}

/* Force video element to cover the area */
.plyr video,
#webinar-video {
    object-fit: cover !important;
    width: 100% !important;
    height: 100% !important;
    position: absolute !important;
    top: 0 !important;
    left: 0 !important;
}

/* Ensure container has no gaps */
.video-player-wrapper {
    overflow: hidden;
}
