/* ============================================================
   SmartCom Masjid Management System - Login Styles
   ============================================================ */
*, *::before, *::after {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: 'Segoe UI', system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
    background: #f4f6f9;
    font-size: 16px;
    -webkit-tap-highlight-color: transparent;
}

:root {
    --primary: #1a365d;
    --secondary: #2d5aa0;
    --accent: #d69e2e;
    --green: #38a169;
    --light: #f7fafc;
    --dark: #2d3748;
    --gray: #718096;
    --light-gray: #e2e8f0;
    --shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    --radius: 8px;
    --transition: all 0.3s ease;
    --btnbg: #e6a904;
    --topbar-height: 70px;
}

/* TOP BAR - Mobile Optimized */
.topbar {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    padding: 12px 20px;
    border-bottom: 1px solid rgba(214, 158, 46, 0.2);
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.05);
    height: auto;
    min-height: 70px;
}

.topbar-inner {
    display: flex;
    align-items: center;
    gap: 15px;
    max-width: 1400px;
    margin: 0 auto;
}

@media (max-width: 768px) {
    .topbar-inner {
        flex-direction: column;
        gap: 8px;
        text-align: center;
    }
    .topbar {
        min-height: 80px;
        padding: 10px 15px;
    }
}

.topbar-logo {
    height: 44px;
    width: auto;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.1));
    transition: transform 0.3s ease;
}

@media (max-width: 768px) {
    .topbar-logo {
        height: 40px;
    }
}

.topbar-logo:active {
    transform: scale(0.98);
}

.title-wrapper h3 {
    margin: 0;
    color: #1a365d;
    font-size: 1.25rem;
    font-weight: 600;
    letter-spacing: -0.3px;
}

@media (max-width: 768px) {
    .title-wrapper h3 {
        font-size: 1rem;
    }
}

.subtitle {
    font-size: 0.8rem;
    color: #718096;
    display: block;
    margin-top: 2px;
    font-weight: 400;
}

@media (max-width: 768px) {
    .subtitle {
        font-size: 0.65rem;
    }
}

/* LAYOUT - Mobile First */
.container {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    padding-top: 10px;
    padding-bottom: 50px;
    box-sizing: border-box;
    min-height: 100vh;
    min-height: calc(100vh - 70px);
}

@media (min-width: 768px) {
    .container {
        padding: 2rem;
        padding-top: 15px;
        padding-bottom: 80px;
        min-height: calc(100vh - 70px);
    }
}

/* For better spacing on mobile when topbar is sticky */
@media (max-width: 768px) {
    .container {
        padding-top: 100px;
        padding-bottom: 40px;
        min-height: calc(100vh - 80px);
    }
}

/* CARD - Mobile Optimized */
.card {
    width: 100%;
    max-width: 800px;
    display: flex;
    flex-direction: column;
    border-radius: 16px;
    overflow: hidden;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.15);
    background: #fff;
    box-sizing: border-box;
}

@media (min-width: 768px) {
    .card {
        flex-direction: row;
        max-width: 800px;
        box-sizing: border-box;
    }
}

