/* Dashboard Styles */

.dashboard-main {
    padding: 40px 0;
    min-height: calc(100vh - 200px);
    background-color: var(--light-color);
}

.dashboard-title {
    font-size: 2.5rem;
    color: var(--primary-color);
    margin-bottom: 2rem;
}

/* User Section */
.user-section {
    display: flex;
    align-items: center;
    gap: 15px;
}

.user-section span {
    font-weight: 600;
    color: var(--text-color);
}

.btn-sm {
    padding: 8px 16px;
    font-size: 0.9rem;
}

/* Statistics Cards */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 20px;
    margin-bottom: 3rem;
}

.stat-card {
    background: white;
    padding: 25px;
    border-radius: 10px;
    box-shadow: var(--shadow);
    display: flex;
    align-items: center;
    gap: 20px;
    transition: transform 0.3s ease;
}

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

.stat-icon {
    font-size: 3rem;
    line-height: 1;
}

.stat-info h3 {
    font-size: 2rem;
    margin: 0;
    color: var(--primary-color);
}

.stat-info p {
    margin: 5px 0 0;
    color: var(--text-light);
    font-size: 0.9rem;
}

/* Dashboard Sections */
.dashboard-section {
    background: white;
    padding: 30px;
    border-radius: 10px;
    box-shadow: var(--shadow);
    margin-bottom: 30px;
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 25px;
}

.section-header h2 {
    margin: 0;
    color: var(--primary-color);
}

/* Inventory Controls */
.inventory-controls {
    display: flex;
    gap: 15px;
    margin-bottom: 25px;
    flex-wrap: wrap;
    align-items: center;
}

.search-input {
    flex: 1;
    min-width: 250px;
    padding: 10px 15px;
    border: 1px solid #ddd;
    border-radius: 5px;
    font-size: 1rem;
}

.filter-select {
    padding: 10px 15px;
    border: 1px solid #ddd;
    border-radius: 5px;
    font-size: 1rem;
    background: white;
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    user-select: none;
}

.checkbox-label input[type="checkbox"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
}

/* Inventory Grid */
.inventory-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 20px;
}

.inventory-card {
    background: var(--light-color);
    border-radius: 8px;
    padding: 20px;
    border: 1px solid #e0e0e0;
    transition: all 0.3s ease;
}

.inventory-card:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow);
}

.inventory-card-header {
    display: flex;
    justify-content: space-between;
    align-items: start;
    margin-bottom: 15px;
}

.inventory-card-header h3 {
    margin: 0;
    color: var(--dark-color);
    font-size: 1.2rem;
}

.category-badge {
    background: var(--secondary-color);
    color: white;
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 0.75rem;
    white-space: nowrap;
}

.inventory-card-body {
    margin-bottom: 15px;
}

.inventory-detail {
    display: flex;
    justify-content: space-between;
    padding: 8px 0;
    border-bottom: 1px solid #e0e0e0;
}

.inventory-detail:last-child {
    border-bottom: none;
}

.inventory-detail .label {
    color: var(--text-light);
    font-size: 0.9rem;
}

.inventory-detail .value {
    font-weight: 600;
    color: var(--text-color);
}

.text-warning {
    color: var(--accent-color) !important;
}

.inventory-alert {
    background: #fff3cd;
    color: #856404;
    padding: 8px 12px;
    border-radius: 5px;
    font-size: 0.85rem;
    margin-top: 10px;
}

.inventory-card-actions {
    display: flex;
    gap: 10px;
}

.btn-danger {
    background-color: #dc3545;
    color: white;
}

.btn-danger:hover {
    background-color: #c82333;
}

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

.modal-content {
    background-color: white;
    margin: 5% auto;
    padding: 30px;
    border-radius: 10px;
    width: 90%;
    max-width: 600px;
    box-shadow: var(--shadow-lg);
    animation: slideDown 0.3s ease;
}

.modal-small {
    max-width: 400px;
}

.close {
    color: #aaa;
    float: right;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
    line-height: 1;
}

.close:hover,
.close:focus {
    color: var(--dark-color);
}

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

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

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

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #ddd;
    border-radius: 5px;
    font-size: 1rem;
    font-family: inherit;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--primary-color);
}

