/* ========================================
   RESPONSIVE DESIGN - MOBILE FIRST
   ======================================== */

/* Tablet & Below (768px) */
@media (max-width: 768px) {

    /* Container */
    .container {
        padding: 0 1rem;
    }

    /* Sidebar */
    .sidebar {
        transform: translateX(-100%);
        box-shadow: 2px 0 10px rgba(0, 0, 0, 0.3);
    }

    .sidebar.active {
        transform: translateX(0);
    }

    /* Main Content */
    .main-content {
        margin-left: 0;
        padding: 1rem;
    }

    /* Header */
    .header {
        flex-direction: column;
        gap: 1rem;
        padding: 1rem;
    }

    .header-title h1 {
        font-size: 1.5rem;
    }

    .header-actions {
        width: 100%;
        justify-content: space-between;
        display: flex;
        align-items: center;
    }

    .menu-toggle-admin {
        display: block !important;
    }

    .user-balance {
        font-size: 0.9rem;
        padding: 0.5rem 1rem;
    }

    /* Stats Grid */
    .stats-grid {
        grid-template-columns: 1fr;
        gap: 1rem;
    }

    /* Admin Dashboard Stats - Single column on mobile */
    .stat-card {
        padding: 1rem;
    }
    
    .stat-value {
        font-size: 1.5rem;
    }
    
    .stat-label {
        font-size: 0.8rem;
    }
    
    .stat-icon {
        width: 40px;
        height: 40px;
        font-size: 1.1rem;
    }

    /* Raffle Grid */
    .raffle-grid {
        grid-template-columns: 1fr;
        gap: 1rem;
    }

    /* Glass Card */
    .glass-card {
        padding: 1rem;
    }

    /* Buttons */
    .btn {
        padding: 0.625rem 1.25rem;
        font-size: 0.9rem;
    }

    /* Form Controls */
    .form-control {
        font-size: 16px;
        /* Prevent zoom on iOS */
    }

    /* Tables */
    .table-container {
        overflow-x: auto;
    }

    table {
        min-width: 600px;
    }

    th,
    td {
        padding: 0.75rem;
        font-size: 0.85rem;
    }

    /* Language Dropdown */
    .lang-dropdown-btn {
        min-width: 130px;
        font-size: 0.85rem;
        padding: 0.4rem 0.8rem;
    }

    .lang-dropdown-menu {
        min-width: 150px;
    }

    /* Modal */
    .modal-content {
        width: 95%;
        padding: 1.5rem;
    }

    /* Navbar (index.php) */
    .navbar {
        padding: 1rem;
    }

    .navbar-content {
        justify-content: space-between;
        align-items: center;
    }

    .navbar-logo {
        font-size: 1.2rem;
        order: 1;
    }

    .navbar-menu {
        flex-direction: column;
        width: 100%;
        gap: 0.5rem;
        position: fixed;
        top: 70px;
        left: 0;
        right: 0;
        background: var(--bg-secondary);
        border-bottom: 1px solid var(--border-color);
        padding: 1rem;
        z-index: 999;
        display: none !important;
    }

    .navbar-menu.active {
        display: flex !important;
    }

    .navbar-menu li {
        width: 100%;
    }

    .navbar-menu a {
        display: block;
        padding: 0.75rem;
        text-align: center;
        color: var(--text-primary);
    }

    .navbar-toggle {
        display: block !important;
        order: 2;
    }
    
    /* RTL Navbar Mobile */
    body.rtl .navbar-logo {
        order: 2;
    }
    
    body.rtl .navbar-toggle {
        order: 1;
    }
    
    body.rtl .navbar-menu {
        right: auto;
        left: 0;
        direction: rtl;
        text-align: right;
    }

    /* Hero Section */
    .hero {
        padding: 3rem 1rem;
        min-height: 60vh;
    }

    .hero-title {
        font-size: 2rem;
    }

    .hero-subtitle {
        font-size: 1rem;
    }

    /* Footer */
    .footer-content {
        grid-template-columns: 1fr;
        gap: 2rem;
    }

    .footer-section {
        text-align: center;
    }
}