/* LEFT PANEL */
.left {
    width: 100%;
    background: linear-gradient(135deg, #0c042b 35%, var(--secondary) 65%);
    color: white;
    padding: 1rem;
    display: flex;
    flex-direction: column;
    box-sizing: border-box;
}

@media (min-width: 768px) {
    .left {
        width: 50%;
        padding: 1.5rem 1.75rem;
        box-sizing: border-box;
    }
}

/* Add scroll if content overflows on mobile */
@media (max-width: 768px) {
    .left {
        max-height: 50vh;
        overflow-y: auto;
    }
}

.left h2 {
    margin-bottom: 0.75rem;
    font-size: 1.5rem;
    margin-top: 0.75rem;
    text-align: center;
}
.left p {
    text-align: justify;
    margin-bottom: 1rem;
}

@media (max-width: 768px) {
    .left h2 {
        font-size: 1.35rem;
        margin-bottom: 0.5rem;
        margin-top: 0.5rem;
    }
}

.left p {
    font-size: 0.875rem;
    line-height: 1.5;
    margin-bottom: 1rem;
}

.left ul {
    margin-top: 0.75rem;
    padding: 0;
    list-style: none;
}

.left li {
    margin: 0.5 rem 0;
    font-size: 0.875rem;
    display: flex;
    align-items: center;
}

/* Icon spacing */
.iconSpace {
    list-style: none;
    padding: 0;
    margin-bottom: 7px;
    flex: 1;
}

.iconSpace li {
    margin: 0.75rem 0;
    font-size: 0.875rem;
    display: flex;
    align-items: center;
}

.iconSpace i {
    margin-right: 10px;
    width: 24px;
    text-align: center;
    font-size: 1.1rem;
}

/* Masjid Image Styling */
.masjid-image {
    text-align: center;
    margin-top: 20px;
    margin-bottom: 10px;
}

.masjid-image img {
    max-width: 60%;
    height: auto;
    border-radius: 12px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
    transition: transform 0.3s ease;
}

.masjid-image img:hover {
    transform: scale(1.02);
}

/* RIGHT PANEL */
.right {
    width: 100%;
    background: #f7f7f7;
    padding: 1.5rem;
    box-sizing: border-box;
}

@media (min-width: 768px) {
    .right {
        width: 50%;
        padding: 1.75rem 2rem;
        box-sizing: border-box;
    }
}

/* TABS - Mobile Friendly */
.tabs {
    display: flex;
    margin-bottom: 1.25rem;
    border-bottom: 1px solid var(--light-gray);
    gap: 0;
}

.tabs div {
    flex: 1;
    text-align: center;
    padding: 12px 8px;
    font-weight: 600;
    cursor: pointer;
    color: var(--gray);
    transition: var(--transition);
    border-bottom: 3px solid transparent;
    font-size: 0.875rem;
    min-height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
}

@media (max-width: 480px) {
    .tabs div {
        font-size: 0.8125rem;
        padding: 10px 6px;
    }
}

.tabs div:active {
    transform: scale(0.98);
}

.tabs .active {
    border-bottom-color: #e89905;
    border-width: 3px;
    color: var(--primary);
}

/* ROLE BOX - Responsive Grid - REDUCED HEIGHT */
.role-box {
    display: grid;
    gap: 8px;
    margin-bottom: 1.25rem;
    margin-top: 0.5rem;
}

/* Mobile: 1 column */
@media (max-width: 480px) {
    .role-box {
        grid-template-columns: 1fr;
        gap: 8px;
    }
}

/* Tablet: 2 columns */
@media (min-width: 481px) and (max-width: 767px) {
    .role-box {
        grid-template-columns: repeat(2, 1fr);
        gap: 8px;
    }
}

/* Desktop: 3 columns */
@media (min-width: 768px) {
    .role-box {
        grid-template-columns: repeat(3, 1fr);
        gap: 12px;
    }
}

/* Role styling - SIGNIFICANTLY REDUCED HEIGHT */
.role {
    border: 1px solid #ddd;
    padding: 6px 4px;
    text-align: center;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
    background: #fff;
    height: 48px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
}

@media (max-width: 480px) {
    .role {
        padding: 5px 3px;
        height: 45px;
    }
}

.role i {
    font-size: 1.2rem;
    margin-bottom: 0;
}

@media (max-width: 480px) {
    .role i {
        font-size: 1.5rem;
    }
}

.role span, .role br {
    display: none;
}

/* Show text without line break for compact view */
.role::after {
    content: attr(data-role-text);
    font-size: 0.9rem;
    display: block;
    line-height: 1.2;
}

@media (min-width: 768px) {
    .role::after {
        font-size: 0.75rem;
    }
}

@media (max-width: 480px) {
    .role::after {
        font-size: 0.65rem;
    }
}

.role:active {
    transform: scale(0.98);
}

.role.active {
    border-color: var(--accent);
    outline: 2px solid var(--accent);
    background: rgba(214, 158, 46, 0.1);
    color: var(--primary);
    font-weight: bold;
}

.role.active::after {
    font-weight: bold;
}

.role:hover {
    color: var(--primary);
    border-color: var(--primary);
    outline: 2px solid var(--primary);
    background: rgba(2, 73, 173, 0.05);
    font-weight: bold;
}

/* INPUT - Mobile Optimized */
input {
    width: 100%;
    padding: 14px;
    margin: 8px 0;
    border-radius: 10px;
    border: 1px solid #ccc;
    font-size: 16px;
    transition: border-color 0.2s, box-shadow 0.2s;
    box-sizing: border-box;
}

@media (max-width: 768px) {
    input {
        padding: 12px;
    }
}

input:focus {
    border-color: var(--accent);
    outline: none;
    box-shadow: 0 0 0 3px rgba(214, 158, 46, 0.2);
}

/* BUTTON - Mobile Friendly */
button {
    width: 100%;
    padding: 14px 16px;
    background: var(--accent);
    color: var(--primary);
    border: none;
    border-radius: 10px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    min-height: 52px;
    margin-top: 0.5rem;
}

@media (max-width: 768px) {
    button {
        padding: 12px 14px;
        min-height: 48px;
    }
}

button:active {
    transform: scale(0.97);
    background: #c4891c;
}

button:hover {
    background: #c4891c;
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(214, 158, 46, 0.3);
}

/* SMALL TEXT */
.small {
    font-size: 0.75rem;
    color: #777;
    text-align: center;
    margin-top: 12px;
}

@media (max-width: 768px) {
    .small {
        font-size: 0.7rem;
    }
}

/* Error/Success Messages */
.alert {
    padding: 12px;
    border-radius: 10px;
    margin-bottom: 1rem;
    font-size: 0.875rem;
    display: flex;
    align-items: center;
    gap: 8px;
}

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

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

/* Loading state */
button.loading {
    opacity: 0.7;
    cursor: wait;
}

button.loading::after {
    content: '';
    width: 18px;
    height: 18px;
    border: 2px solid rgba(255,255,255,0.3);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
    display: inline-block;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Touch-friendly adjustments */
@media (max-width: 768px) {
    .role, 
    .tabs div,
    button,
    input {
        touch-action: manipulation;
    }
}

/* Safe area support */
@supports (padding: max(0px)) {
    .container {
        padding-bottom: max(1rem, env(safe-area-inset-bottom));
    }
    
    .topbar {
        padding-left: max(20px, env(safe-area-inset-left));
        padding-right: max(20px, env(safe-area-inset-right));
    }
}

/* Landscape mode adjustments - REDUCED HEIGHT */
@media (max-width: 768px) and (orientation: landscape) {
    .container {
        min-height: auto;
        padding: 0.75rem;
        padding-top: 80px;
    }
    
    .left {
        padding: 1rem;
    }
    
    .right {
        padding: 1rem;
    }
    
    .role-box {
        grid-template-columns: repeat(3, 1fr);
        gap: 6px;
    }
    
    .role {
        height: 40px;
        padding: 4px 3px;
    }
    
    .role i {
        font-size: 0.85rem;
    }
    
    .role::after {
        font-size: 0.6rem;
    }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .role.active {
        outline: 3px solid var(--accent);
    }
    
    button {
        outline: 1px solid var(--primary);
    }
}

/* Reduced motion preference */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
    
    button:hover {
        transform: none;
    }
}

/* ============================================================
   BUTTON UNIFORM SIZING - FIX (WITH HOVER EFFECTS PRESERVED)
   ============================================================ */

/* Make all primary action buttons uniform */
.send-otp-btn,
.toggle-method-btn,
.zakath-portal-btn,
#loginSubmitBtn,
#otpVerifyForm button[type="submit"] {
    height: 52px !important;
    min-height: 52px !important;
    max-height: 52px !important;
    padding: 0 16px !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    margin-top: 10px !important;
    margin-bottom: 10px !important;
    width: 100% !important;
    box-sizing: border-box !important;
    border-radius: 8px !important;
    font-size: 15px !important;
    font-weight: 600 !important;
    line-height: 1.2 !important;
    transition: all 0.3s ease !important;
}

