/* Global Styles */
:root {
    --primary-color: #3498db;
    --secondary-color: #2980b9;
    --success-color: #2ecc71;
    --danger-color: #e74c3c;
    --warning-color: #f39c12;
    --info-color: #1abc9c;
    --light-color: #ecf0f1;
    --dark-color: #2c3e50;
    --gray-color: #95a5a6;
    --white-color: #ffffff;
    --black-color: #000000;
    
    --sidebar-width: 250px;
    --sidebar-collapsed-width: 0;
    --top-bar-height: 60px;
    
    --shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    --transition: all 0.3s ease;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

/* Modal and overlay fixes */
.modal-backdrop {
    z-index: 1040 !important;
}

.modal {
    z-index: 1050 !important;
}

.btn {
    position: relative;
    z-index: auto;
}

/* Prevent any parent from blocking clicks */
.content, .main-content, .dashboard-container {
    position: static !important;
    overflow: visible !important;
}

/* Make sure DataTables elements are visible */
.dataTables_wrapper {
    position: relative;
    z-index: 1;
}

body {
    background-color: #f5f6fa;
    color: #333;
    line-height: 1.6;
    overflow-x: hidden;
}

a {
    text-decoration: none;
    color: inherit;
}

button, input, select, textarea {
    font-family: inherit;
    font-size: inherit;
}

.btn {
    display: inline-block;
    padding: 8px 16px;
    border: none;
    border-radius: 4px;
    background-color: var(--primary-color);
    color: white;
    cursor: pointer;
    transition: var(--transition);
}

.btn:hover {
    background-color: var(--secondary-color);
    transform: translateY(-2px);
}

.btn-sm {
    padding: 5px 10px;
    font-size: 0.9rem;
}

.btn-outline {
    background-color: transparent;
    border: 1px solid var(--primary-color);
    color: var(--primary-color);
}

.btn-outline:hover {
    background-color: var(--primary-color);
    color: white;
}

.btn-primary {
    background-color: var(--primary-color);
}

.btn-success {
    background-color: var(--success-color);
}

.btn-danger {
    background-color: var(--danger-color);
}

.btn-warning {
    background-color: var(--warning-color);
}

.btn-info {
    background-color: var(--info-color);
}

/* Login Page Styles */
.login-container {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    background-color: #f5f6fa;
    padding: 20px;
}

.login-box {
    width: 100%;
    max-width: 400px;
    background-color: white;
    border-radius: 8px;
    box-shadow: var(--shadow);
    overflow: hidden;
}

.login-header {
    padding: 20px;
    text-align: center;
    background-color: var(--primary-color);
    color: white;
}

.login-header img {
    width: 90px;
    height: 90px;
    margin-bottom: 15px;
    border-radius: 50%;
    border: 3px solid white;
}

.login-header h2 {
    font-size: 1.5rem;
    margin-bottom: 5px;
}

.login-box form {
    padding: 20px;
}

.form-group {
    margin-bottom: 15px;
}

.form-group label {
    display: block;
    margin-bottom: 5px;
    font-weight: 500;
}

.form-group input {
    width: 100%;
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 1rem;
}

.password-input {
    position: relative;
}

.password-input input {
    padding-right: 40px;
}

.toggle-password {
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    cursor: pointer;
    color: var(--gray-color);
}

.remember-me {
    display: flex;
    align-items: center;
    margin-bottom: 15px;
}

.remember-me input {
    margin-right: 8px;
}

.form-footer {
    text-align: center;
    margin-top: 15px;
}

.form-footer a {
    color: var(--primary-color);
}

.form-footer a:hover {
    text-decoration: underline;
}

/* Flash Messages */
.flash-messages {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 10000;
    max-width: 300px;
}

.flash-message {
    padding: 15px;
    margin-bottom: 10px;
    border-radius: 4px;
    color: white;
    box-shadow: var(--shadow);
    animation: slideIn 0.3s ease forwards, fadeOut 0.5s ease 3s forwards;
    opacity: 1;
    transform: translateX(0);
}

@keyframes slideIn {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

@keyframes fadeOut {
    from {
        opacity: 1;
        transform: translateX(0);
    }
    to {
        opacity: 0;
        transform: translateX(100%);
    }
}

.flash-message.success {
    background-color: var(--success-color);
}

.flash-message.danger {
    background-color: var(--danger-color);
}

.flash-message.warning {
    background-color: var(--warning-color);
}

.flash-message.info {
    background-color: var(--info-color);
}

/* Dashboard Layout */
.dashboard-container {
    display: flex;
    min-height: 100vh;
    position: relative;
}

.sidebar {
    width: var(--sidebar-width);
    background-color: var(--dark-color);
    color: white;
    transition: var(--transition);
    position: relative;
    z-index: 100;
    height: 100vh;
    overflow-y: auto;
}

.sidebar.collapsed {
    width: var(--sidebar-collapsed-width);
    overflow: hidden;
}

.sidebar-header {
    padding: 20px;
    text-align: center;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.sidebar-header img {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    margin-bottom: 10px;
}

.sidebar-header h3 {
    font-size: 1.2rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar-menu {
    list-style: none;
}

.sidebar-menu li a {
    display: flex;
    align-items: center;
    padding: 12px 20px;
    color: rgba(255, 255, 255, 0.8);
    transition: var(--transition);
    white-space: nowrap;
}

.sidebar-menu li a:hover {
    background-color: rgba(255, 255, 255, 0.1);
    color: white;
}

.sidebar-menu li a.active {
    background-color: var(--primary-color);
    color: white;
}

.sidebar-menu li a i {
    margin-right: 10px;
    width: 20px;
    text-align: center;
}

.sidebar.collapsed .sidebar-header h3,
.sidebar.collapsed .sidebar-menu li a span {
    display: none;
}

.sidebar.collapsed .sidebar-menu li a {
    justify-content: center;
    padding: 15px 0;
}

.sidebar.collapsed .sidebar-menu li a i {
    margin-right: 0;
    font-size: 1.2rem;
}

.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    transition: var(--transition);
    width: calc(100% - var(--sidebar-width));
}

.sidebar.collapsed + .main-content {
    width: 100%;
}

.top-bar {
    height: var(--top-bar-height);
    background-color: white;
    box-shadow: var(--shadow);
    display: flex;
    align-items: center;
    padding: 0 20px;
    z-index: 90;
}

.sidebar-toggle {
    background: none;
    border: none;
    font-size: 1.2rem;
    cursor: pointer;
    margin-right: 20px;
    color: var(--dark-color);
}

.user-info {
    margin-left: auto;
    display: flex;
    align-items: center;
}

.dropbtn {
    background: none;
    border: none;
    color: var(--dark-color);
    font-size: 1.5rem;
    cursor: pointer;
}

.dropdown {
    position: relative;
    display: inline-block;
}

.dropdown-content {
    display: none;
    position: absolute;
    right: 0;
    background-color: white;
    min-width: 160px;
    box-shadow: var(--shadow);
    z-index: 1;
    border-radius: 4px;
    overflow: hidden;
}

.dropdown-content a {
    color: var(--dark-color);
    padding: 12px 16px;
    display: block;
    transition: var(--transition);
}

.dropdown-content a:hover {
    background-color: #f1f1f1;
}

.dropdown:hover .dropdown-content {
    display: block;
}

.content {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
}

/* Section Content Behavior */
.section-content {
    display: none;
    width: 100%;
}

.section-content.active {
    display: block;
}

/* Dashboard Widgets */
.dashboard-widgets {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.widget {
    background-color: white;
    border-radius: 8px;
    box-shadow: var(--shadow);
    overflow: hidden;
}

.widget-header {
    padding: 15px 20px;
    background-color: var(--primary-color);
    color: white;
}

.widget-header h3 {
    font-size: 1.1rem;
    display: flex;
    align-items: center;
}

.widget-header h3 i {
    margin-right: 10px;
}

.widget-body {
    padding: 20px;
}

.widget-item {
    display: flex;
    justify-content: space-between;
    margin-bottom: 10px;
    padding-bottom: 10px;
    border-bottom: 1px solid #eee;
}

.widget-item:last-child {
    margin-bottom: 0;
    padding-bottom: 0;
    border-bottom: none;
}

.widget-label {
    font-weight: 500;
    color: var(--gray-color);
}

.widget-value {
    font-weight: 600;
}

.widget-actions {
    margin-top: 15px;
}

/* Data Tables */
.data-table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 20px;
}

.data-table th, .data-table td {
    padding: 12px 15px;
    text-align: left;
    border-bottom: 1px solid #eee;
}

.data-table th {
    background-color: #f8f9fa;
    font-weight: 600;
    color: var(--dark-color);
}

.data-table tr:hover {
    background-color: #f8f9fa;
}

.status-badge {
    display: inline-block;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 0.8rem;
    font-weight: 500;
    color: white;
}

.status-badge.active {
    background-color: var(--success-color);
}

.status-badge.completed {
    background-color: var(--info-color);
}

.status-badge.pending {
    background-color: var(--warning-color);
}

.status-badge.cancelled {
    background-color: var(--danger-color);
}

/* Forms */
.form-row {
    display: flex;
    flex-wrap: wrap;
    margin: 0 -10px;
}

.form-group {
    flex: 1;
    min-width: 200px;
    padding: 0 10px;
    margin-bottom: 15px;
}

.form-control {
    width: 100%;
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 1rem;
}

/* Modals */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 1000;
    overflow-y: auto;
}

.modal.show {
    display: block;
}

.modal-dialog {
    max-width: 800px;
    margin: 30px auto;
    background-color: white;
    border-radius: 8px;
    box-shadow: var(--shadow);
}

.modal-header {
    padding: 15px 20px;
    border-bottom: 1px solid #eee;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-title {
    margin: 0;
    font-size: 1.2rem;
}

.modal-body {
    padding: 20px;
}

.modal-footer {
    padding: 15px 20px;
    border-top: 1px solid #eee;
    display: flex;
    justify-content: flex-end;
}

.close {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--gray-color);
}

/* Drug List Styles */
.drug-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 15px;
    padding: 15px;
}