.form-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 25px;
}

.btn-block {
    width: 100%;
}

.modal-footer {
    text-align: center;
    margin-top: 20px;
    color: var(--text-light);
}

.modal-footer a {
    color: var(--primary-color);
    text-decoration: none;
    font-weight: 600;
}

.error-message {
    background: #f8d7da;
    color: #721c24;
    padding: 10px;
    border-radius: 5px;
    margin-bottom: 15px;
}

/* Notifications */
.notification {
    position: fixed;
    top: 20px;
    right: 20px;
    padding: 15px 25px;
    border-radius: 5px;
    box-shadow: var(--shadow-lg);
    z-index: 2000;
    animation: slideInRight 0.3s ease;
}

.notification-success {
    background: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}

.notification-error {
    background: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}

.notification-info {
    background: #d1ecf1;
    color: #0c5460;
    border: 1px solid #bee5eb;
}

.notification.fade-out {
    animation: fadeOut 0.3s ease;
}

/* Empty State */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-light);
    font-size: 1.1rem;
}

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

/* Animations */
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes slideDown {
    from {
        transform: translateY(-50px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

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

@keyframes fadeOut {
    from { opacity: 1; }
    to { opacity: 0; }
}

/* Responsive */
@media (max-width: 768px) {
    .stats-grid {
        grid-template-columns: 1fr;
    }

    .inventory-grid {
        grid-template-columns: 1fr;
    }

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

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

    .inventory-controls {
        flex-direction: column;
        align-items: stretch;
    }

    .search-input {
        min-width: 100%;
    }

    .modal-content {
        margin: 10% auto;
        width: 95%;
    }
}

/* Inventory Overview Section */
.inventory-charts-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1.5rem;
}

.attention-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    max-height: 250px;
    overflow-y: auto;
}

.attention-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 1rem;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 8px;
    border-left: 3px solid #eab308;
}

.attention-item.urgent {
    border-left-color: #ef4444;
    background: rgba(239, 68, 68, 0.1);
}

.attention-item.warning {
    border-left-color: #eab308;
    background: rgba(234, 179, 8, 0.1);
}

.attention-item.expiring {
    border-left-color: #f97316;
    background: rgba(249, 115, 22, 0.1);
}

.attention-item-info {
    display: flex;
    flex-direction: column;
}

.attention-item-name {
    font-weight: 500;
    color: var(--text-primary);
}

.attention-item-detail {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.attention-badge {
    font-size: 0.75rem;
    font-weight: 500;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    white-space: nowrap;
}

.attention-badge.urgent {
    background: rgba(239, 68, 68, 0.2);
    color: #ef4444;
}

.attention-badge.warning {
    background: rgba(234, 179, 8, 0.2);
    color: #eab308;
}

.attention-badge.expiring {
    background: rgba(249, 115, 22, 0.2);
    color: #f97316;
}

/* Light theme for attention items */
body[data-theme="light"] .attention-item {
    background: rgba(0, 0, 0, 0.03);
}

body[data-theme="light"] .attention-item.urgent {
    background: rgba(239, 68, 68, 0.08);
}

body[data-theme="light"] .attention-item.warning {
    background: rgba(234, 179, 8, 0.08);
}

body[data-theme="light"] .attention-item.expiring {
    background: rgba(249, 115, 22, 0.08);
}

@media (max-width: 768px) {
    .inventory-charts-grid {
        grid-template-columns: 1fr;
    }
}

/* Pantry Overview Section */
#pantry-overview {
    margin-top: 2rem;
}

.pantry-stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
    gap: 0.75rem;
    margin-bottom: 1.5rem;
}

/* Compact pantry stat cards */
.pantry-stat {
    padding: 1rem 0.75rem;
}

.pantry-stat .stat-icon {
    font-size: 1.75rem;
}

.pantry-stat .stat-info h3 {
    font-size: 1.25rem;
}

.pantry-stat .stat-info p {
    font-size: 0.75rem;
}

/* Days of supply formatting */
.pantry-stat .stat-info h3 .supply-value {
    font-size: 1.1rem;
    font-weight: 700;
}

