/* =====================================================
   Martial Arts Club Manager - Frontend Styles
   ===================================================== */

:root {
    --macm-bg:        #0f172a;
    --macm-bg-soft:   #1e293b;
    --macm-surface:   #ffffff;
    --macm-border:    #e5e7eb;
    --macm-text:      #0f172a;
    --macm-muted:     #64748b;
    --macm-primary:   #dc2626;        /* martial arts red */
    --macm-primary-2: #b91c1c;
    --macm-accent:    #f59e0b;
    --macm-success:   #16a34a;
    --macm-warn:      #d97706;
    --macm-danger:    #dc2626;
    --macm-radius:    14px;
    --macm-shadow:    0 6px 24px rgba(2, 6, 23, 0.08);
}

* { box-sizing: border-box; }

/* ============= AUTH (Login / Register) ============= */
.macm-auth-wrap {
    min-height: 100vh;
    display: flex; align-items: center; justify-content: center;
    background: linear-gradient(135deg, #0f172a 0%, #7f1d1d 100%);
    padding: 24px;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}
.macm-auth-card {
    width: 100%; max-width: 460px;
    background: #fff; border-radius: 20px; padding: 40px 32px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, .35);
}
.macm-auth-brand { text-align: center; margin-bottom: 26px; }
.macm-auth-logo {
    width: 64px; height: 64px; margin: 0 auto 12px;
    background: linear-gradient(135deg, #dc2626, #f59e0b);
    border-radius: 16px;
    display: flex; align-items: center; justify-content: center;
    font-size: 30px;
    box-shadow: 0 8px 24px rgba(220, 38, 38, .35);
}
.macm-auth-brand h1 { margin: 6px 0 4px; font-size: 24px; color: #0f172a; }
.macm-auth-brand p  { margin: 0; color: var(--macm-muted); font-size: 14px; }

.macm-auth-tabs {
    display: flex; background: #f1f5f9; border-radius: 12px; padding: 4px; margin-bottom: 22px;
}
.macm-tab {
    flex: 1; border: 0; background: transparent; padding: 10px 14px; cursor: pointer;
    border-radius: 10px; font-weight: 600; color: var(--macm-muted); transition: .2s;
}
.macm-tab.active {
    background: #fff; color: var(--macm-primary);
    box-shadow: 0 2px 6px rgba(0, 0, 0, .06);
}

.macm-auth-form { display: none; }
.macm-auth-form.active { display: block; }

.macm-field { margin-bottom: 14px; }
.macm-field label { display: block; font-size: 13px; font-weight: 600; color: #334155; margin-bottom: 6px; }
.macm-field input {
    width: 100%; padding: 11px 13px; border: 1px solid var(--macm-border);
    border-radius: 10px; font-size: 15px; transition: .2s; background: #fff;
}
.macm-field input:focus {
    outline: none; border-color: var(--macm-primary);
    box-shadow: 0 0 0 3px rgba(220, 38, 38, .12);
}

.macm-btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 6px;
    padding: 12px 18px; border: 0; border-radius: 10px;
    font-size: 15px; font-weight: 600; cursor: pointer; transition: .2s;
    width: 100%;
}
.macm-btn-sm { width: auto; padding: 7px 12px; font-size: 13px; }
.macm-btn-primary {
    background: linear-gradient(135deg, var(--macm-primary), var(--macm-primary-2));
    color: #fff;
}
.macm-btn-primary:hover { transform: translateY(-1px); box-shadow: 0 6px 16px rgba(220, 38, 38, .3); }
.macm-btn-ghost {
    background: transparent; color: #475569; border: 1px solid var(--macm-border);
}
.macm-btn-ghost:hover { background: #f8fafc; }
.macm-btn-danger { background: #ef4444; color: #fff; }
.macm-btn-spinner {
    display: none; width: 14px; height: 14px;
    border: 2px solid rgba(255,255,255,.5); border-top-color: #fff;
    border-radius: 50%; animation: macm-spin .7s linear infinite;
}
.macm-btn.loading .macm-btn-text { opacity: .6; }
.macm-btn.loading .macm-btn-spinner { display: inline-block; }
@keyframes macm-spin { to { transform: rotate(360deg); } }

.macm-form-msg { margin-top: 10px; font-size: 14px; min-height: 18px; }
.macm-form-msg.error   { color: var(--macm-danger); }
.macm-form-msg.success { color: var(--macm-success); }

/* ============= MODAL ============= */
.macm-modal {
    position: fixed; inset: 0; background: rgba(15, 23, 42, .65);
    display: flex; align-items: center; justify-content: center; z-index: 9999; padding: 20px;
    animation: macm-fade .2s;
}
@keyframes macm-fade { from { opacity: 0; } to { opacity: 1; } }
.macm-modal-card {
    background: #fff; border-radius: 16px; padding: 36px 28px; text-align: center;
    max-width: 420px; width: 100%; box-shadow: 0 24px 60px rgba(0, 0, 0, .3);
    animation: macm-pop .25s;
}
.macm-modal-large { max-width: 600px; text-align: left; padding: 28px; position: relative; }
.macm-modal-x {
    position: absolute; top: 12px; right: 14px;
    border: 0; background: transparent; font-size: 26px; cursor: pointer; color: #94a3b8;
}
@keyframes macm-pop { from { transform: scale(.9); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.macm-modal-icon { font-size: 48px; margin-bottom: 12px; }
.macm-modal-card h2 { margin: 0 0 10px; }
.macm-modal-card p { color: var(--macm-muted); margin-bottom: 18px; }

/* ============= INFO BANNERS ============= */
.macm-info, .macm-warning, .macm-pending-card {
    max-width: 600px; margin: 30px auto; padding: 22px;
    border-radius: var(--macm-radius); text-align: center;
    font-family: inherit;
}
.macm-info    { background: #eff6ff; color: #1e40af; }
.macm-warning { background: #fef3c7; color: #92400e; }
.macm-pending-card { background: #fff; box-shadow: var(--macm-shadow); }
.macm-pending-icon { font-size: 56px; }

/* ============= APP / DASHBOARD ============= */
.macm-app {
    display: grid;
    grid-template-columns: 250px 1fr;
    min-height: 100vh;
    background: #f1f5f9;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    color: var(--macm-text);
}

.macm-sidebar {
    background: #0f172a; color: #cbd5e1;
    padding: 22px 14px; display: flex; flex-direction: column;
    position: sticky; top: 0; height: 100vh;
}
.macm-brand { display: flex; gap: 10px; align-items: center; padding: 0 6px 22px; border-bottom: 1px solid #1e293b; margin-bottom: 14px; }
.macm-brand-logo {
    width: 42px; height: 42px; border-radius: 10px;
    background: linear-gradient(135deg, var(--macm-primary), var(--macm-accent));
    display: flex; align-items: center; justify-content: center; font-size: 22px;
}
.macm-brand-text strong { color: #fff; display: block; }
.macm-brand-text span { font-size: 12px; color: #64748b; }

.macm-nav { display: flex; flex-direction: column; gap: 2px; flex: 1; }
.macm-nav-item {
    display: flex; align-items: center; gap: 10px;
    padding: 10px 12px; color: #cbd5e1; text-decoration: none;
    border-radius: 8px; font-size: 14px; font-weight: 500;
    transition: .15s;
}
.macm-nav-item:hover { background: #1e293b; color: #fff; }
.macm-nav-item.active { background: var(--macm-primary); color: #fff; }
.macm-nav-item .ico { font-size: 16px; }

.macm-sidebar-footer { padding-top: 14px; border-top: 1px solid #1e293b; }
.macm-sidebar-footer .macm-btn-ghost { color: #cbd5e1; border-color: #334155; }
.macm-sidebar-footer .macm-btn-ghost:hover { background: #1e293b; }

/* Main */
.macm-main { padding: 22px 28px; }
.macm-topbar { display: flex; justify-content: space-between; align-items: center; margin-bottom: 22px; flex-wrap: wrap; gap: 12px; }
.macm-topbar h1 { margin: 0 0 4px; font-size: 22px; }
.macm-sub { margin: 0; color: var(--macm-muted); font-size: 14px; }
.macm-topbar-right { display: flex; gap: 10px; align-items: center; }
.macm-live { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--macm-success); font-weight: 600; }
.macm-pulse {
    width: 8px; height: 8px; border-radius: 50%;
    background: var(--macm-success);
    animation: macm-pulse 1.6s infinite;
}
@keyframes macm-pulse {
    0%   { box-shadow: 0 0 0 0 rgba(22, 163, 74, .55); }
    70%  { box-shadow: 0 0 0 10px rgba(22, 163, 74, 0); }
    100% { box-shadow: 0 0 0 0 rgba(22, 163, 74, 0); }
}

/* Badges */
.macm-badge {
    display: inline-block; padding: 4px 10px; border-radius: 999px;
    font-size: 12px; font-weight: 700; letter-spacing: .03em;
}
.macm-badge-admin      { background: #fee2e2; color: #991b1b; }
.macm-badge-instructor { background: #dbeafe; color: #1e40af; }
.macm-badge-assistant  { background: #dcfce7; color: #166534; }
.macm-badge-pending    { background: #fef3c7; color: #92400e; }
.macm-badge-active     { background: #dcfce7; color: #166534; }
.macm-badge-rejected, .macm-badge-suspended { background: #fee2e2; color: #991b1b; }

/* Views */
.macm-view { display: none; animation: macm-fade .2s; }
.macm-view.active { display: block; }

/* Stats */
.macm-stats {
    display: grid; gap: 14px;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    margin-bottom: 18px;
}
.macm-stat {
    background: #fff; padding: 16px; border-radius: var(--macm-radius);
    box-shadow: var(--macm-shadow);
    display: flex; align-items: center; gap: 14px;
    transition: .2s;
}
.macm-stat:hover { transform: translateY(-2px); box-shadow: 0 10px 28px rgba(2, 6, 23, .1); }
.macm-stat-icon {
    width: 48px; height: 48px; border-radius: 12px;
    display: flex; align-items: center; justify-content: center; font-size: 22px;
}
.macm-stat-num { font-size: 22px; font-weight: 800; }
.macm-stat-label { font-size: 12px; color: var(--macm-muted); }

/* Grid + cards */
.macm-grid {
    display: grid; gap: 14px;
    grid-template-columns: 1fr 1fr;
}
@media (max-width: 1000px) { .macm-grid { grid-template-columns: 1fr; } }

.macm-card {
    background: #fff; border-radius: var(--macm-radius); padding: 18px;
    box-shadow: var(--macm-shadow); margin-bottom: 14px;
}
.macm-card-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; }
.macm-card-head h3 { margin: 0; font-size: 16px; }
.macm-live-dot {
    width: 8px; height: 8px; border-radius: 50%;
    background: var(--macm-success); animation: macm-pulse 1.6s infinite;
}

/* Activity feed */
.macm-activity { display: flex; flex-direction: column; gap: 12px; max-height: 480px; overflow-y: auto; }
.macm-act-item { display: flex; gap: 11px; padding: 10px; border-radius: 10px; transition: background .15s; }
.macm-act-item:hover { background: #f8fafc; }
.macm-act-avatar {
    width: 36px; height: 36px; border-radius: 50%;
    background: linear-gradient(135deg, var(--macm-primary), var(--macm-accent));
    color: #fff; display: flex; align-items: center; justify-content: center; font-weight: 700;
    flex-shrink: 0;
}
.macm-act-line { font-size: 14px; }
.macm-act-action { color: var(--macm-primary); font-weight: 600; margin: 0 4px; }
.macm-act-module {
    background: #f1f5f9; padding: 1px 8px; border-radius: 6px;
    font-size: 11px; color: #475569; text-transform: uppercase;
}
.macm-act-desc  { font-size: 13px; color: #475569; margin-top: 2px; }
.macm-act-time  { font-size: 11px; color: #94a3b8; margin-top: 2px; }
.macm-empty { color: var(--macm-muted); text-align: center; padding: 20px; }

/* Permission grid */
.macm-perm-grid {
    display: grid; gap: 10px;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
}
.macm-perm {
    border: 1px solid var(--macm-border); border-radius: 12px;
    padding: 14px; text-align: center; transition: .2s;
}
.macm-perm.on { border-color: var(--macm-success); background: #f0fdf4; }
.macm-perm.off { opacity: .5; }
.macm-perm-ico { font-size: 24px; margin-bottom: 6px; }
.macm-perm-name { font-weight: 600; font-size: 14px; }
.macm-perm-status { font-size: 11px; color: var(--macm-muted); margin-top: 3px; }
.macm-perm.on .macm-perm-status { color: var(--macm-success); font-weight: 600; }

/* Tables */
.macm-table-wrap { overflow-x: auto; }
.macm-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.macm-table th, .macm-table td {
    padding: 11px 10px; text-align: left;
    border-bottom: 1px solid var(--macm-border);
}
.macm-table th { background: #f8fafc; font-weight: 600; color: #475569; font-size: 12px; text-transform: uppercase; letter-spacing: .04em; }
.macm-table tbody tr:hover { background: #f8fafc; }

/* Profile */
.macm-profile { display: flex; gap: 22px; align-items: center; flex-wrap: wrap; }
.macm-avatar {
    width: 90px; height: 90px; border-radius: 50%;
    background: linear-gradient(135deg, var(--macm-primary), var(--macm-accent));
    color: #fff; display: flex; align-items: center; justify-content: center;
    font-size: 36px; font-weight: 800;
}
.macm-profile-info h2 { margin: 0 0 6px; }
.macm-profile-info p  { margin: 4px 0; color: #475569; }

/* Module form */
#macm-form-fields { display: grid; gap: 12px; margin-bottom: 14px; }
#macm-form-fields label { display: block; font-size: 13px; font-weight: 600; color: #334155; margin-bottom: 4px; }
#macm-form-fields input, #macm-form-fields select, #macm-form-fields textarea {
    width: 100%; padding: 9px 11px; border: 1px solid var(--macm-border);
    border-radius: 8px; font-size: 14px; font-family: inherit;
}
#macm-form-fields textarea { min-height: 80px; resize: vertical; }
.macm-form-actions { display: flex; gap: 10px; justify-content: flex-end; }
.macm-form-actions .macm-btn { width: auto; }

/* Loading */
.macm-loading { padding: 30px; text-align: center; color: var(--macm-muted); }

/* Mobile */
@media (max-width: 768px) {
    .macm-app { grid-template-columns: 1fr; }
    .macm-sidebar {
        position: fixed; left: -260px; width: 250px; height: 100vh;
        z-index: 100; transition: left .25s;
    }
    .macm-sidebar.open { left: 0; box-shadow: 6px 0 30px rgba(0,0,0,.3); }
    .macm-main { padding: 14px; padding-top: 60px; }
    .macm-mobile-toggle {
        position: fixed; top: 14px; left: 14px; z-index: 101;
        width: 40px; height: 40px; border-radius: 8px; background: var(--macm-primary); color: #fff;
        border: 0; font-size: 18px; cursor: pointer; box-shadow: var(--macm-shadow);
    }
    .macm-grid { grid-template-columns: 1fr; }
    .macm-stats { grid-template-columns: 1fr 1fr; }
}
@media (min-width: 769px) { .macm-mobile-toggle { display: none; } }