/* Hover effects for Send OTP button */
.send-otp-btn {
    background: linear-gradient(135deg, #28a745 0%, #20c997 100%) !important;
    color: white !important;
    border: none !important;
    margin-top: 10px !important;
}

.send-otp-btn:hover {
    background: linear-gradient(135deg, #1e7e34 0%, #169b7a 100%) !important;
    transform: translateY(-2px) !important;
    box-shadow: 0 5px 15px rgba(40, 167, 69, 0.4) !important;
}

/* Hover effects for Toggle button */
.toggle-method-btn {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%) !important;
    color: white !important;
    border: none !important;
    margin-top: 10px !important;
}

.toggle-method-btn:hover {
    background: linear-gradient(135deg, #5a67d8 0%, #6b3fa0 100%) !important;
    transform: translateY(-2px) !important;
    box-shadow: 0 5px 15px rgba(102, 126, 234, 0.4) !important;
}

/* Hover effects for Zakath Portal button */
.zakath-portal-btn {
    background: linear-gradient(135deg, #0f3057 0%, #11998e 100%) !important;
    color: white !important;
    border: none !important;
    margin-top: 10px !important;
    text-decoration: none !important;
    padding: 0 16px !important;
}

.zakath-portal-btn:hover {
    background: linear-gradient(135deg, #0a233f 0%, #0d7a70 100%) !important;
    transform: translateY(-2px) !important;
    box-shadow: 0 5px 15px rgba(17, 153, 142, 0.4) !important;
    color: white !important;
    text-decoration: none !important;
}

/* Hover effects for Login Submit button */
#loginSubmitBtn {
    background: var(--accent) !important;
    color: var(--primary) !important;
    border: none !important;
    margin-top: 10px !important;
}

#loginSubmitBtn:hover {
    background: #c4891c !important;
    transform: translateY(-2px) !important;
    box-shadow: 0 5px 15px rgba(214, 158, 46, 0.3) !important;
}

/* Remove the divider and adjust spacing */
.zakath-portal-divider {
    margin: 5px 0 5px 0 !important;
}

.zakath-portal-divider span {
    font-size: 12px !important;
}

/* Responsive adjustments for smaller screens */
@media (max-width: 768px) {
    .send-otp-btn,
    .toggle-method-btn,
    .zakath-portal-btn,
    #loginSubmitBtn,
    #otpVerifyForm button[type="submit"] {
        height: 48px !important;
        min-height: 48px !important;
        max-height: 48px !important;
        font-size: 14px !important;
        padding: 0 12px !important;
        margin-top: 8px !important;
        margin-bottom: 8px !important;
    }
    
    /* Mobile hover adjustments */
    .send-otp-btn:hover,
    .toggle-method-btn:hover,
    .zakath-portal-btn:hover,
    #loginSubmitBtn:hover {
        transform: translateY(-1px) !important;
    }
}

