@import url('https://fonts.googleapis.com/css2?family=Open+Sans:wght@300;400;500;600;700&display=swap');

:root {
    /* Solid Colors - Professional Palette */
    --primary: #2563eb;
    /* Deep Blue */
    --primary-dark: #1d4ed8;
    --primary-light: #3b82f6;

    --success: #10b981;
    /* Emerald */
    --danger: #ef4444;
    /* Red */
    --warning: #f59e0b;
    /* Amber */
    --info: #3b82f6;
    /* Blue */

    --dark: #111827;
    /* Gray 900 */
    --dark-light: #374151;
    /* Gray 700 */
    --gray: #6b7280;
    /* Gray 500 */
    --light: #f3f4f6;
    /* Gray 100 */
    --white: #ffffff;

    --border: #e5e7eb;
    /* Gray 200 */
    --shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px 0 rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);

    --sidebar-width: 250px;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Open Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: var(--light);
    color: var(--dark);
    line-height: 1.5;
    font-size: 14px;
    /* Reduced base font size */
}

/* App Layout */
.app-container {
    display: flex;
    min-height: 100vh;
}

/* Sidebar */
.sidebar {
    width: var(--sidebar-width);
    background: var(--white);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    position: fixed;
    height: 100vh;
    overflow-y: auto;
    z-index: 10;
}

.sidebar-header {
    padding: 1.5rem;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.sidebar-logo {
    width: 40px;
    height: 40px;
    background: var(--primary);
    color: var(--white);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
}

.sidebar-title {
    font-size: 1.1rem;
    color: var(--dark);
    font-weight: 700;
}

.sidebar-nav {
    flex: 1;
    padding: 1rem;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    margin-bottom: 0.25rem;
    border-radius: 8px;
    color: var(--dark-light);
    text-decoration: none;
    font-weight: 500;
    transition: all 0.2s;
    font-size: 0.95rem;
}

.nav-item:hover {
    background: var(--light);
    color: var(--primary);
}

.nav-item.active {
    background: var(--primary);
    color: var(--white);
}

.nav-icon {
    font-size: 1.1rem;
    width: 24px;
    display: flex;
    justify-content: center;
}

.sidebar-footer {
    padding: 1.25rem;
    border-top: 1px solid var(--border);
    background: #fafafa;
}

.user-profile {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.user-avatar {
    width: 36px;
    height: 36px;
    background: var(--dark-light);
    color: var(--white);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 0.9rem;
}

.user-name {
    font-weight: 600;
    color: var(--dark);
    font-size: 0.9rem;
}

.user-logout {
    color: var(--gray);
    text-decoration: none;
    font-size: 0.8rem;
    transition: color 0.2s;
    display: block;
    margin-top: 0.2rem;
}

.user-logout:hover {
    color: var(--danger);
}

/* Main Content */
.main-content {
    flex: 1;
    margin-left: var(--sidebar-width);
    padding: 2rem;
    max-width: 1600px;
}

.content-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
}

.page-title {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--dark);
    letter-spacing: -0.025em;
}

.header-actions {
    display: flex;
    gap: 0.75rem;
}

/* Stats Grid */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.stat-card {
    background: var(--white);
    padding: 1.5rem;
    border-radius: 12px;
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 1rem;
    transition: transform 0.2s, box-shadow 0.2s;
}

.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.stat-icon {
    width: 50px;
    height: 50px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
}

.stat-icon.primary {
    background: var(--primary);
    color: var(--white);
}

.stat-icon.success {
    background: var(--success);
    color: var(--white);
}

.stat-icon.info {
    background: var(--info);
    color: var(--white);
}

.stat-icon.warning {
    background: var(--warning);
    color: var(--white);
}

.stat-content h3 {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--dark);
    line-height: 1.2;
}

.stat-content p {
    color: var(--gray);
    font-size: 0.85rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* Cards */
.card {
    background: var(--white);
    border-radius: 12px;
    padding: 1.75rem;
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
    margin-bottom: 2rem;
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--border);
}

.card-title {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--dark);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

/* Charts */
.chart-container {
    position: relative;
    height: 300px;
    margin-top: 1rem;
}

.chart-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
    gap: 2rem;
    margin-bottom: 2rem;
}

/* Buttons */
.btn {
    padding: 0.6rem 1.25rem;
    border: 1px solid transparent;
    border-radius: 6px;
    font-weight: 600;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    /* Centered content */
    gap: 0.5rem;
    text-decoration: none;
    line-height: 1.2;
    font-family: inherit;
}

.btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

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

.btn-primary:hover:not(:disabled) {
    background: var(--primary-dark);
}

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

.btn-success:hover:not(:disabled) {
    background: #059669;
}

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

.btn-danger:hover:not(:disabled) {
    background: #dc2626;
}

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

.btn-outline:hover:not(:disabled) {
    background: var(--light);
    color: var(--dark);
    border-color: var(--gray);
}

/* Forms */
.form-group {
    margin-bottom: 1.25rem;
}

.form-label {
    display: block;
    margin-bottom: 0.4rem;
    font-weight: 600;
    color: var(--dark-light);
    font-size: 0.9rem;
}

.form-input,
.form-select,
.form-textarea {
    width: 100%;
    padding: 0.6rem 0.9rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 0.95rem;
    transition: all 0.2s;
    font-family: inherit;
    background: var(--white);
    color: var(--dark);
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

/* Tables */
.table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
}

.table th {
    background: var(--light);
    padding: 0.8rem 1rem;
    text-align: left;
    font-weight: 600;
    color: var(--dark-light);
    border-bottom: 1px solid var(--border);
    font-size: 0.85rem;
    text-transform: uppercase;
}

.table td {
    padding: 0.9rem 1rem;
    border-bottom: 1px solid var(--border);
    font-size: 0.9rem;
    color: var(--dark-light);
}

.table tr:last-child td {
    border-bottom: none;
}

.table tr:hover td {
    background: #fafafa;
}

/* Rules List */
.rules-list {
    list-style: none;
}

.rule-item {
    background: var(--white);
    padding: 1.25rem;
    border-radius: 8px;
    margin-bottom: 0.75rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border: 1px solid var(--border);
    transition: box-shadow 0.2s;
}

.rule-item:hover {
    box-shadow: var(--shadow);
}

.rule-info h4 {
    font-size: 1rem;
    color: var(--dark);
    font-weight: 600;
    margin-bottom: 0.25rem;
}

.rule-info p {
    color: var(--gray);
    font-size: 0.85rem;
}

.rule-actions {
    display: flex;
    gap: 0.6rem;
}

.badge {
    padding: 0.2rem 0.6rem;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 600;
    margin-left: 0.5rem;
    display: inline-block;
}

.badge-success {
    background: #ecfdf5;
    color: #059669;
    border: 1px solid #d1fae5;
}

.badge-danger {
    background: #fef2f2;
    color: #dc2626;
    border: 1px solid #fee2e2;
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(17, 24, 39, 0.6);
    backdrop-filter: blur(2px);
    z-index: 1000;
    align-items: center;
    justify-content: center;
}

.modal.active {
    display: flex;
}

.modal-content {
    background: var(--white);
    padding: 2rem;
    border-radius: 12px;
    max-width: 500px;
    width: 90%;
    box-shadow: var(--shadow-lg);
    animation: modalSlideIn 0.2s ease-out;
}

@keyframes modalSlideIn {
    from {
        transform: scale(0.95);
        opacity: 0;
    }

    to {
        transform: scale(1);
        opacity: 1;
    }
}

.modal-header {
    margin-bottom: 1.5rem;
    border-bottom: 1px solid var(--border);
    padding-bottom: 1rem;
}

.modal-header h2 {
    font-size: 1.25rem;
    color: var(--dark);
    font-weight: 600;
}

.modal-footer {
    display: flex;
    gap: 0.75rem;
    justify-content: flex-end;
    margin-top: 2rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border);
}

/* Alert */
.alert {
    padding: 0.9rem 1.25rem;
    border-radius: 8px;
    margin-bottom: 1.25rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-size: 0.9rem;
    border: 1px solid transparent;
}

.alert-success {
    background: #ecfdf5;
    color: #065f46;
    border-color: #d1fae5;
}

.alert-danger {
    background: #fef2f2;
    color: #991b1b;
    border-color: #fee2e2;
}

.alert-info {
    background: #eff6ff;
    color: #1e40af;
    border-color: #dbeafe;
}

/* Empty State */
.empty-state {
    text-align: center;
    padding: 4rem 1rem;
    color: var(--gray);
}

.empty-state-icon {
    font-size: 3rem;
    margin-bottom: 1rem;
    opacity: 0.4;
}

/* Responsive */
@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
        transition: transform 0.3s;
    }

    .sidebar.active {
        transform: translateX(0);
    }

    .main-content {
        margin-left: 0;
        padding: 1rem;
    }
}