@import url('https://fonts.googleapis.com/css2?family=Cairo:wght@200..1000&display=swap');

/* ===== Base & Variables ====== */
:root {
    --primary-color: #2c3e50;
    --secondary-color: #e67e22; /* Iron/Fire Color theme matching */
    --accent-color: #34495e;
    --bg-color: #f4f6f9;
    --text-dark: #333;
    --text-light: #ecf0f1;
    --white: #ffffff;
    
    --success: #27ae60;
    --warning: #f39c12;
    --danger: #e74c3c;
    --info: #3498db;

    --sidebar-width: 260px;
    --sidebar-collapsed-width: 70px;
    --transition-speed: 0.3s;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Cairo', sans-serif;
}

body {
    background-color: var(--bg-color);
    display: flex;
    min-height: 100vh;
    overflow-x: hidden;
}

a { text-decoration: none; }
ul { list-style: none; }

/* ===== Sidebar ===== */
.sidebar {
    width: var(--sidebar-width);
    background-color: var(--primary-color);
    color: var(--text-light);
    height: 100vh;
    position: fixed;
    right: 0;
    top: 0;
    transition: all var(--transition-speed);
    z-index: 100;
}

.sidebar.collapsed {
    width: var(--sidebar-collapsed-width);
}

.sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px;
    background-color: var(--accent-color);
}

.sidebar-header .logo {
    display: flex;
    align-items: center;
    gap: 10px;
}

.sidebar-header .logo i {
    font-size: 1.5rem;
    color: var(--secondary-color);
}

.sidebar.collapsed .logo h2 {
    display: none;
}

.toggle-btn {
    background: none;
    border: none;
    color: var(--text-light);
    font-size: 1.2rem;
    cursor: pointer;
}

.nav-links {
    margin-top: 20px;
    padding: 0 10px;
}

.nav-links li {
    margin-bottom: 5px;
}

.nav-links li a {
    display: flex;
    align-items: center;
    padding: 12px 15px;
    color: var(--text-light);
    border-radius: 8px;
    transition: all 0.2s;
    font-size: 1.05rem;
}

.nav-links li.active a, .nav-links li a:hover {
    background-color: var(--secondary-color);
    color: #fff;
}

.nav-links li a i {
    min-width: 30px;
    font-size: 1.2rem;
}

.sidebar.collapsed .nav-links li a .text {
    display: none;
}

/* ===== Main Content ===== */
.main-content {
    flex: 1;
    margin-right: var(--sidebar-width);
    padding: 20px 30px;
    transition: all var(--transition-speed);
}

.main-content.expanded {
    margin-right: var(--sidebar-collapsed-width);
}

/* Topbar */
.topbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background-color: var(--white);
    padding: 15px 25px;
    border-radius: 10px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.05);
    margin-bottom: 30px;
}

.search-box {
    display: flex;
    align-items: center;
    background-color: var(--bg-color);
    padding: 8px 15px;
    border-radius: 20px;
    width: 300px;
}

