/* PetIoT Platform Styles */
:root {
    --primary: #4f46e5;
    --primary-hover: #4338ca;
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    --bg: #f1f5f9;
    --card-bg: #ffffff;
    --text: #1e293b;
    --text-muted: #64748b;
    --border: #e2e8f0;
    --radius: 8px;
    --shadow: 0 1px 3px rgba(0,0,0,0.1);
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
}

/* Login Page */
.login-container {
    display: flex; align-items: center; justify-content: center;
    min-height: 100vh; background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}
.login-card {
    background: var(--card-bg); border-radius: 12px; padding: 40px;
    width: 400px; box-shadow: 0 20px 60px rgba(0,0,0,0.2);
}
.login-card h1 { text-align: center; margin-bottom: 8px; font-size: 24px; color: var(--primary); }
.login-card .subtitle { text-align: center; color: var(--text-muted); margin-bottom: 32px; font-size: 14px; }
.login-card .tab-bar { display: flex; margin-bottom: 24px; border-bottom: 2px solid var(--border); }
.login-card .tab-bar button {
    flex: 1; padding: 10px; border: none; background: none;
    font-size: 15px; cursor: pointer; color: var(--text-muted);
    border-bottom: 2px solid transparent; margin-bottom: -2px; transition: all 0.2s;
}
.login-card .tab-bar button.active { color: var(--primary); border-bottom-color: var(--primary); font-weight: 600; }

