/* Sheep & Goat Farm Management - Main Stylesheet */
* { margin: 0; padding: 0; box-sizing: border-box; }

:root {
    --primary-color: #059669;
    --secondary-color: #047857;
    --success-color: #10b981;
    --danger-color: #ef4444;
    --warning-color: #f59e0b;
    --info-color: #3b82f6;
    --dark-color: #1f2937;
    --light-color: #f3f4f6;
    --border-color: #e5e7eb;
    --text-color: #374151;
    --sidebar-width: 260px;
    --header-height: 65px;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    font-size: 14px;
    color: var(--text-color);
    background-color: #f9fafb;
    line-height: 1.6;
}

.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #059669 0%, #047857 100%);
}

.login-container { width: 100%; max-width: 420px; padding: 20px; }
.login-box { background: white; border-radius: 12px; box-shadow: 0 10px 40px rgba(0,0,0,0.2); padding: 40px; }
.login-header { text-align: center; margin-bottom: 30px; }
.login-header h1 { color: var(--primary-color); font-size: 28px; margin-bottom: 8px; }
.login-header p { color: #6b7280; font-size: 14px; }
.login-form .form-group { margin-bottom: 20px; }
.login-form label { display: block; margin-bottom: 6px; font-weight: 600; color: var(--dark-color); }
.login-form input { width: 100%; padding: 12px; border: 1px solid var(--border-color); border-radius: 6px; font-size: 14px; transition: all 0.3s; }
.login-form input:focus { outline: none; border-color: var(--primary-color); box-shadow: 0 0 0 3px rgba(5, 150, 105, 0.2); }
.login-footer { margin-top: 25px; padding-top: 20px; border-top: 1px solid var(--border-color); text-align: center; color: #6b7280; font-size: 13px; }

.btn { display: inline-block; padding: 10px 20px; border: none; border-radius: 6px; font-size: 14px; font-weight: 600; cursor: pointer; transition: all 0.3s; text-decoration: none; text-align: center; }
.btn-primary { background-color: var(--primary-color); color: white; }
.btn-primary:hover { background-color: var(--secondary-color); transform: translateY(-1px); box-shadow: 0 4px 12px rgba(5, 150, 105, 0.3); }
.btn-success { background-color: var(--success-color); color: white; }
.btn-success:hover { background-color: #059669; }
.btn-danger { background-color: var(--danger-color); color: white; }
.btn-danger:hover { background-color: #dc2626; }
.btn-warning { background-color: var(--warning-color); color: white; }
.btn-info { background-color: var(--info-color); color: white; }
.btn-secondary { background-color: #6b7280; color: white; }
.btn-block { width: 100%; display: block; }
.btn-sm { padding: 6px 12px; font-size: 13px; }
.btn-lg { padding: 14px 28px; font-size: 16px; }

.alert { padding: 12px 16px; border-radius: 6px; margin-bottom: 20px; border-left: 4px solid; }
.alert-success { background-color: #d1fae5; border-color: var(--success-color); color: #065f46; }
.alert-error { background-color: #fee2e2; border-color: var(--danger-color); color: #991b1b; }
.alert-warning { background-color: #fef3c7; border-color: var(--warning-color); color: #92400e; }
.alert-info { background-color: #dbeafe; border-color: var(--info-color); color: #1e40af; }

.wrapper { display: flex; min-height: 100vh; }
.sidebar { width: var(--sidebar-width); background-color: var(--dark-color); color: white; position: fixed; height: 100vh; overflow-y: auto; transition: all 0.3s; z-index: 1000; }
.sidebar-header { padding: 20px; background-color: #111827; border-bottom: 1px solid #374151; }
.sidebar-header h2 { font-size: 18px; font-weight: 700; }
.sidebar-nav ul { list-style: none; padding: 15px 0; }
.sidebar-nav li { margin-bottom: 5px; }
.sidebar-nav a { display: flex; align-items: center; padding: 12px 20px; color: #d1d5db; text-decoration: none; transition: all 0.3s; }
.sidebar-nav a:hover { background-color: #374151; color: white; }
.sidebar-nav a.active { background-color: var(--primary-color); color: white; }
.sidebar-nav a i { margin-right: 12px; width: 20px; text-align: center; }
.sidebar-nav a i.fa-chevron-down { margin-left: auto; margin-right: 0; font-size: 12px; }

.has-submenu { position: relative; }
.has-submenu > a { display: flex; align-items: center; justify-content: space-between; }
.submenu { list-style: none; padding: 0; background-color: #1a1f2e; display: none; }
.has-submenu.active > .submenu { display: block; }
.submenu li a { padding-left: 50px; font-size: 13px; }
.submenu li a:hover { background-color: #2d3748; }
.submenu li a.active { background-color: #4a5568; color: white; }

.main-content { margin-left: var(--sidebar-width); width: calc(100% - var(--sidebar-width)); min-height: 100vh; display: flex; flex-direction: column; }
.top-header { height: var(--header-height); background-color: white; border-bottom: 1px solid var(--border-color); display: flex; justify-content: space-between; align-items: center; padding: 0 30px; position: sticky; top: 0; z-index: 100; }
.header-left { display: flex; align-items: center; gap: 20px; }
.header-left h1 { font-size: 22px; color: var(--dark-color); }
.sidebar-toggle { background: none; border: none; font-size: 20px; color: var(--text-color); cursor: pointer; display: none; }
.header-right { display: flex; align-items: center; gap: 20px; }

.user-menu { position: relative; }
.user-btn { display: flex; align-items: center; gap: 8px; background: none; border: none; cursor: pointer; padding: 8px 12px; border-radius: 6px; transition: background 0.3s; }
.user-btn:hover { background-color: var(--light-color); }
.user-btn i.fa-user-circle { font-size: 28px; color: var(--primary-color); }
.user-dropdown { position: absolute; top: 100%; right: 0; margin-top: 8px; background: white; border: 1px solid var(--border-color); border-radius: 8px; box-shadow: 0 4px 12px rgba(0,0,0,0.1); min-width: 220px; display: none; }
.user-dropdown.show { display: block; }
.user-info { padding: 15px; border-bottom: 1px solid var(--border-color); }
.user-name { font-weight: 600; color: var(--dark-color); }
.user-role { font-size: 12px; color: #6b7280; }
.user-dropdown a { display: block; padding: 10px 15px; color: var(--text-color); text-decoration: none; transition: background 0.3s; }
.user-dropdown a:hover { background-color: var(--light-color); }
.user-dropdown a i { margin-right: 10px; width: 18px; }
.dropdown-divider { height: 1px; background-color: var(--border-color); }

.page-content { flex: 1; padding: 30px; }
.card { background: white; border-radius: 8px; box-shadow: 0 1px 3px rgba(0,0,0,0.1); margin-bottom: 20px; }
.card-header { padding: 20px; border-bottom: 1px solid var(--border-color); display: flex; justify-content: space-between; align-items: center; }
.card-header h3 { font-size: 18px; font-weight: 600; color: var(--dark-color); }
.card-body { padding: 20px; }
.card-footer { padding: 15px 20px; border-top: 1px solid var(--border-color); background-color: #f9fafb; }

.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 20px; margin-bottom: 30px; }
.stat-card { background: white; padding: 25px; border-radius: 8px; box-shadow: 0 1px 3px rgba(0,0,0,0.1); display: flex; align-items: center; gap: 20px; transition: transform 0.3s; }
.stat-card:hover { transform: translateY(-4px); box-shadow: 0 4px 12px rgba(0,0,0,0.15); }
.stat-icon { width: 60px; height: 60px; border-radius: 12px; display: flex; align-items: center; justify-content: center; font-size: 28px; color: white; }
.stat-icon.blue { background: linear-gradient(135deg, #3b82f6, #2563eb); }
.stat-icon.green { background: linear-gradient(135deg, #10b981, #059669); }
.stat-icon.orange { background: linear-gradient(135deg, #f59e0b, #d97706); }
.stat-icon.red { background: linear-gradient(135deg, #ef4444, #dc2626); }
.stat-icon.purple { background: linear-gradient(135deg, #8b5cf6, #a855f7); }
.stat-icon.teal { background: linear-gradient(135deg, #14b8a6, #06b6d4); }
.stat-content h4 { font-size: 12px; color: #6b7280; font-weight: 500; margin-bottom: 5px; }
.stat-content .stat-value { font-size: 28px; font-weight: 700; color: var(--dark-color); }
.stat-content small { font-size: 12px; color: #6b7280; }

.table-container { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
table thead { background-color: var(--light-color); }
table th { padding: 12px; text-align: left; font-weight: 600; color: var(--dark-color); border-bottom: 2px solid var(--border-color); }
table td { padding: 12px; border-bottom: 1px solid var(--border-color); }
table tbody tr:hover { background-color: #f9fafb; }

.form-group { margin-bottom: 20px; }
.form-group label { display: block; margin-bottom: 6px; font-weight: 600; color: var(--dark-color); }
.form-control { width: 100%; padding: 10px 12px; border: 1px solid var(--border-color); border-radius: 6px; font-size: 14px; transition: all 0.3s; }
.form-control:focus { outline: none; border-color: var(--primary-color); box-shadow: 0 0 0 3px rgba(5, 150, 105, 0.1); }
select.form-control { cursor: pointer; }
textarea.form-control { resize: vertical; min-height: 100px; }
.form-row { display: grid; grid-template-columns: repeat(2, 1fr); gap: 20px; }

.badge { display: inline-block; padding: 4px 10px; border-radius: 12px; font-size: 12px; font-weight: 600; }
.badge-success { background-color: #d1fae5; color: #065f46; }
.badge-danger { background-color: #fee2e2; color: #991b1b; }
.badge-warning { background-color: #fef3c7; color: #92400e; }
.badge-info { background-color: #dbeafe; color: #1e40af; }
.badge-secondary { background-color: #e5e7eb; color: #374151; }

.pagination { display: flex; gap: 5px; margin-top: 20px; justify-content: center; flex-wrap: wrap; }
.pagination a, .pagination span { padding: 8px 12px; border: 1px solid var(--border-color); border-radius: 4px; text-decoration: none; color: var(--text-color); }
.pagination a:hover { background-color: var(--light-color); }
.pagination .active { background-color: var(--primary-color); color: white; border-color: var(--primary-color); }
.pagination .disabled { opacity: 0.5; cursor: not-allowed; }

.main-footer { padding: 20px 30px; background-color: white; border-top: 1px solid var(--border-color); text-align: center; color: #6b7280; font-size: 13px; }

/* Tabs */
.tabs { display: flex; gap: 5px; margin-bottom: 20px; border-bottom: 2px solid var(--border-color); flex-wrap: wrap; }
.tabs a, .tabs span { padding: 12px 20px; text-decoration: none; color: var(--text-color); font-weight: 500; border-bottom: 3px solid transparent; margin-bottom: -2px; transition: all 0.3s; }
.tabs a:hover { color: var(--primary-color); }
.tabs a.active, .tabs span.active { color: var(--primary-color); border-bottom-color: var(--primary-color); }

.text-center { text-align: center; }
.text-right { text-align: right; }
.table-total { background-color: #f0fdf4; border-top: 2px solid var(--success-color); }
.text-danger { color: var(--danger-color); }
.mb-2 { margin-bottom: 20px; }
.mt-2 { margin-top: 20px; }

/* Image Lightbox */
.lightbox-overlay { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.9); z-index: 9999; display: flex; align-items: center; justify-content: center; cursor: pointer; }
.lightbox-overlay .lightbox-img { max-width: 95%; max-height: 95%; object-fit: contain; cursor: default; }
.lightbox-close { position: absolute; top: 20px; right: 30px; font-size: 36px; color: white; cursor: pointer; z-index: 10000; opacity: 0.8; }
.lightbox-close:hover { opacity: 1; }
.img-preview { cursor: pointer; }

/* Mobile overlay for sidebar */
.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.5);
    z-index: 999;
    opacity: 0;
    transition: opacity 0.3s;
}
.sidebar-overlay.show { display: block; opacity: 1; }

@media (max-width: 991px) {
    .sidebar { margin-left: calc(-1 * var(--sidebar-width)); transform: translateX(0); }
    .sidebar.show { margin-left: 0; box-shadow: 4px 0 20px rgba(0,0,0,0.2); }
    .main-content { margin-left: 0; width: 100%; }
    .sidebar-toggle { display: flex !important; align-items: center; justify-content: center; }
    .stats-grid { grid-template-columns: repeat(2, 1fr); gap: 12px; }
    .page-content { padding: 15px; }
    .top-header { padding: 0 15px; height: 56px; }
    .header-left h1 { font-size: 16px; }
    .card-header { flex-direction: column; align-items: flex-start; gap: 12px; padding: 15px; }
    .card-body { padding: 15px; }
    .stat-card { padding: 16px; gap: 12px; }
    .stat-icon { width: 48px; height: 48px; font-size: 22px; }
    .stat-content .stat-value { font-size: 22px; }
    .form-row { grid-template-columns: 1fr; }
    .table-container { margin: 0 -15px; overflow-x: auto; -webkit-overflow-scrolling: touch; }
    table { min-width: 600px; }
    table th, table td { padding: 10px 8px; font-size: 13px; }
    .btn { padding: 8px 14px; font-size: 13px; }
    .btn-sm { padding: 5px 10px; font-size: 12px; }
    .tabs { overflow-x: auto; -webkit-overflow-scrolling: touch; flex-wrap: nowrap; padding-bottom: 2px; }
    .tabs a, .tabs span { padding: 10px 14px; font-size: 13px; white-space: nowrap; }
    .pagination-container { flex-direction: column; gap: 12px; align-items: stretch; padding: 12px !important; }
    .pagination-per-page { justify-content: center; }
    .pagination { justify-content: center; flex-wrap: wrap; }
    .user-btn span { display: none; }
    .quick-actions-grid { grid-template-columns: repeat(2, 1fr) !important; gap: 10px !important; }
}

@media (max-width: 576px) {
    .stats-grid { grid-template-columns: 1fr; gap: 10px; margin-bottom: 20px; }
    .page-content { padding: 12px; }
    .top-header { padding: 0 12px; }
    .header-left h1 { font-size: 14px; max-width: 180px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
    .card-header { padding: 12px; }
    .card-body { padding: 12px; }
    .stat-card { padding: 14px; }
    .stat-content .stat-value { font-size: 20px; }
    .login-container { padding: 12px; }
    .login-box { padding: 24px; }
    .login-header h1 { font-size: 22px; }
    .quick-actions-grid { grid-template-columns: 1fr !important; }
    .form-group { margin-bottom: 16px; }
    .alert { padding: 10px 12px; font-size: 13px; }
}

/* Login page responsive */
@media (max-width: 480px) {
    .login-page { padding: 10px; align-items: flex-start; padding-top: 20px; }
    .login-box { padding: 20px; }
    .login-form input { padding: 10px; }
}

/* Ensure touch-friendly tap targets */
@media (pointer: coarse) {
    .sidebar-nav a { padding: 14px 20px; min-height: 44px; }
    .btn { min-height: 44px; min-width: 44px; display: inline-flex; align-items: center; justify-content: center; }
    .btn-sm { min-height: 36px; min-width: 36px; }
}

/* Prevent zoom on input focus (iOS) */
@media (max-width: 768px) {
    input.form-control, select.form-control, textarea.form-control { font-size: 16px; }
}

/* Print styles */
@media print {
    .sidebar, .sidebar-toggle, .sidebar-overlay, .user-menu, .btn:not(.btn-print), .quick-actions-grid, .no-print { display: none !important; }
    .main-content { margin-left: 0 !important; width: 100% !important; }
    .page-content { padding: 0 !important; }
}
