/* -------------------- Base & Typography -------------------- */
* {
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Arial, sans-serif;
    background-color: #121212;
    color: #ffffff;
    margin: 0;
    padding: 0;
}

a {
    color: #c82333;
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

h1, h2, h3, h4, h5, h6 {
    margin-top: 0;
    margin-bottom: 0.5rem;
    font-weight: 500;
}

/* -------------------- Topbar -------------------- */
.topbar {
    background-color: #1e1e1e;
    padding: 0 24px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    height: 60px;
    border-bottom: 1px solid #333;
    position: sticky;
    top: 0;
    z-index: 1020;
}

.topbar .logo a {
    color: #c82333;
    font-size: 24px;
    font-weight: bold;
    text-decoration: none;
}
.topbar .logo a i {
    margin-right: 8px;
}

.topbar-right {
    display: flex;
    align-items: center;
}

.topbar-right span {
    margin-right: 16px;
    color: #ccc;
}

.topbar-right a {
    color: #ccc;
    margin-left: 16px;
    font-size: 14px;
}
.topbar-right a:hover {
    color: #fff;
    text-decoration: none;
}

.topbar-right .profile-img-small {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    margin-right: 8px;
    object-fit: cover;
    border: 2px solid #555;
}

/* -------------------- Main Container -------------------- */
.container {
    padding: 24px;
}

/* -------------------- Card System -------------------- */
.card {
    background-color: #1e1e1e;
    border: 1px solid #333;
    border-radius: 8px;
    margin-bottom: 24px;
}

.card-header {
    background-color: #c82333;
    padding: 12px 16px;
    border-bottom: 1px solid #333;
    border-top-left-radius: 8px;
    border-top-right-radius: 8px;
    display: flex;
    align-items: center;
    color: #fff;
    font-weight: bold;
}
.card-header i {
    margin-right: 8px;
}

.card-body {
    padding: 24px;
}

/* -------------------- Buttons -------------------- */
.btn {
    display: inline-block;
    font-weight: 400;
    color: #fff;
    text-align: center;
    vertical-align: middle;
    cursor: pointer;
    user-select: none;
    background-color: transparent;
    border: 1px solid transparent;
    padding: 8px 16px;
    font-size: 14px;
    line-height: 1.5;
    border-radius: 4px;
    transition: all 0.15s ease-in-out;
}

.btn-primary {
    background-color: #c82333;
    border-color: #c82333;
}
.btn-primary:hover {
    background-color: #c62828;
    border-color: #c62828;
}

.btn-success {
    background-color: #43a047;
    border-color: #43a047;
}
.btn-success:hover {
    background-color: #2e7d32;
    border-color: #2e7d32;
}

.btn-danger {
    background-color: #dc3545;
    border-color: #dc3545;
}
.btn-danger:hover {
    background-color: #c82333;
    border-color: #bd2130;
}

.btn-secondary {
    background-color: #555;
    border-color: #555;
}
.btn-secondary:hover {
    background-color: #444;
    border-color: #444;
}

.btn-sm {
    padding: 4px 8px;
    font-size: 12px;
}

/* -------------------- Forms -------------------- */
.form-group {
    margin-bottom: 1rem;
}

.form-control {
    display: block;
    width: 100%;
    padding: 10px;
    font-size: 14px;
    line-height: 1.5;
    color: #fff;
    background-color: #333;
    border: 1px solid #555;
    border-radius: 4px;
}
.form-control:focus {
    color: #fff;
    background-color: #444;
    border-color: #c82333;
    outline: 0;
    box-shadow: none;
}
.form-control[readonly] {
    background-color: #2a2a2a;
    opacity: 0.7;
}

.form-text {
    display: block;
    margin-top: 5px;
    font-size: 12px;
}
.text-success { color: #43a047 !important; }
.text-danger { color: #c82333 !important; }
.text-info { color: #2196F3 !important; }

/* -------------------- Image Upload Enhancements -------------------- */
#image-preview-container {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
    gap: 10px;
    padding: 10px;
    border: 2px dashed #555;
    border-radius: 8px;
    min-height: 124px; /* 100px + 2*10px padding + 2*2px border */
}

.upload-slot {
    width: 100px;
    height: 100px;
    background-color: #333;
    border-radius: 8px;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    color: #777;
    font-size: 36px;
    transition: background-color 0.2s, color 0.2s;
}
.upload-slot:hover {
    background-color: #c82333;
    color: #fff;
}

.upload-slot-preview {
    width: 100px;
    height: 100px;
    position: relative;
    border-radius: 8px;
    overflow: hidden;
    cursor: grab;
}
.upload-slot-preview img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}
.upload-slot-preview.dragging {
    opacity: 0.5;
}

.remove-image-btn {
    position: absolute;
    top: 4px;
    right: 4px;
    width: 20px;
    height: 20px;
    background-color: rgba(0, 0, 0, 0.7);
    color: #fff;
    border: none;
    border-radius: 50%;
    font-size: 14px;
    line-height: 20px;
    text-align: center;
    cursor: pointer;
    opacity: 0;
    transition: opacity 0.2s;
}
.upload-slot-preview:hover .remove-image-btn {
    opacity: 1;
}


/* -------------------- Tables -------------------- */
.table {
    width: 100%;
    margin-bottom: 1rem;
    color: #fff;
    border-collapse: collapse;
}
.table th, .table td {
    padding: 12px;
    vertical-align: middle;
    border-top: 1px solid #333;
    text-align: left;
}
.table thead th {
    vertical-align: bottom;
    border-bottom: 2px solid #444;
    background-color: #2a2a2a;
}
.table tbody tr:hover {
    background-color: #2a2a2a;
}
.table .avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    margin-right: 12px;
    object-fit: cover;
}

/* -------------------- Dashboard -------------------- */
.dashboard-stats {
     display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
}


.stat-card {
    background-color: #f8f9fa;
    border-radius: 8px;
    padding: 20px;
    text-align: center;
    color: #333;
    transition: transform 0.2s, box-shadow 0.2s;
    border: 1px solid #e9ecef;
}

.stat-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

.stat-card h3 {
    margin: 0;
    font-size: 2.5rem;
}

.stat-card p {
    margin: 5px 0 0;
    font-size: 1rem;
    font-weight: 500;
}

.stat-card.blue {
    background-color: #007bff;
    color: white;
}

.stat-card.red {
    background-color: #c82333; /* A darker, more accessible red */
    color: white;
}

.stat-card.green {
    background-color: #28a745;
    color: white;
}

.stat-card.purple {
    background-color: #6f42c1;
    color: white;
}

.stat-card-link {
    text-decoration: none;
    color: inherit;

}
.stat-card-link:hover .stat-card {
     text-decoration: none;
}

/* -------------------- Box Grid -------------------- */
.box-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 20px;
}
.box-card {
    background: #1e1e1e;
    border-radius: 8px;
    overflow: hidden;
    text-decoration: none;
    color: #fff;
    border: 1px solid #333;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}
.box-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 20px rgba(0,0,0,0.2);
}
.box-card img {
    width: 100%;
    height: 150px;
    object-fit: cover;
}
.box-card-body {
    padding: 16px;
}
.box-card-body h4 {
    margin: 0 0 5px;
    font-size: 1rem;
}
.box-card-body p {
     margin: 0;
    color: #aaa;
    font-size: 0.9rem;
}
.box-card-actions {
    display: flex;
    justify-content: flex-end;
    gap: 5px;
    padding-top: 10px;
    margin-top: 10px;
    border-top: 1px solid #333;
}