/* Layout */
.layout { display: flex; min-height: 100vh; }
.sidebar {
    width: 240px; background: #1e293b; color: #fff;
    padding: 20px 0; position: fixed; top: 0; left: 0; bottom: 0; z-index: 100;
}
.sidebar .logo { padding: 0 20px 24px; font-size: 20px; font-weight: 700; color: #818cf8; }
.sidebar nav a {
    display: flex; align-items: center; gap: 10px; padding: 12px 20px;
    color: #94a3b8; text-decoration: none; font-size: 14px; transition: all 0.2s;
    border-left: 3px solid transparent;
}
.sidebar nav a:hover, .sidebar nav a.active { color: #fff; background: rgba(255,255,255,0.05); border-left-color: #818cf8; }
.sidebar .user-info { position: absolute; bottom: 20px; left: 20px; right: 20px; padding-top: 16px; border-top: 1px solid #334155; }
.sidebar .user-info .name { font-size: 14px; color: #e2e8f0; }
.sidebar .user-info .role { font-size: 12px; color: #818cf8; margin-top: 2px; }
.sidebar .user-info .logout { font-size: 12px; color: #94a3b8; cursor: pointer; margin-top: 6px; display: inline-block; }
.sidebar .user-info .logout:hover { color: #ef4444; }

.main { margin-left: 240px; flex: 1; padding: 24px; }
.page-header { margin-bottom: 24px; }
.page-header h2 { font-size: 22px; font-weight: 600; }
.page-header p { color: var(--text-muted); font-size: 14px; margin-top: 4px; }

/* Cards */
.card {
    background: var(--card-bg); border-radius: var(--radius);
    padding: 20px; box-shadow: var(--shadow); margin-bottom: 20px;
}
.card-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; }
.card-header h3 { font-size: 16px; font-weight: 600; }
.stats-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 16px; margin-bottom: 24px; }
.stat-card {
    background: var(--card-bg); border-radius: var(--radius); padding: 20px;
    box-shadow: var(--shadow); display: flex; align-items: center; gap: 16px;
}
.stat-card .icon { width: 48px; height: 48px; border-radius: 12px; display: flex; align-items: center; justify-content: center; font-size: 22px; }
.stat-card .icon.blue { background: #eef2ff; color: #4f46e5; }
.stat-card .icon.green { background: #ecfdf5; color: #10b981; }
.stat-card .icon.orange { background: #fffbeb; color: #f59e0b; }
.stat-card .icon.red { background: #fef2f2; color: #ef4444; }
.stat-card .stat-value { font-size: 24px; font-weight: 700; }
.stat-card .stat-label { font-size: 13px; color: var(--text-muted); }

/* Forms */
.form-group { margin-bottom: 16px; }
.form-group label { display: block; font-size: 13px; font-weight: 500; margin-bottom: 6px; color: var(--text); }
.form-group input, .form-group select, .form-group textarea {
    width: 100%; padding: 10px 12px; border: 1px solid var(--border);
    border-radius: var(--radius); font-size: 14px; transition: border-color 0.2s;
    background: #fff; color: var(--text);
}
.form-group input:focus, .form-group select:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(79,70,229,0.1); }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }

/* Buttons */
.btn {
    padding: 10px 20px; border: none; border-radius: var(--radius);
    font-size: 14px; font-weight: 500; cursor: pointer; transition: all 0.2s;
    display: inline-flex; align-items: center; gap: 6px;
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); }
.btn-success { background: var(--success); color: #fff; }
.btn-success:hover { opacity: 0.9; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { opacity: 0.9; }
.btn-outline { background: #fff; color: var(--text); border: 1px solid var(--border); }
.btn-outline:hover { background: #f8fafc; }
.btn-sm { padding: 6px 12px; font-size: 12px; }
.btn-block { width: 100%; justify-content: center; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* Tables */
table { width: 100%; border-collapse: collapse; }
th, td { padding: 12px 16px; text-align: left; border-bottom: 1px solid var(--border); font-size: 14px; }
th { background: #f8fafc; font-weight: 600; color: var(--text-muted); font-size: 12px; text-transform: uppercase; letter-spacing: 0.5px; }
tr:hover { background: #f8fafc; }

/* Badges */
.badge {
    padding: 2px 10px; border-radius: 20px; font-size: 12px; font-weight: 500;
    display: inline-block;
}
.badge-success { background: #ecfdf5; color: #065f46; }
.badge-warning { background: #fffbeb; color: #92400e; }
.badge-danger { background: #fef2f2; color: #991b1b; }
.badge-info { background: #eef2ff; color: #3730a3; }
.badge-gray { background: #f1f5f9; color: #475569; }

/* Toast */
.toast-container { position: fixed; top: 20px; right: 20px; z-index: 9999; }
.toast {
    padding: 12px 20px; border-radius: var(--radius); color: #fff; font-size: 14px;
    margin-bottom: 8px; box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    animation: slideIn 0.3s ease; min-width: 280px;
}
.toast.success { background: var(--success); }
.toast.error { background: var(--danger); }
.toast.warning { background: var(--warning); }
@keyframes slideIn { from { transform: translateX(100%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }

/* Modal */
.modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.5); display: flex; align-items: center; justify-content: center; z-index: 1000; }
.modal { background: #fff; border-radius: 12px; padding: 24px; width: 480px; max-width: 90vw; box-shadow: 0 20px 60px rgba(0,0,0,0.2); }
.modal h3 { margin-bottom: 16px; font-size: 18px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 20px; }

/* Loading */
.loading { text-align: center; padding: 40px; color: var(--text-muted); }
.spinner { width: 32px; height: 32px; border: 3px solid var(--border); border-top-color: var(--primary); border-radius: 50%; animation: spin 0.8s linear infinite; margin: 0 auto 12px; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Empty State */
.empty { text-align: center; padding: 40px; color: var(--text-muted); }
.empty .icon { font-size: 48px; margin-bottom: 12px; }

/* Error */
.error-message { color: var(--danger); font-size: 13px; margin-top: 4px; }

/* Responsive */
@media (max-width: 768px) {
    .sidebar { display: none; }
    .main { margin-left: 0; }
    .form-row { grid-template-columns: 1fr; }
    .stats-row { grid-template-columns: 1fr 1fr; }
}

/* Pagination */
.pagination-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 0;
    margin-top: 8px;
    border-top: 1px solid var(--border);
    flex-wrap: wrap;
    gap: 8px;
}

.pagination-info {
    font-size: 13px;
    color: var(--text-muted);
}

.pagination-controls {
    display: flex;
    align-items: center;
    gap: 4px;
    flex-wrap: wrap;
}

.pagination-pages {
    display: flex;
    align-items: center;
    gap: 4px;
}

.pagination-pages .btn {
    min-width: 32px;
    text-align: center;
}

.pagination-ellipsis {
    color: var(--text-muted);
    padding: 0 4px;
    font-size: 13px;
    user-select: none;
}

.pagination-controls .btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    pointer-events: none;
}

#page-size-select {
    width: auto;
    padding: 5px 8px;
    font-size: 12px;
}