/* استيراد التصميم المتجاوب */
@import 'responsive.css';

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

body {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
}

.login-container {
    width: 100%;
    max-width: 400px;
    padding: 20px;
}

.login-box {
    background: white;
    padding: 40px;
    border-radius: 10px;
    box-shadow: 0 0 20px rgba(0, 0, 0, 0.1);
}

h2 {
    color: #333;
    text-align: center;
    margin-bottom: 30px;
}

.form-group {
    margin-bottom: 20px;
}

label {
    display: block;
    margin-bottom: 8px;
    color: #555;
}

input {
    width: 100%;
    padding: 12px;
    border: 1px solid #ddd;
    border-radius: 5px;
    font-size: 16px;
    transition: border-color 0.3s;
}

input:focus {
    border-color: #667eea;
    outline: none;
}

.btn-login {
    width: 100%;
    padding: 12px;
    background: #667eea;
    color: white;
    border: none;
    border-radius: 5px;
    font-size: 16px;
    cursor: pointer;
    transition: background 0.3s;
}

.btn-login:hover {
    background: #764ba2;
}

.alert {
    padding: 12px;
    border-radius: 5px;
    margin-bottom: 20px;
    text-align: center;
}

.alert-danger {
    background: #ffe5e5;
    color: #ff3333;
    border: 1px solid #ffcccc;
}

/* لوحة التحكم */
.dashboard {
    background: #f5f6fa;
    min-height: 100vh;
}

.sidebar {
    width: 250px;
    height: 100vh;
    background: #2c3e50;
    position: fixed;
    right: 0;
    top: 0;
    color: white;
    transition: all 0.3s ease;
    z-index: 1000;
    box-shadow: -2px 0 5px rgba(0, 0, 0, 0.1);
    visibility: visible;
    opacity: 1;
}

.sidebar.collapsed {
    width: 0;
    overflow: hidden;
    padding: 0;
    visibility: hidden;
    opacity: 0;
}

.sidebar-header {
    padding: 15px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.logo h2 {
    margin: 0;
    font-size: 1.2rem;
    color: white;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    text-align: center;
}

.sidebar-toggle {
    position: fixed;
    right: 250px;
    top: 20px;
    background: #34495e;
    border: 2px solid #2c3e50;
    color: white;
    cursor: pointer;
    padding: 12px 15px;
    border-radius: 5px 0 0 5px;
    z-index: 1001;
    transition: all 0.3s ease;
    box-shadow: -2px 0 10px rgba(0, 0, 0, 0.2);
}

.sidebar-toggle:hover {
    background: #2c3e50;
    border-color: #34495e;
}

.sidebar-toggle i {
    font-size: 1.2rem;
    transition: transform 0.3s ease;
}

.sidebar.collapsed ~ .sidebar-toggle {
    right: 0;
    border-radius: 5px;
    margin: 10px;
}

.sidebar.collapsed ~ .sidebar-toggle i {
    transform: rotate(180deg);
}

.nav-menu {
    padding: 15px 0;
    opacity: 1;
    transition: opacity 0.3s ease;
}

.sidebar.collapsed .nav-menu {
    opacity: 0;
    visibility: hidden;
}

.nav-link {
    display: flex;
    align-items: center;
    padding: 12px 15px;
    color: #ecf0f1;
    text-decoration: none;
    transition: all 0.3s ease;
    opacity: 1;
}

.nav-link i,
.nav-link .nav-text {
    transition: opacity 0.3s ease;
}

.sidebar.collapsed .nav-link,
.sidebar.collapsed .nav-link i,
.sidebar.collapsed .nav-link .nav-text {
    opacity: 0;
    visibility: hidden;
}

.nav-link:hover {
    background: rgba(255, 255, 255, 0.1);
}

.nav-link.active {
    background: #34495e;
}

.nav-link i {
    width: 30px;
    text-align: center;
    font-size: 1.1rem;
}

.nav-link .nav-text {
    margin-right: 10px;
    white-space: nowrap;
}

.sidebar.collapsed .nav-text {
    display: none;
}

.sidebar.collapsed .logo h2 {
    display: none;
}

.main-content {
    margin-right: 250px;
    padding: 20px;
    transition: all 0.3s ease;
}

.main-content.expanded {
    margin-right: 0;
}

.card {
    background: white;
    border-radius: 10px;
    padding: 20px;
    margin-bottom: 20px;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.05);
}