.pantry-stat .stat-info h3 .supply-value.supply-secondary {
    font-size: 0.9rem;
}

.pantry-stat .stat-info h3 .supply-unit {
    font-size: 0.6rem;
    font-weight: 400;
    color: var(--text-light);
    margin-left: 1px;
    vertical-align: baseline;
}

/* Expiring card colors */
.pantry-stat.expiring-7 h3 {
    color: #ef4444;
}

.pantry-stat.expiring-30 h3 {
    color: #f59e0b;
}

.pantry-stat.expiring-90 h3 {
    color: #3b82f6;
}

/* Clickable stat cards */
a.stat-card.clickable {
    text-decoration: none;
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

a.stat-card.clickable:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.15);
}

a.stat-card.clickable .stat-info p {
    color: var(--text-light);
}

.pantry-charts-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1.5rem;
    margin-bottom: 1.5rem;
}

.chart-card {
    background: var(--card-bg, #2a2f3e);
    border-radius: 12px;
    padding: 1.5rem;
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.chart-card h3 {
    margin: 0 0 1rem 0;
    font-size: 1.1rem;
    color: var(--text-primary);
}

.chart-container {
    position: relative;
    height: 250px;
}

.expiring-preview {
    background: var(--card-bg, #2a2f3e);
    border-radius: 12px;
    padding: 1.5rem;
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.expiring-preview h3 {
    margin: 0 0 1rem 0;
    font-size: 1.1rem;
    color: var(--text-primary);
}

.expiring-items-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.expiring-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 1rem;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 8px;
    border-left: 3px solid #eab308;
}

.expiring-item.expired {
    border-left-color: #ef4444;
}

.expiring-item-info {
    display: flex;
    flex-direction: column;
}

.expiring-item-name {
    font-weight: 500;
    color: var(--text-primary);
}

.expiring-item-qty {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.expiring-item-date {
    font-weight: 500;
    color: #eab308;
    font-size: 0.9rem;
}

.expiring-item.expired .expiring-item-date {
    color: #ef4444;
}

.empty-text {
    color: var(--text-secondary);
    text-align: center;
    padding: 1rem;
}

/* Light theme */
body[data-theme="light"] .chart-card,
body[data-theme="light"] .expiring-preview {
    border-color: var(--border-color);
    box-shadow: 0 2px 8px rgba(0,0,0,0.05);
}

body[data-theme="light"] .expiring-item {
    background: rgba(0, 0, 0, 0.03);
}

/* Responsive */
@media (max-width: 1024px) {
    .pantry-stats-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media (max-width: 768px) {
    .pantry-charts-grid {
        grid-template-columns: 1fr;
    }
    .pantry-stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 480px) {
    .pantry-stats-grid {
        grid-template-columns: 1fr;
    }
}

/* System Monitoring Section */
.system-stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.system-card {
    background: var(--card-bg, #fff);
    border-radius: 10px;
    padding: 1.25rem;
    box-shadow: var(--shadow);
}

.system-card-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.system-card-header h4 {
    margin: 0;
    font-size: 1rem;
    color: var(--text-primary, #333);
}

.system-icon {
    font-size: 1.5rem;
}

.system-card-body {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.progress-bar-container {
    width: 100%;
    height: 8px;
    background: var(--border-color, #e5e7eb);
    border-radius: 4px;
    overflow: hidden;
}

.progress-bar {
    height: 100%;
    background: linear-gradient(90deg, var(--primary-color) 0%, var(--secondary-color) 100%);
    border-radius: 4px;
    transition: width 0.5s ease;
}

.progress-bar.warning {
    background: linear-gradient(90deg, #f59e0b 0%, #fbbf24 100%);
}

.progress-bar.danger {
    background: linear-gradient(90deg, #ef4444 0%, #f87171 100%);
}

.system-stats {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.95rem;
}

.system-stats span:first-child {
    font-weight: 600;
    font-size: 1.25rem;
    color: var(--primary-color);
}

.stat-secondary {
    color: var(--text-secondary, #666);
    font-size: 0.85rem;
}

.stat-detail {
    font-size: 0.8rem;
    color: var(--text-secondary, #666);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.uptime-display {
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--primary-color);
    margin-bottom: 0.25rem;
}

.disk-details {
    display: flex;
    justify-content: space-between;
    gap: 0.5rem;
    margin-top: 0.5rem;
    font-size: 0.75rem;
}

.disk-stat {
    display: flex;
    gap: 0.25rem;
}

.disk-label {
    color: var(--text-secondary, #6b7280);
}

#disk-used, #disk-free {
    font-weight: 500;
    color: var(--text-primary);
}

/* PM2 Processes */
.pm2-processes {
    background: var(--card-bg, #fff);
    border-radius: 10px;
    padding: 1.25rem;
    box-shadow: var(--shadow);
}

.pm2-processes h4 {
    margin: 0 0 1rem 0;
    color: var(--text-primary);
}

.process-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 0.75rem;
}

.process-item {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    padding: 0.75rem 1rem;
    background: var(--hover-bg, #f3f4f6);
    border-radius: 8px;
    border-left: 3px solid var(--border-color);
    min-width: 0;
}

.process-item.online {
    border-left-color: #22c55e;
}

.process-item.stopped {
    border-left-color: #ef4444;
}

.process-item.errored,
.process-item.error {
    border-left-color: #f59e0b;
}

.process-info {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    min-width: 0;
}

.process-name {
    font-weight: 600;
    font-size: 0.85rem;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex: 1;
    min-width: 0;
}

.process-status {
    display: inline-flex;
    align-items: center;
    padding: 0.15rem 0.5rem;
    border-radius: 9999px;
    font-size: 0.65rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.025em;
    flex-shrink: 0;
}

.process-status.online {
    background: rgba(34, 197, 94, 0.15);
    color: #16a34a;
}

.process-status.stopped {
    background: rgba(239, 68, 68, 0.15);
    color: #dc2626;
}

.process-status.errored,
.process-status.error {
    background: rgba(245, 158, 11, 0.15);
    color: #d97706;
}

.process-stats {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.25rem 0.75rem;
    font-size: 0.7rem;
}

.process-stat {
    display: flex;
    justify-content: space-between;
    gap: 0.5rem;
}

.stat-label {
    color: var(--text-secondary, #6b7280);
}

.stat-value {
    color: var(--text-primary);
    font-weight: 500;
    text-align: right;
}

@media (max-width: 768px) {
    .system-stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 480px) {
    .system-stats-grid {
        grid-template-columns: 1fr;
    }
    .process-grid {
        grid-template-columns: 1fr;
    }
}

/* Ollama AI Status Section */
.ollama-status-section {
    background: var(--card-bg, #fff);
    border-radius: 10px;
    padding: 1rem;
    margin-top: 1rem;
}

.ollama-status-section h4 {
    margin: 0 0 1rem 0;
    color: var(--text-primary);
    font-size: 0.9rem;
    font-weight: 600;
}

.ollama-status {
    display: flex;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
}

.ollama-status-indicator {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.status-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
}

.status-dot.online {
    background: #22c55e;
    box-shadow: 0 0 6px rgba(34, 197, 94, 0.5);
}

.status-dot.stopped {
    background: #f59e0b;
}

.status-dot.not-installed {
    background: #94a3b8;
}

.ollama-status .status-text {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.ollama-status .status-text a {
    color: var(--primary-color, #3b82f6);
    text-decoration: underline;
}

.ollama-status .status-text code {
    background: var(--bg-secondary, #f1f5f9);
    padding: 0.1rem 0.4rem;
    border-radius: 4px;
    font-size: 0.8rem;
}

.ollama-models {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.ollama-models .models-label {
    font-weight: 500;
}

.ollama-models .models-list {
    color: var(--text-primary);
}

.ollama-status .btn-sm {
    padding: 0.35rem 0.75rem;
    font-size: 0.8rem;
    margin-left: auto;
}

.ollama-status .btn-outline {
    border: 1px solid var(--primary-color, #3b82f6);
    color: var(--primary-color, #3b82f6);
    background: transparent;
    border-radius: 6px;
    text-decoration: none;
    transition: all 0.2s;
}

.ollama-status .btn-outline:hover {
    background: var(--primary-color, #3b82f6);
    color: #fff;
}
