/* ============================================================
   login.css - TTC Field Tracking Sign In Page
   Modern Microsoft Fluent UI Design
   ============================================================ */

*, *::before, *::after { box-sizing: border-box; }

:root {
    --primary: #0078D4;
    --primary-dark: #106EBE;
    --primary-light: #EFF6FC;
    --black: #2F2F2F;
    --text: #201F1E;
    --text-secondary: #605E5C;
    --success: #107C10;
    --warning: #FFB900;
    --error: #D13438;
    --surface: #FFFFFF;
    --border: #E1DFDD;
}

body {
    margin: 0;
    padding: 0;
    min-height: 100vh;
    font-family: 'Segoe UI', 'Sarabun', -apple-system, BlinkMacSystemFont, sans-serif;
    background: linear-gradient(135deg, #0078D4 0%, #106EBE 50%, #005A9E 100%);
    color: var(--text);
    overflow-x: hidden;
    position: relative;
}

/* ============ Animated Background Pattern ============ */
.bg-pattern {
    position: fixed;
    inset: 0;
    z-index: 0;
    pointer-events: none;
    background-image:
        radial-gradient(circle at 20% 30%, rgba(255,255,255,0.08) 0%, transparent 50%),
        radial-gradient(circle at 80% 70%, rgba(255,255,255,0.06) 0%, transparent 50%),
        radial-gradient(circle at 50% 50%, rgba(255,255,255,0.04) 0%, transparent 70%);
    animation: pattern-shift 20s ease-in-out infinite;
}

@keyframes pattern-shift {
    0%, 100% { transform: scale(1) rotate(0deg); }
    50% { transform: scale(1.1) rotate(5deg); }
}

/* ============ Layout ============ */
.login-container {
    position: relative;
    z-index: 1;
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
}

.login-card {
    background: var(--surface);
    border-radius: 20px;
    padding: 48px 40px 28px;
    width: 100%;
    max-width: 440px;
    box-shadow:
        0 24px 48px rgba(0,0,0,0.2),
        0 0 0 1px rgba(255,255,255,0.1);
    animation: card-enter 0.6s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes card-enter {
    from {
        opacity: 0;
        transform: translateY(30px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* ============ Branding ============ */
.brand {
    text-align: center;
    margin-bottom: 28px;
}

.logo {
    font-size: 64px;
    margin-bottom: 16px;
    display: inline-block;
    animation: logo-bounce 0.8s cubic-bezier(0.34, 1.56, 0.64, 1) 0.2s both;
}

@keyframes logo-bounce {
    from { opacity: 0; transform: scale(0.3); }
    to { opacity: 1; transform: scale(1); }
}

.brand h1 {
    color: var(--primary);
    font-size: 28px;
    font-weight: 600;
    margin: 0 0 12px;
    letter-spacing: -0.5px;
}

.subtitle {
    color: var(--text-secondary);
    font-size: 14px;
    line-height: 1.6;
    margin: 0;
}

/* ============ Alerts ============ */
.alert {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 16px;
    border-radius: 10px;
    margin-bottom: 20px;
    font-size: 13px;
    text-align: left;
    animation: alert-slide 0.4s ease-out;
}

@keyframes alert-slide {
    from { opacity: 0; transform: translateY(-10px); }
    to { opacity: 1; transform: translateY(0); }
}

.alert-icon {
    flex-shrink: 0;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 14px;
}

.alert-text {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.alert-text strong {
    font-weight: 600;
    font-size: 13px;
}

.alert-text small {
    font-size: 11px;
    opacity: 0.8;
}

.alert-success {
    background: #DFF6DD;
    color: var(--success);
    border-left: 4px solid var(--success);
}

.alert-success .alert-icon {
    background: var(--success);
    color: #fff;
}

.alert-warning {
    background: #FFF4CE;
    color: #8A6500;
    border-left: 4px solid var(--warning);
}

.alert-warning .alert-icon {
    background: var(--warning);
    color: #fff;
}

.alert-error {
    background: #FED9CC;
    color: var(--error);
    border-left: 4px solid var(--error);
}

.alert-error .alert-icon {
    background: var(--error);
    color: #fff;
}

/* ============ Microsoft Sign In Button ============ */
.ms-btn {
    width: 100%;
    height: 56px;
    background: var(--black);
    color: #fff;
    border: none;
    border-radius: 10px;
    font-family: inherit;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow: hidden;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.ms-btn:hover:not(:disabled) {
    background: #1A1A1A;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

.ms-btn:active:not(:disabled) {
    transform: translateY(0);
}

.ms-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.ms-btn-content {
    display: flex;
    align-items: center;
    gap: 12px;
}

.ms-logo {
    display: inline-grid;
    grid-template-columns: 1fr 1fr;
    width: 21px;
    height: 21px;
    gap: 1px;
}

.ms-logo span {
    display: block;
    width: 100%;
    height: 100%;
}

.ms-logo span:nth-child(1) { background: #F25022; }
.ms-logo span:nth-child(2) { background: #7FBA00; }
.ms-logo span:nth-child(3) { background: #00A4EF; }
.ms-logo span:nth-child(4) { background: #FFB900; }

/* Loading spinner inside button */
.btn-spinner {
    width: 20px;
    height: 20px;
    border: 2px solid rgba(255,255,255,0.3);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

/* ============ Footer ============ */
.login-footer {
    margin-top: 28px;
    padding-top: 20px;
    border-top: 1px solid var(--border);
    text-align: center;
}

.powered-by {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    margin-bottom: 6px;
    color: var(--text-secondary);
}

.powered-by small {
    font-size: 11px;
}

.powered-by strong {
    font-size: 12px;
    color: var(--primary);
    font-weight: 600;
}

.copyright {
    font-size: 10px;
    color: var(--text-secondary);
    opacity: 0.7;
}

/* ============ Responsive ============ */
@media (max-width: 480px) {
    .login-card {
        padding: 36px 28px 24px;
        border-radius: 16px;
    }
    
    .logo { font-size: 52px; }
    .brand h1 { font-size: 24px; }
    .subtitle { font-size: 13px; }
    .ms-btn { height: 52px; font-size: 14px; }
}

@media (max-height: 700px) {
    .login-card {
        padding: 32px 32px 24px;
    }
    .brand { margin-bottom: 20px; }
    .logo { font-size: 48px; margin-bottom: 12px; }
    .login-footer { margin-top: 20px; padding-top: 16px; }
}

/* ============ Smooth fade for hidden elements ============ */
[style*="display:none"] {
    display: none !important;
}