/* Mobile (480px) */
@media (max-width: 480px) {

    /* Typography */
    h1 {
        font-size: 1.75rem;
    }

    h2 {
        font-size: 1.5rem;
    }

    h3 {
        font-size: 1.25rem;
    }

    /* Header */
    .header-title h1 {
        font-size: 1.25rem;
    }

    .header-title p {
        font-size: 0.8rem;
    }

    /* Stats Card */
    .stat-value {
        font-size: 1.5rem;
    }

    .stat-label {
        font-size: 0.8rem;
    }

    /* Raffle Card */
    .raffle-title {
        font-size: 1.1rem;
    }

    .raffle-description {
        font-size: 0.85rem;
    }

    .raffle-info {
        flex-direction: column;
        gap: 0.5rem;
    }

    /* Buttons */
    .btn {
        width: 100%;
        justify-content: center;
    }

    /* Tables Mobile - Extra Small */
    .table-container {
        overflow-x: auto;
    }
    
    table {
        font-size: 0.75rem;
        min-width: 500px;
    }
    
    th,
    td {
        padding: 0.5rem;
    }
    
    .stat-icon {
        width: 40px;
        height: 40px;
        font-size: 1.1rem;
    }
    
    .stat-card {
        padding: 0.75rem;
    }

    /* Language Dropdown */
    .lang-dropdown-btn {
        min-width: 110px;
        font-size: 0.8rem;
    }

    /* Hero */
    .hero-title {
        font-size: 1.5rem;
    }

    .hero-subtitle {
        font-size: 0.9rem;
    }

    /* Payment Options */
    .payment-card {
        padding: 1rem;
    }

    /* Bank Info */
    .bank-info-item {
        flex-direction: column;
        gap: 0.5rem;
        text-align: center;
    }

    /* RTL Mobile Table */
    body.rtl table {
        text-align: right;
    }

    body.rtl th,
    body.rtl td {
        text-align: right;
    }
}

/* Landscape Mobile */
@media (max-width: 768px) and (orientation: landscape) {
    .hero {
        min-height: 100vh;
    }

    .sidebar {
        width: 250px;
    }
}

/* Touch Device Optimizations */
@media (hover: none) and (pointer: coarse) {

    /* Larger touch targets */
    .btn,
    .lang-dropdown-btn,
    .sidebar-nav a {
        min-height: 44px;
    }

    /* Remove hover effects on touch */
    .glass-card:hover,
    .stat-card:hover,
    .raffle-card:hover {
        transform: none;
    }

    /* Tap highlight */
    * {
        -webkit-tap-highlight-color: rgba(99, 102, 241, 0.2);
    }
}

/* Mobile Menu Toggle Button */
.menu-toggle {
    position: fixed;
    top: 1rem;
    left: 1rem;
    z-index: 1001;
    background: var(--primary);
    color: white;
    border: none;
    padding: 0.75rem 1rem;
    border-radius: var(--radius-md);
    cursor: pointer;
    display: none;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

@media (max-width: 768px) {
    .menu-toggle {
        display: block;
    }

    body.rtl .menu-toggle {
        left: auto;
        right: 1rem;
    }
}

/* Sidebar Overlay */
.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 999;
}

@media (max-width: 768px) {
    .sidebar-overlay.active {
        display: block;
    }
}

/* Responsive Images */
img {
    max-width: 100%;
    height: auto;
}