.search-box i { color: #888; margin-left: 10px; }
.search-box input {
    border: none;
    background: transparent;
    outline: none;
    width: 100%;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 25px;
}

.notification {
    position: relative;
    font-size: 1.2rem;
    cursor: pointer;
    color: #666;
}

.notification .badge {
    position: absolute;
    top: -5px;
    right: -8px;
    background-color: var(--danger);
    color: #fff;
    font-size: 0.7rem;
    padding: 2px 6px;
    border-radius: 50%;
}

.profile {
    display: flex;
    align-items: center;
    gap: 10px;
}

.profile img {
    border-radius: 50%;
    width: 40px;
    height: 40px;
}

.profile h4 { font-size: 0.95rem; color: var(--text-dark); }
.profile small { font-size: 0.8rem; color: #888; }

/* Dashboard Cards */
.dashboard-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.card {
    background-color: var(--white);
    padding: 20px;
    border-radius: 10px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.05);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.card h3 {
    color: #888;
    font-size: 1rem;
    font-weight: 500;
}

.card h2 {
    color: var(--text-dark);
    font-size: 1.8rem;
    margin-top: 5px;
}

.card-icon {
    width: 60px;
    height: 60px;
    border-radius: 15px;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 1.8rem;
}

.card-icon.warning { background-color: rgba(243, 156, 18, 0.15); color: var(--warning); }
.card-icon.success { background-color: rgba(39, 174, 96, 0.15); color: var(--success); }
.card-icon.danger { background-color: rgba(231, 76, 60, 0.15); color: var(--danger); }
.card-icon.primary { background-color: rgba(52, 152, 219, 0.15); color: var(--info); }

/* Dashboard Sections */
.dashboard-sections {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 20px;
}

.table-section, .widget {
    background-color: var(--white);
    padding: 20px;
    border-radius: 10px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.05);
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.btn {
    padding: 8px 15px;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-weight: 600;
    transition: 0.3s;
}

.btn-primary {
    background-color: var(--secondary-color);
    color: #fff;
}
.btn-primary:hover { background-color: #d68910; }

table {
    width: 100%;
    border-collapse: collapse;
}

table th, table td {
    padding: 12px 15px;
    text-align: right;
    border-bottom: 1px solid #eee;
}

table th {
    background-color: #f8f9fa;
    color: #666;
    font-weight: 600;
}

.progress-bar {
    width: 100%;
    height: 8px;
    background-color: #eee;
    border-radius: 5px;
    overflow: hidden;
}

.progress {
    height: 100%;
    background-color: var(--secondary-color);
}

.status {
    padding: 5px 10px;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: bold;
}

.status.warning { background-color: rgba(243, 156, 18, 0.2); color: #d68910; }
.status.success { background-color: rgba(39, 174, 96, 0.2); color: #1e8449; }
.status.primary { background-color: rgba(52, 152, 219, 0.2); color: #2874a6; }

.action-btn {
    background: none;
    border: none;
    color: #888;
    cursor: pointer;
    font-size: 1.1rem;
}
.action-btn:hover { color: var(--primary-color); }

/* Side Widgets */
.side-widgets {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.widget h3 {
    margin-bottom: 15px;
    font-size: 1.1rem;
    color: var(--primary-color);
    border-bottom: 2px solid #efefef;
    padding-bottom: 10px;
}

.list li {
    display: flex;
    justify-content: space-between;
    padding: 10px 0;
    border-bottom: 1px dashed #eee;
}

.text-danger { color: var(--danger); }

.alerts-list .alert-item {
    padding: 12px;
    border-radius: 8px;
    margin-bottom: 10px;
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    gap: 10px;
}

.alert-item.warning { background-color: rgba(243, 156, 18, 0.1); border-right: 4px solid var(--warning); }
.alert-item.danger { background-color: rgba(231, 76, 60, 0.1); border-right: 4px solid var(--danger); }
.alert-item.info { background-color: rgba(52, 152, 219, 0.1); border-right: 4px solid var(--info); }

/* Media Queries */
@media (max-width: 992px) {
    .dashboard-sections {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 768px) {
    .sidebar { left: -100%; right: unset; /* Move out of screen */ }
    .main-content { margin-right: 0; }
}

/* ===== Page Title ===== */
.page-title {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 25px;
}
.page-title h1 {
    color: var(--primary-color);
    font-size: 1.6rem;
}
.page-title .breadcrumb {
    color: #888;
    font-size: 0.9rem;
}

/* ===== Filter Bar ===== */
.filter-bar {
    background-color: var(--white);
    padding: 15px 20px;
    border-radius: 10px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.05);
    margin-bottom: 20px;
    display: flex;
    gap: 15px;
    align-items: center;
    flex-wrap: wrap;
}
.filter-bar input, .filter-bar select {
    padding: 8px 12px;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-family: inherit;
    outline: none;
    min-width: 180px;
}
.filter-bar input:focus, .filter-bar select:focus {
    border-color: var(--secondary-color);
}
.filter-bar .spacer { flex: 1; }

/* ===== Buttons ===== */
.btn-secondary {
    background-color: var(--accent-color);
    color: #fff;
}
.btn-success { background-color: var(--success); color: #fff; }
.btn-danger { background-color: var(--danger); color: #fff; }
.btn-outline {
    background: transparent;
    border: 1px solid #ddd;
    color: var(--text-dark);
}
.btn-outline:hover { background-color: var(--bg-color); }

/* ===== Status / Badges ===== */
.status.danger { background-color: rgba(231, 76, 60, 0.2); color: #c0392b; }
.status.info { background-color: rgba(52, 152, 219, 0.2); color: #1f618d; }
.status.muted { background-color: #ecf0f1; color: #7f8c8d; }
.badge {
    display: inline-block;
    padding: 3px 8px;
    border-radius: 4px;
    font-size: 0.8rem;
    font-weight: 600;
    background-color: var(--bg-color);
    color: var(--text-dark);
}

/* ===== Tabs ===== */
.tabs {
    display: flex;
    gap: 5px;
    border-bottom: 2px solid #eee;
    margin-bottom: 20px;
}
.tab {
    padding: 10px 20px;
    cursor: pointer;
    color: #888;
    font-weight: 600;
    border-bottom: 3px solid transparent;
    margin-bottom: -2px;
    transition: 0.2s;
}
.tab:hover { color: var(--primary-color); }
.tab.active {
    color: var(--secondary-color);
    border-bottom-color: var(--secondary-color);
}

/* ===== Kanban Board ===== */
.kanban-board {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 15px;
    overflow-x: auto;
}
.kanban-column {
    background-color: #f0f2f5;
    border-radius: 10px;
    padding: 15px;
    min-height: 400px;
}
.kanban-column h4 {
    color: var(--primary-color);
    margin-bottom: 15px;
    font-size: 1rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-bottom: 10px;
    border-bottom: 2px solid #ddd;
}
.kanban-column h4 .count {
    background-color: var(--secondary-color);
    color: #fff;
    border-radius: 50%;
    width: 26px;
    height: 26px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.85rem;
}
.kanban-card {
    background-color: var(--white);
    padding: 12px;
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
    margin-bottom: 10px;
    border-right: 4px solid var(--secondary-color);
    cursor: grab;
}
.kanban-card:hover { box-shadow: 0 4px 12px rgba(0,0,0,0.1); }
.kanban-card .k-title { font-weight: 700; color: var(--primary-color); margin-bottom: 5px; }
.kanban-card .k-meta { font-size: 0.85rem; color: #777; margin-bottom: 4px; }
.kanban-card .k-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 8px;
    font-size: 0.8rem;
}

/* ===== Grid Cards (Items/Machines) ===== */
.grid-cards {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 20px;
}
.item-card {
    background-color: var(--white);
    border-radius: 10px;
    overflow: hidden;
    box-shadow: 0 2px 10px rgba(0,0,0,0.05);
    transition: 0.3s;
}
.item-card:hover { transform: translateY(-3px); box-shadow: 0 6px 18px rgba(0,0,0,0.1); }
.item-card .item-img {
    height: 140px;
    background: linear-gradient(135deg, var(--primary-color), var(--accent-color));
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 3rem;
}
.item-card .item-body { padding: 15px; }
.item-card h4 { color: var(--primary-color); margin-bottom: 8px; }
.item-card .item-meta {
    display: flex;
    justify-content: space-between;
    font-size: 0.85rem;
    color: #777;
    margin: 5px 0;
}

/* ===== Form ===== */
.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 15px;
}
.form-group {
    display: flex;
    flex-direction: column;
}
.form-group label {
    margin-bottom: 6px;
    font-weight: 600;
    color: var(--text-dark);
    font-size: 0.9rem;
}
.form-control {
    padding: 10px 12px;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-family: inherit;
    outline: none;
    font-size: 0.95rem;
}
.form-control:focus { border-color: var(--secondary-color); }
textarea.form-control { min-height: 80px; resize: vertical; }

/* ===== Timeline ===== */
.timeline { position: relative; padding-right: 30px; }
.timeline::before {
    content: '';
    position: absolute;
    right: 10px;
    top: 0;
    bottom: 0;
    width: 2px;
    background-color: #ddd;
}
.timeline-item {
    position: relative;
    padding-bottom: 20px;
}
.timeline-item::before {
    content: '';
    position: absolute;
    right: -25px;
    top: 5px;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background-color: var(--secondary-color);
    border: 3px solid #fff;
    box-shadow: 0 0 0 2px var(--secondary-color);
}
.timeline-item.done::before { background-color: var(--success); box-shadow: 0 0 0 2px var(--success); }
.timeline-item.pending::before { background-color: #bbb; box-shadow: 0 0 0 2px #bbb; }
.timeline-item h5 { color: var(--primary-color); margin-bottom: 4px; }
.timeline-item .time { font-size: 0.8rem; color: #888; }

/* ===== Stats Mini ===== */
.mini-stat {
    background: var(--white);
    padding: 15px;
    border-radius: 10px;
    text-align: center;
    box-shadow: 0 2px 10px rgba(0,0,0,0.04);
}
.mini-stat h3 { font-size: 1.6rem; color: var(--primary-color); }
.mini-stat span { color: #888; font-size: 0.9rem; }

/* Chart Placeholder */
.chart-placeholder {
    height: 280px;
    background: linear-gradient(135deg, #f8f9fa, #ecf0f1);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #999;
    font-size: 1rem;
    border: 2px dashed #ddd;
}
/* Language Overrides LTR */
html[dir="ltr"] .sidebar {
    right: auto;
    left: 0;
}
html[dir="ltr"] .main-content {
    margin-right: 0;
    margin-left: var(--sidebar-width);
}
html[dir="ltr"] .main-content.expanded {
    margin-right: 0;
    margin-left: var(--sidebar-collapsed-width);
}
html[dir="ltr"] table th, html[dir="ltr"] table td {
    text-align: left;
}
html[dir="ltr"] .search-box i {
    margin-left: 0;
    margin-right: 10px;
}
html[dir="ltr"] .notification .badge {
    right: auto;
    left: -8px;
}
html[dir="ltr"] .sidebar-header .logo h2 {
    margin-left: 10px;
    margin-right: 0; 
}

