/* === GLOBAL STYLES === */

:root {
    --primary-color: #667eea;
    --secondary-color: #764ba2;
    --success-color: #48bb78;
    --warning-color: #ed8936;
    --danger-color: #f56565;
    --text-color: #333;
    --text-secondary: #666;
    --bg-light: #f9f9f9;
    --bg-white: #ffffff;
    --border-color: #eee;
    --border-radius: 8px;
    --box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

* {
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    color: var(--text-color);
    background: var(--bg-light);
}

/* === BUTTONS === */

.edm-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 10px 20px;
    border: none;
    border-radius: var(--border-radius);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s;
    text-decoration: none;
    white-space: nowrap;
}

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

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

.edm-btn-primary:hover:not(:disabled) {
    background: #5568d3;
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

.edm-btn-secondary {
    background: var(--bg-light);
    color: var(--text-color);
    border: 1px solid var(--border-color);
}

.edm-btn-secondary:hover:not(:disabled) {
    background: #f0f0f0;
}

.edm-btn-ghost {
    background: transparent;
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
}

.edm-btn-ghost:hover:not(:disabled) {
    background: var(--bg-light);
    color: var(--text-color);
}

.edm-btn-small {
    padding: 6px 12px;
    font-size: 12px;
}

.edm-btn-block {
    width: 100%;
}

/* === FORMS === */

.edm-form {
    background: var(--bg-white);
    padding: 20px;
    border-radius: var(--border-radius);
    box-shadow: var(--box-shadow);
}

.edm-form-group {
    margin-bottom: 20px;
}

.edm-form-group label {
    display: block;
    margin-bottom: 8px;
    color: var(--text-color);
    font-weight: 500;
    font-size: 14px;
}

.edm-input,
.edm-select {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    font-size: 14px;
    font-family: inherit;
    transition: border-color 0.3s;
}

.edm-input:focus,
.edm-select:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.edm-form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

.edm-form-row.full {
    grid-template-columns: 1fr;
}

/* === ALERTS === */

.edm-alert {
    padding: 15px;
    border-radius: var(--border-radius);
    margin-bottom: 20px;
    font-size: 14px;
    display: none;
}

.edm-alert.edm-alert-success {
    background: #ecf0f1;
    color: #27ae60;
    border-left: 4px solid #27ae60;
    display: block;
}

.edm-alert.edm-alert-warning {
    background: #fff3cd;
    color: #856404;
    border-left: 4px solid #ffc107;
    display: block;
}

.edm-alert.edm-alert-danger {
    background: #f8d7da;
    color: #721c24;
    border-left: 4px solid #dc3545;
    display: block;
}

.edm-alert.edm-alert-info {
    background: #d1ecf1;
    color: #0c5460;
    border-left: 4px solid #17a2b8;
    display: block;
}

/* === DASHBOARD === */

.edm-dashboard {
    max-width: 1400px;
    margin: 0 auto;
    padding: 20px;
}

.edm-dashboard-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
    padding-bottom: 20px;
    border-bottom: 1px solid var(--border-color);
}

.edm-dashboard-header h1 {
    margin: 0 0 5px 0;
    font-size: 32px;
    color: var(--text-color);
}

.edm-welcome {
    margin: 0;
    font-size: 14px;
    color: var(--text-secondary);
}

/* === STATS === */

.edm-stats-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.edm-stat-card {
    background: var(--bg-white);
    padding: 20px;
    border-radius: var(--border-radius);
    box-shadow: var(--box-shadow);
}

.edm-stat-value {
    font-size: 32px;
    font-weight: bold;
    color: var(--primary-color);
    margin-bottom: 5px;
}

.edm-stat-label {
    font-size: 14px;
    color: var(--text-secondary);
    margin-bottom: 10px;
}

.edm-stat-bar {
    width: 100%;
    height: 8px;
    background: #e0e0e0;
    border-radius: 4px;
    overflow: hidden;
}