/* Table Styles */
.table-responsive {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    margin-bottom: 1rem;
    background: white;
    border-radius: 10px;
    box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
    position: relative;
}

.table-responsive::after {
    content: 'اسحب للرؤية المزيد ←';
    display: none;
    text-align: center;
    font-size: 0.8rem;
    color: #666;
    padding: 5px;
    background: #f8f9fa;
    border-bottom: 1px solid #eee;
    position: sticky;
    top: 0;
    right: 0;
    left: 0;
    z-index: 1;
}

.table {
    width: 100%;
    margin-bottom: 0;
    border-collapse: collapse;
    background: white;
}

.table th,
.table td {
    padding: 12px;
    text-align: right;
    border-bottom: 1px solid #eee;
    min-width: 120px; /* Minimum width for cells */
}

.table th {
    background: #f8f9fa;
    font-weight: 600;
    color: #2c3e50;
    position: sticky;
    top: 0;
    z-index: 1;
}

.table tbody tr:hover {
    background: #f8f9fa;
}

/* Mobile Table Styles */
@media (max-width: 768px) {
    .table-responsive {
        margin-left: -15px;
        margin-right: -15px;
        width: calc(100% + 30px);
        border-radius: 0;
        max-width: 100vw;
    }
    
    .table-responsive::after {
        display: block;
    }

    .table {
        width: max-content;
        min-width: 100%;
    }

    .table th,
    .table td {
        font-size: 0.9rem;
        padding: 8px;
        white-space: nowrap;
    }

    /* Actions column should not wrap */
    .table td:last-child {
        white-space: nowrap;
        min-width: 120px;
    }

    /* Make sure buttons in tables don't overflow */
    .table .btn {
        padding: 4px 8px;
        font-size: 0.8rem;
    }
}

/* Fix for nested tables */
.table-responsive .table-responsive {
    margin: 0;
    width: 100%;
    box-shadow: none;
}

/* Fix for cards containing tables */
.card .table-responsive,
.dashboard-card .table-responsive {
    margin-left: -20px;
    margin-right: -20px;
    width: calc(100% + 40px);
    border-radius: 0;
}

/* Ensure proper spacing in main content */
.main-content {
    overflow-x: hidden;
}

/* Dashboard specific fixes */
.dashboard-card {
    overflow: hidden;
    padding: 20px 0;
}

.dashboard-card .table-responsive {
    border-radius: 0;
    box-shadow: none;
}

/* تنسيق بطاقة المجموعة */
.group-card {
    border: 1px solid #ddd;
    padding: 15px;
    border-radius: 5px;
    margin-bottom: 20px;
}

.group-card h4 {
    margin-top: 0;
    color: #333;
}

.button-group {
    display: flex;
    gap: 10px;
    margin-top: 10px;
}

.btn-danger {
    background-color: #dc3545;
    border-color: #dc3545;
    color: white;
}

.btn-danger:hover {
    background-color: #c82333;
    border-color: #bd2130;
}

/* تنسيق المجموعات غير النشطة */
.inactive-group {
    background-color: #f8f9fa;
    border-color: #e9ecef;
}

.inactive-group h4 {
    color: #6c757d;
}

.text-danger {
    color: #dc3545;
    font-weight: bold;
}

.mt-2 {
    margin-top: 1rem;
}

/* Responsive Adjustments */
@media (max-width: 768px) {
    .sidebar {
        width: 250px;
    }
    
    .sidebar.collapsed {
        width: 0;
    }
    
    .main-content {
        margin-right: 250px;
    }
    
    .main-content.expanded {
        margin-right: 0;
    }
    
    .sidebar-toggle {
        padding: 10px 12px;
    }
}

/* Card Grid for Dashboard */
.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.dashboard-card {
    background: white;
    padding: 20px;
    border-radius: 10px;
    box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
}

/* Responsive Grid Adjustments */
@media (max-width: 768px) {
    .dashboard-grid {
        grid-template-columns: 1fr;
        padding: 0 10px;
    }

    .card {
        margin-bottom: 15px;
    }

    .main-content {
        padding: 15px 10px;
    }
}