/* Responsive Tables */
@media (max-width: 768px) {
    .table-responsive {
        display: block;
        width: 100%;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    /* RTL Table Fix for Mobile */
    body.rtl .table-responsive {
        direction: rtl;
    }

    body.rtl table {
        text-align: right;
    }

    body.rtl tbody tr {
        text-align: right;
    }

    body.rtl th {
        text-align: right;
    }

    body.rtl td {
        text-align: right;
    }

    body.rtl .table-container {
        direction: rtl;
    }
}

/* Grid Adjustments */
@media (max-width: 768px) {
    [style*="display: grid"] {
        grid-template-columns: 1fr !important;
    }
}

/* Spacing Adjustments */
@media (max-width: 768px) {
    .page-content {
        padding: 0;
    }

    section {
        padding: 2rem 1rem;
    }
}

/* Light Mode Mobile */
body.light-mode .menu-toggle {
    background: var(--primary);
    color: white;
}

body.light-mode .sidebar-overlay {
    background: rgba(0, 0, 0, 0.3);
}

/* ========================================
   RTL MOBILE FIXES
   ======================================== */

@media (max-width: 768px) {
    /* RTL Sidebar */
    body.rtl .sidebar {
        left: auto;
        right: 0;
        transform: translateX(100%);
    }

    body.rtl .sidebar.active {
        transform: translateX(0);
    }

    body.rtl .main-content {
        margin-left: 0;
        margin-right: 0;
    }

    body.rtl .menu-toggle {
        left: auto;
        right: 1rem;
    }
    
    body.rtl .menu-toggle-admin {
        order: 1;
    }

    /* RTL Header */
    body.rtl .header-title {
        text-align: right;
    }

    body.rtl .header-actions {
        justify-content: space-between;
    }

    /* RTL Stats Grid */
    body.rtl .stats-grid {
        direction: rtl;
    }

    body.rtl .stat-card {
        text-align: right;
    }

    /* RTL Raffle Grid */
    body.rtl .raffle-grid {
        direction: rtl;
    }

    body.rtl .raffle-card {
        text-align: right;
    }

    body.rtl .raffle-badge {
        right: auto;
        left: 1rem;
    }

    body.rtl .raffle-content {
        direction: rtl;
        text-align: right;
    }

    /* RTL Table */
    body.rtl .table-container {
        direction: rtl;
        overflow-x: auto;
    }

    body.rtl table {
        text-align: right;
        direction: rtl;
    }

    body.rtl thead {
        direction: rtl;
    }

    body.rtl th {
        text-align: right;
        direction: rtl;
    }

    body.rtl td {
        text-align: right;
        direction: rtl;
    }

    /* RTL Glass Card */
    body.rtl .glass-card {
        text-align: right;
        direction: rtl;
    }

    body.rtl .glass-card h2 {
        justify-content: flex-end;
    }

    /* RTL Progress Text */
    body.rtl .progress-text {
        flex-direction: row-reverse;
    }

    /* RTL Modal */
    body.rtl .modal-header {
        flex-direction: row-reverse;
    }

    /* RTL Buttons */
    body.rtl .btn {
        flex-direction: row-reverse;
    }

    /* RTL Icons in Lists */
    body.rtl .sidebar-nav a {
        flex-direction: row-reverse;
    }

    body.rtl .sidebar-nav a i {
        order: 2;
    }

    /* RTL Page Content */
    body.rtl .page-content {
        direction: rtl;
        text-align: right;
    }
}

@media (max-width: 480px) {
    /* Extra RTL Adjustments for Small Screens */
    body.rtl .stat-value {
        text-align: right;
    }

    body.rtl .stat-label {
        text-align: right;
    }

    body.rtl .raffle-info {
        flex-direction: column;
        text-align: right;
    }

    body.rtl .raffle-info-item {
        text-align: right;
    }

    body.rtl .payment-card {
        text-align: right;
    }

    body.rtl .bank-info-item {
        text-align: center;
    }

    /* RTL Header Alignment */
    body.rtl .header {
        text-align: right;
    }

    body.rtl .header-title {
        text-align: right;
    }

    body.rtl .header-actions {
        width: 100%;
        justify-content: flex-start;
        flex-direction: row-reverse;
    }
}