.edm-stat-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--primary-color), var(--secondary-color));
    transition: width 0.3s;
}

/* === DASHBOARD CONTENT === */

.edm-dashboard-content {
    display: grid;
    grid-template-columns: 200px 1fr;
    gap: 20px;
}

.edm-sidebar {
    background: var(--bg-white);
    border-radius: var(--border-radius);
    padding: 0;
    box-shadow: var(--box-shadow);
    height: fit-content;
}

.edm-nav {
    display: flex;
    flex-direction: column;
}

.edm-nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 15px;
    color: var(--text-secondary);
    text-decoration: none;
    border-left: 3px solid transparent;
    transition: all 0.3s;
    font-size: 14px;
    font-weight: 500;
}

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

.edm-nav-item.active {
    background: #f0f4ff;
    color: var(--primary-color);
    border-left-color: var(--primary-color);
}

.edm-nav-icon {
    font-size: 18px;
}

/* === TABS === */

.edm-tab-content {
    background: var(--bg-white);
    border-radius: var(--border-radius);
    box-shadow: var(--box-shadow);
    padding: 20px;
}

.edm-tab {
    display: none;
}

.edm-tab.active {
    display: block;
}

/* === DOCUMENTS LIST === */

.edm-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 20px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.edm-toolbar-left,
.edm-toolbar-right {
    display: flex;
    gap: 10px;
    flex: 1;
}

.edm-toolbar-right {
    justify-content: flex-end;
}

.edm-search-input {
    padding: 10px 15px;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    font-size: 14px;
    min-width: 200px;
}

.edm-filters {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
}

.edm-select {
    padding: 8px 12px;
    min-width: 150px;
}

/* === DOCUMENTS GRID === */

.edm-documents-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 15px;
}

.edm-document-card {
    display: flex;
    align-items: center;
    gap: 15px;
    padding: 15px;
    background: var(--bg-light);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    transition: all 0.3s;
}

.edm-document-card:hover {
    border-color: var(--primary-color);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
    background: white;
}

.edm-doc-icon {
    font-size: 32px;
    flex-shrink: 0;
}

.edm-doc-info {
    flex: 1;
    min-width: 0;
}

.edm-doc-name {
    font-weight: 500;
    color: var(--text-color);
    word-break: break-word;
    margin-bottom: 5px;
}

.edm-doc-meta {
    font-size: 12px;
    color: var(--text-secondary);
}

.edm-doc-actions {
    display: flex;
    gap: 5px;
    flex-shrink: 0;
}

.edm-empty {
    text-align: center;
    padding: 40px 20px;
    color: var(--text-secondary);
    font-size: 14px;
}

.edm-loading {
    text-align: center;
    padding: 40px 20px;
    color: var(--text-secondary);
}

/* === BADGES === */

.edm-badge {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 500;
}

.edm-badge-active {
    background: #d4edda;
    color: #155724;
}

.edm-badge-suspended {
    background: #f8d7da;
    color: #721c24;
}

.edm-badge-inactive {
    background: #e2e3e5;
    color: #383d41;
}

.edm-badge-success {
    background: #d4edda;
    color: #155724;
}

.edm-badge-error {
    background: #f8d7da;
    color: #721c24;
}

/* === COMPLIANCE LIST === */

.edm-compliance-list {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.edm-compliance-item {
    padding: 15px;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    background: var(--bg-light);
}

.edm-compliance-item.high-priority {
    border-left: 4px solid var(--danger-color);
}

.edm-compliance-item.medium-priority {
    border-left: 4px solid var(--warning-color);
}

.edm-compliance-item.low-priority {
    border-left: 4px solid var(--success-color);
}

/* === ACTIVITY TIMELINE === */

.edm-activity-list {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.edm-activity-item {
    padding: 15px;
    border-left: 3px solid var(--border-color);
    position: relative;
    padding-left: 20px;
}

.edm-activity-item::before {
    content: '';
    position: absolute;
    left: -9px;
    top: 20px;
    width: 12px;
    height: 12px;
    background: var(--primary-color);
    border: 3px solid white;
    border-radius: 50%;
}

.edm-activity-action {
    font-weight: 500;
    color: var(--text-color);
}

.edm-activity-time {
    font-size: 12px;
    color: var(--text-secondary);
    margin-top: 5px;
}

/* === MODAL === */

.edm-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 9999;
}

.edm-modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
}