.drug-card {
    background: white;
    border-radius: 5px;
    padding: 15px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
    display: flex;
    flex-direction: column;
}

.drug-info h5 {
    margin: 0 0 5px 0;
    color: #333;
}

.drug-info p {
    margin: 0 0 10px 0;
    color: #666;
    font-size: 14px;
}

.drug-meta {
    display: flex;
    justify-content: space-between;
    margin-top: auto;
}

.price {
    font-weight: bold;
    color: #28a745;
}

.stock {
    color: #6c757d;
    font-size: 13px;
}

.drug-actions {
    margin-top: 10px;
}

.btn-add-to-cart {
    width: 100%;
}

.loading-spinner, .empty-list, .error-loading {
    text-align: center;
    padding: 20px;
    grid-column: 1 / -1;
}

.empty-list i, .error-loading i {
    font-size: 24px;
    margin-bottom: 10px;
    display: block;
}

.error-loading {
    color: #dc3545;
}

/* Responsive */
@media (max-width: 768px) {
    .sidebar {
        position: fixed;
        left: -100%;
        top: 0;
        bottom: 0;
        z-index: 1000;
        width: var(--sidebar-width);
    }
    
    .sidebar.show {
        left: 0;
    }
    
    .sidebar.collapsed {
        left: -100%;
    }
    
    .main-content {
        width: 100%;
        margin-left: 0;
    }
    
    .dashboard-widgets {
        grid-template-columns: 1fr;
    }
}