/* Fix for the "Back to Login Options" button - keep it different */
.back-to-password-btn {
    height: 44px !important;
    min-height: 44px !important;
    padding: 0 12px !important;
    margin-top: 5px !important;
    margin-bottom: 10px !important;
}

.back-to-password-btn:hover {
    background: #5a6268 !important;
    transform: translateY(-2px) !important;
    box-shadow: 0 4px 12px rgba(108, 117, 125, 0.3) !important;
}

/* ============================================================
   REDUCE GAP BETWEEN ROLES AND USERNAME FIELD
   ============================================================ */

/* Reduce margin for the role box */
.role-box {
    margin-bottom: 8px !important;
    margin-top: 4px !important;
    gap: 8px !important;
}

/* Reduce margin for username input */
#password_username {
    margin-top: 4px !important;
    margin-bottom: 4px !important;
}

/* Reduce margin for password input */
#password_field {
    margin-top: 4px !important;
    margin-bottom: 4px !important;
}

/* Reduce label margin too */
#passwordLogin label {
    margin-bottom: 2px !important;
    font-weight: 500 !important;
}

/* For the OTP form - maintain consistency */
#otpLogin .form-group {
    margin-bottom: 8px !important;
}

#otpLogin .form-group label {
    margin-bottom: 4px !important;
}

#otp_username {
    margin-top: 4px !important;
    margin-bottom: 4px !important;
}

/* Reduce gap between OTP input and button in verify form */
#otpVerifyForm .form-group {
    margin-bottom: 4px !important;
}

#otpVerifyForm .otp-input-group {
    margin-top: 4px !important;
}

#otpVerifyForm button[type="submit"] {
    margin-top: 10px !important;
}

/* Additional fix: Ensure the role selection text is properly aligned */
.role-box + input {
    margin-top: 4px !important;
}

/* Fix for any extra spacing in the password form */
#passwordForm input[type="text"],
#passwordForm input[type="password"] {
    margin-top: 4px !important;
    margin-bottom: 4px !important;
}