/* This rule is a duplicate and can be removed. */

/* -------------------- Pagination -------------------- */
.pagination {
    display: flex;
    justify-content: center;
    padding: 0;
    list-style: none;
    margin-top: 24px;
}
.pagination a, .pagination span {
    color: #fff;
    padding: 8px 12px;
    margin: 0 4px;
    border: 1px solid #333;
    border-radius: 4px;
    text-decoration: none;
}
.pagination a:hover {
    background-color: #c82333;
    border-color: #c82333;
}
.pagination .active {
    background-color: #c82333;
    border-color: #c82333;
    cursor: default;
}

/* -------------------- Profile Page -------------------- */
.profile-picture-section {
    text-align: center;
    margin-bottom: 24px;
}
.profile-img-large {
    width: 120px;
    height: 120px;
    border-radius: 50%;
    object-fit: cover;
    border: 4px solid #333;
    margin-bottom: 16px;
}

/* -------------------- Alerts -------------------- */
.alert {
    padding: 15px;
    margin-bottom: 20px;
    border: 1px solid transparent;
    border-radius: 4px;
}
.alert-danger {
    color: #fff;
    background-color: #c82333;
    border-color: #c82333;
}
.alert-success {
    color: #fff;
    background-color: #43a047;
    border-color: #43a047;
}

/* -------------------- Responsive -------------------- */
@media (max-width: 768px) {
    .topbar {
        padding: 0 16px;
    }
    .container {
        padding: 16px;
    }
    .card-body {
        padding: 16px;
    }
}

@media (max-width: 576px) {
    .topbar {
        flex-direction: column;
        height: auto;
        padding: 12px;
    }
    .topbar .logo {
        margin-bottom: 8px;
    }
    .topbar-right {
        margin-top: 8px;
    }
    .btn {
      display: inline-block;
        width: 100%;
        margin-bottom: 8px;
    }
    .table, .table thead, .table tbody, .table th, .table td, .table tr {
        display: block;
    }
    .table thead {
        display: none;
    }
    .table tr {
        margin-bottom: 15px;
        border: 1px solid #333;
        border-radius: 4px;
    }
    .table td {
        border: none;
        border-bottom: 1px solid #333;
        position: relative;
        padding-left: 50%;
        text-align: right;
    }
    .table td:before {
        content: attr(data-label);
        position: absolute;
        left: 10px;
        width: 45%;
        padding-right: 10px;
        white-space: nowrap;
        text-align: left;
        font-weight: bold;
    }
}