.edm-modal-content {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: white;
    border-radius: var(--border-radius);
    max-width: 600px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    z-index: 10000;
}

.edm-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px;
    border-bottom: 1px solid var(--border-color);
}

.edm-modal-title {
    margin: 0;
    font-size: 18px;
    color: var(--text-color);
}

.edm-modal-close {
    background: none;
    border: none;
    font-size: 24px;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 0;
}

.edm-modal-body {
    padding: 20px;
}

/* === CHANGE CATEGORY MODAL (frontend, dynamically built by dashboard.js) === */

.edm-catmodal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    padding: 20px;
}

.edm-catmodal-box {
    background: var(--bg-white);
    border-radius: var(--border-radius);
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.25);
    padding: 28px;
    width: 100%;
    max-width: 420px;
    text-align: center;
}

.edm-catmodal-box h3 {
    margin: 4px 0 8px;
}

.edm-catmodal-box p {
    color: var(--text-secondary);
    font-size: 14px;
    margin-bottom: 16px;
}

.edm-catmodal-icon {
    font-size: 32px;
    margin-bottom: 4px;
}

.edm-catmodal-box .edm-form-group {
    text-align: left;
    margin-bottom: 20px;
}

.edm-catmodal-actions {
    display: flex;
    gap: 10px;
    justify-content: center;
}

.edm-catmodal-actions .edm-btn {
    flex: 1;
}

/* === RESPONSIVE === */

@media (max-width: 768px) {
    .edm-dashboard-content {
        grid-template-columns: 1fr;
    }

    .edm-sidebar {
        display: grid;
        grid-template-columns: repeat(auto-fit, minmax(100px, 1fr));
    }

    .edm-nav {
        flex-direction: row;
    }

    .edm-nav-item {
        padding: 10px;
        flex-direction: column;
        text-align: center;
        border-left: none;
        border-bottom: 3px solid transparent;
    }

    .edm-nav-item.active {
        border-left: none;
        border-bottom-color: var(--primary-color);
    }

    .edm-form-row {
        grid-template-columns: 1fr;
    }

    .edm-toolbar {
        flex-direction: column;
    }

    .edm-toolbar-left,
    .edm-toolbar-right {
        width: 100%;
        flex-direction: column;
    }

    .edm-toolbar-right {
        justify-content: flex-start;
    }

    .edm-documents-grid {
        grid-template-columns: 1fr;
    }

    .edm-stats-row {
        grid-template-columns: 1fr 1fr;
    }

    .edm-dashboard-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 15px;
    }

    .edm-header-right {
        width: 100%;
    }

    .edm-header-right .edm-btn {
        width: 100%;
    }
}

/* === DARK MODE === */

@media (prefers-color-scheme: dark) {
    :root {
        --text-color: #e0e0e0;
        --text-secondary: #b0b0b0;
        --bg-light: #2a2a2a;
        --bg-white: #1e1e1e;
        --border-color: #444;
    }

    .edm-input,
    .edm-select {
        background: #333;
        color: #e0e0e0;
        border-color: #444;
    }

    .edm-form {
        background: #1e1e1e;
    }

    .edm-alert-success {
        background: #1b5e20;
        color: #81c784;
    }

    .edm-alert-warning {
        background: #3e2723;
        color: #ffb74d;
    }

    .edm-alert-danger {
        background: #b71c1c;
        color: #ef9a9a;
    }
}
